0

I have built a static library foo.a with a bunch of functions. Some function definitions are not preset and as expected the linker gives undefined reference when I link it and try to create an elf. I would like to know if there is an option to provide the symbols along with addresses as a separate input in the linker command line(for the functions whose definitions are missing).

e.g: lets say I have a symbol definition file def.txt that has following function/global variable defines,

func_a 0x100 0x10

func_b 0x120 0x20

glob_b 0x200 0x4

glob_c 0x240 0x4

I would like to link the foo.a along with this file so that the linker doesn't complain about the definitions. In my system these functions exist in a different area(Lets say a ROM), That is the reason I am not defining them in this elf and just want to point out where they exist

gcc -static -nostdlib -nostartfiles -o foo.elf foo.a -lm -lgcc -T test.lod

In the above command line is there a way to input this def.txt file also

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Thomas
  • 489
  • 1
  • 8
  • 13
  • 2
    Why not simply define those symbols (and their locations) in the linker script? – Some programmer dude Apr 16 '18 at 11:15
  • I did that by creating my own section, like, .mysection : { G_var1 = 0x80057954; G_var2 = 0xd0000958; }. But in the final elf, when i check the disassembly I see that the address used to access these variables are incorrect. Is it the right way to assign the symbol address? – Thomas Aug 28 '18 at 06:01

0 Answers0