-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Labels
Description
OS: Arch linux amd64
C Compiler: gcc-14.2.1
I followed the documentation, compiled foo.c3 to static-lib using c3c static-lib command, and renamed foo.a to libfoo.a.
However, I have no clue on this part:
int foo_square(int) __attribute__ ((weak, alias ("foo.square")));- No symbol 'foo.square' in foo.a
I used nm to check the symbol
nm -g foo.aand I could see foo__square in the output, so I changed alias name to foo__square. It didn't work.
The compile command:
gcc test.c -L. -l foo -o mainor
gcc test.c -L. -l foo -Wl,--defsym=foo_square=foo__squaredidn't compile. I changed to C code.
2. Use extern or asm instead.
To compile, I changed the C code to this:
int foo_square(int) asm("foo__square");and it compiled successfully with proper result.
I'm not sure why the export symbols is different, perhaps it's platform depent?