0

When embedding binary files in a elf image with gcc, is there a way to change the address of the automatically generated _binary_*_size symbols? Unlike the _binary_*_start and _binary_*_end symbols, the _binary_*_size symbols don't seem to follow the base address of the code. They are in a bfd absolute section (*ABS*).

For example:

$ arm-linux-gnueabihf-gcc -nostdlib -Wl,-Ttext=0x80000000,--format=binary,foo.bin,--format=default boot.S
$ arm-linux-gnueabihf-nm a.out | sort
00000010 A _binary_foo_bin_size
80000000 T _start
80008004 D _binary_foo_bin_start
80008014 D _binary_foo_bin_end
80008014 A __bss_start
80008014 A __bss_start__
80008014 A __bss_end__
80008014 A _bss_end__
80008014 A _edata
80008014 A _end
80008014 A __end__

I would like _binary_foo_bin_size to be in 0x80008*** instead of 0x00000***. (Preferably without writing my own linker script or using extra objcopy commands.)

Dominic
  • 619
  • 5
  • 4

1 Answers1

0

I think the _size symbol records the size of the section. So, offsetting this symbol would be wrong -- it would no longer record the size.

I'm curious why you need to do this. You didn't say. Maybe there is some other way to achieve your goal.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63
  • I need to get rid of the _size symbols, because when I load the ELF on my board, the debugger is trying to write the _size data at address 0x00000010 which the boot ROM on my board. – Dominic Nov 04 '13 at 21:27
  • Also I'm surprised there is any data to write. I guess I would start by more directly trying to remove the symbol. – Tom Tromey Nov 05 '13 at 02:17
  • That's ARM DS-5 5.16 (with DSTREAM). – Dominic Nov 05 '13 at 18:33