Mr Pang
Mr Pang

Reputation: 1181

Is it possible to export a sub set of symbols using gcc?

I have an executable now. And I want to call some functions in this executable from other process, so I try to compile the executable using "-fPIC -pie -rdynamic", and usig dlopen() dlsym() to call the functions. It works as expected. But "-rdynamic" exports many symbols which is not needed. I only want to export a sub set of them. How to do it?

Upvotes: 2

Views: 374

Answers (1)

Mr Pang
Mr Pang

Reputation: 1181

I have found a solution. Using -Wl,--dynamic-list,symbol.list symbol.list is a file in current path, with content like:

{foo;goo;};

which means that I export symbol foo and goo

Upvotes: 1

Related Questions