0

I am generating an ELF file for ARM platform using linaro tool chain. The file is an executable that is supposed to run bare-metal.

I use a linker script to select the locations of sections in the memory because I want to put specific sections in specific locations.

The problem is that when I move some section forward in the memory I see that the image size increases, although no additional data has been added.

When I run readelf -a elf_file I see that both the virtual address (see Address field below) and the offset in image (See Offset field below) are both increased.

Example:

The following lines in the linker script

. = 0x2000000; .__translations_block_0 : { TM_TranslationTables.o(__translations_block_0) }

Result in the following offsets in the elf file (output from readelf)

[Nr] Name Type Address Offset Size EntSize Flags Link Info Align [10] .tdata PROGBITS 0000000000279000 00279080 000000000000000c 0000000000000000 WAT 0 0 16 [11] .tbss NOBITS 0000000000279080 0027908c 0000000000011bcc 0000000000000000 WAT 0 0 16 [12] .__translations_b PROGBITS 0000000002000000 02000080 0000000000000008 0000000000000000 WA 0 0 8 [13] .__translations_b PROGBITS 0000000002001000 02001080 0000000000000008 0000000000000000 WA 0 0 8

My question is:

Is there a way to increase the address of some section without blowing the image size? I just want the section to be loaded into memory address 0x2000000, I don't want the image size to be 0x2000000.

Any help would be appreciated.

siwesam
  • 463
  • 5
  • 8
  • If I'm not mistaken, what you're doing is moving the location counter in the `.tbss` section, and only then declaring the new section. Can you try `.__translations_block_0 0x2000000 : ...` ? – ninjalj Sep 29 '16 at 19:19
  • That didn't help.. Still getting the same image – siwesam Sep 30 '16 at 08:25
  • Did you remove the `. = 0x2000000` line? – ninjalj Sep 30 '16 at 15:47
  • Yes.. is it supposed to work according to the ARM ELF standard? – siwesam Sep 30 '16 at 17:39
  • I thought it'd work from a quick skimming of https://sourceware.org/binutils/docs/ld/Output-Section-Description.html#Output-Section-Description – ninjalj Oct 01 '16 at 08:17

0 Answers0