gcc 去除符号表

读取符号表

readelf -p .dynstr mylib.so


通过gcc控制可见性

__attribute__((visibility("hidden"))) int foo(int a, int b);
__attribute__((visibility("default"))) int foo(int a, int b);


ndk中控制

NDK_ROOT/platforms/android-9/arch-arm/usr/include/jni.h

#define JNIIMPORT
#define JNIEXPORT  __attribute__ ((visibility ("default")))
#define JNICALL

修改LOCAL_CFLAGS选项加入-fvisibility=hidden


隐藏那些局部符号名呢(t类型的符号)

cmd-strip = $(TOOLCHAIN_PREFIX)strip --strip-debug -x $1


https://gcc.gnu.org/wiki/Visibility

http://my.huhoo.net/archives/2010/03/post-52.html

你可能感兴趣的:(c/c++)