GNU linker: alternative to --version-script to list exported symbols at the command line?

天涯浪子 提交于 2019-12-03 07:32:12

I'm not sure that you can do this like you want. One way is with the linker version script like you mentioned. Another way is to add in your source code __attribute__ ((visibility("default"))) for whatever you want exported and compile everything with -fvisibility=hidden

I may be eight years late, but yes, you actually can do what you want.

Use Bash process substitution:

gcc -shared foo.c -Wl,--version-script=<(echo "{global:foo1;foo2;local:*;};") -o libfoo.so -soname libfoo.so

readelf and objdump have lots of options. How about:

readelf --symbols --use-dynamic $yourlib.so
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!