Reputation: 6385
How is this possible:
>nm --defined-only foobar.so | grep foobar
000000000003c7c0 t foobar
>gcc foobar.c foobar.so
foobar.c:(.text+0x19): undefined reference to `foobar'
collect2: ld returned 1 exit status
Upvotes: 0
Views: 212
Reputation: 20080
On top of excellent @Tibrogargan answer, you may try to check binding using readelf
utility, it is a bit more clear wrt global vs local symbols - it will actually print GLOBAL or LOCAL
> readelf --symbols foobar.so
Upvotes: 0
Reputation: 4603
You can't link to "foobar" because foobar.so defines "foobar" as a local symbol in the "text" area and only global symbols are exported
The 2nd column of the output of nm gives the symbol type. lowercase means local, uppercase means global. Only global symbols are exported. See man nm(1)
Upvotes: 1