Reputation: 659
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.)
Upvotes: 0
Views: 337
Reputation: 22569
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.
Upvotes: 0