I know that in the past there was an option -fprefix-function-name that would add a prefix to all generated symbols, it doesn't seem to be part of gcc anymore. Is there any other way to do this?

有帮助吗?

解决方案

I believe this answer will give you the solution.

In short, you can 'prefix' symbols in an existing library using objcopy like this:

objcopy --prefix-symbols=foo_ foo.o

其他提示

*EDIT: George Skoptsov's solution's better than mine :) The nm trick might come in handy though.


This is not exactly what you are looking for, but I have had to do something similar in the past (renaming the symbols exported by a library)

If you know the names of the symbols you want to redefine you can try using objcopy --redefine-syms old=new . See the man pages of objcopy for more details on the input (objcopy might overwrite your file so be careful with that)

If you do not know the names of the symbols you can trying using nm to get a list of symbols. Again, since I am not sure what kind of symbols you are looking for, the man pages will probably be your best bet.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top