so动态库只导出指定函数

retain_sym.txt

1
2
func1
func2

ver_script.txt

1
2
3
4
5
6
7
LIBA_1.1 {
	global:
		foo1;
		foo2;
	local:
		*;
};
1
ld -shared --retain-symbols-file=retain_sym.txt --version-script=ver_script.txt tst.o -o tst.so

refer to:
https://blog.csdn.net/chdhust/article/details/79356717
http://blog.sina.com.cn/s/blog_493667730100csde.html
http://www.gnu.org/software/gnulib/manual/html_node/LD-Version-Scripts.html