-
I get null for
dli_sname
:$ gcc test.c -ldl -o test $ ./test fname: ./test symbol: (null)
How exactly are you building this?
-
Yes, that is correct; with your
gcc
invocationmain
isn't a dynamic symbol and consequently the dynamic linker won't be able to resolve it.To fix this you will need to explicitly tell the linker to export the symbols as dynamic using
--export-dynamic
or--dynamic-list
. For instance,$ gcc -ldl -o test.o test.c -Wl,--export-dynamic $ ./test.o fname: ./test.o symbol: main
Please register or sign in to comment