Create symdef file

Asked by Nick

Hi I have tried to create a symdef file with this flag but it doesnt recognise it. I added it in the linker.
--symdefs=symdefs.sym

I would like to create a symbol to load in a separate application.

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi Nick,

Do you intend to load the symdef file with the GNU toolchain or with armcc one? If the former I think using nm on the object file and then linking with -R <filename> would work. So you would 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 this.

Hope this helps,

Thomas

Revision history for this message
Nick (n-karakotas) said :
#2

Hi,

Thanks but it cant seem to pick it up with -R. I still get unresolved references.

Revision history for this message
Nick (n-karakotas) said :
#3

Output from nm is:

0800f2ec T __adddf3
0800fb10 T __aeabi_cdcmpeq
0800fb10 T __aeabi_cdcmple
0800fb00 T __aeabi_cdrcmple
0800fc14 T __aeabi_d2f
0800fb84 T __aeabi_d2iz
0800fbd4 T __aeabi_d2uiz
0800f2ec T __aeabi_dadd
0800fb20 T __aeabi_dcmpeq
0800fb5c T __aeabi_dcmpge
0800fb70 T __aeabi_dcmpgt
0800fb48 T __aeabi_dcmple
0800fb34 T __aeabi_dcmplt
0800f8a4 T __aeabi_ddiv
0800f650 T __aeabi_dmul

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#4

Hi Nick,

My bad, I misread the usage of -R option. It will read symbols from a binary file. Therefore the correct workflow would be to copy the final binary (let's call it main) into another file (sym in my example). Then you run arm-none-eabi-objcopy --extract-symbol on it:

arm-none-eabi-objcopy --extract-symbol sym

You should then be able to link with -R option. However I noticed an error due to --extract-symbol removing the attributes. I will search more on my side and will let you know.

In the mean time, one thing that work is using the binary itself as a parameter to ld -R:

arm-none-eabi-gcc -o main main.o -Wl,-R,sym -specs=nosys.specs

where main.o reference a function foo that is defined in foo.o not linked in. ld will take the symbol address from main.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#5

Hi Nick,

I just found by chance that objcopy --extract-symbol would produce something suitable as a symdef file. It remove all the contents from the sections except for the symbol table. It will keep all symbols, not just the global ones, but that shouldn't be a problem because the local ones will get ignored when linking in the file.

I realize it's a very late answer but I hope it will be useful nonetheless.

Best regards.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#6

err, nevermind, I already gave that answer.

Can you help with this problem?

Provide an answer of your own, or ask Nick for more information if necessary.

To post a message you must log in.