How to create symbol table using gcc

I would like to create a symbol definition table to be used in a separate application during linking. The ARM armlink linker has the following flag, but I am using arm-eabi:

- symdefs = filename

+4


source to share


3 answers


This is the correct answer from arm gnu launchpad:



Are you intending to download a symdef file using the GNU toolchain or with armcc? If the former, I think using nm in the object file and then linking with -R <filename>

will work. This way you do arm-none-eabi-nm -D ./prog > ./prog.defsym

after linking prog and then arm-none-eabi-gcc -Wl,-R,./prog.defsym

when you want to use it.

+1


source


-Wl,-Map -Wl,mapfile -Wl,--cref



added to the final gcc command line (link) should do the trick.

+1


source


The GNU objcopy utility has an option --extract-symbol

that can do what you want. It generates an object file with only character data - no actual code or data.

It is specifically designed to create a .sym file for use in the VxWorks RTOS, which has a command shell and a dynamic linker / loader that uses this information. It is also used by the VxWorks host wrapper and source-level debugger.

binutils nm , on the other hand, generates output very similar to armlink --symdefs

, which you can easily execute exactly in the form you need.

+1


source







All Articles