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

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

+7
source share
2 answers

I believe this answer will give you a solution.

In short, you can use the "prefix" characters in an existing library using objcopy as follows:

objcopy --prefix-symbols = foo_ foo.o

+11
source

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


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

If you know the names of the characters you want to override, you can try using objcopy --redefine-syms old=new . See the objcopy man pages for more input information (objcopy can overwrite a file, so be careful with this)

If you don't know the character names you can use, using nm to get a list of characters. Again, since I'm not sure what characters you are looking for, man pages are likely to be your best bet.

+3
source

All Articles