How can I get gcc to add a prefix to all symbol names

扶醉桌前 提交于 2019-12-18 15:17:41

问题


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?


回答1:


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




回答2:


*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.



来源:https://stackoverflow.com/questions/10157680/how-can-i-get-gcc-to-add-a-prefix-to-all-symbol-names

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