avutil/x86/x86util: tone down NASM workaround and use info section

The use of code section (.text) was forced by the unreleased NASM
3.02rc3 which made the issue worse, but preventing assambling anything
without code section, including when only data was present.

This works fine for the most part, but using code (.text) section with
IMAGE_COMDAT_SELECT_ANY causes issues with lib.exe after stripping such
object:
fatal error LNK1143: invalid or corrupt file: no symbol for COMDAT section 0x2

Esentially it makes our workaround not work in all cases, and while
string could be disabled like it already is for MSVC/ICL builds, it used
to work so let's preserve that state.

This make it not compatible with NASM 3.02rc3 when CV debug info is
generated, but hopefully the upstream fix will be merged before release,
to avoid this regression:
https://github.com/netwide-assembler/nasm/pull/221

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
This commit is contained in:
Kacper Michajłow
2026-03-30 19:38:10 +02:00
parent 89c21b5ab7
commit 7d57621b83

View File

@@ -1025,14 +1025,12 @@
; NASM panics when emitting CodeView debug info for an empty translation unit.
; GNU binutils `strip` and some other tools such as older MSVC linker also fail
; on such files. Emit a dummy byte in a COMDAT section to work around this.
; The linker will discard it since __x86util_notref is not referenced anywhere.
; on such files. Emit a dummy byte in a section with IMAGE_SCN_LNK_REMOVE flag
; to work around these issues. Sections like that are dropped by the linker.
%ifidn __OUTPUT_FORMAT__,win64
section .text
section .text$__x86util_notref comdat=2:__x86util_notref
section .x86util info
db 0
%elifidn __OUTPUT_FORMAT__,win32
section .text
section .text$__x86util_notref comdat=2:__x86util_notref
section .x86util info
db 0
%endif