yasm - using gcc __attribute__((__cdecl__)) still results with ld "undefined symbol" - Stack Overflow

admin2025-04-16  4

Have an existing .asm source module setup for the standard cdecl naming and calling convention that is built with yasm for an elf32 target. The .asm source can be used across different platforms and architectures.

The C function is declared with __attribute__((__cdecl__)), but the linker is still looking for the name without the leading underscore.

Turns out that gcc only changes the calling convention and not the name.

So two questions:

1 - Does yasm have an option to automatically strip leading underscores (_) for all the symbols that have them?

2 - Does gcc have an attribute or method to let it know the name needs an underscore.

FWIW, if you have a COFF or OMF .obj file, objconv can convert it and handle everything:

objconv -felf32 -nu source.obj target.o

TIA!!

转载请注明原文地址:http://www.anycun.com/QandA/1744775342a87452.html