Search code examples
gccarmldlinker-scriptsobjcopy

obj-copy ignores some padding


I have come across a strange problem in the arm obj-copy. Am I doing something wrong or have I come across a bug?

I want to pad my image with zeroes up to 0x1000 (4096) alignment and I do this padding via the below link script. The problem is that obj-copy does not copy the whole padding, it stops at 0x400 for some reason.

I have used objdump to evaluate my section and it seems to be of correct size for padding to 0x1000.

How come the hexdump of my binary is not padded correctly in case of using 0x1000 padding? I use objcopy the following way to create my binary:

 /usr/local/armhf/r27/bin/arm-axis-eabi-objcopy -I elf32-little -O binary myobj.o myobj.bin

Objdump:

.fill         0000080c  009117f4  009117f4  000117f4  2**0
              CONTENTS, ALLOC, LOAD, DATA

009117f4 l    d  .fill  00000000 .fill
00912000 g       .fill  00000000 __Eloadimg

link script:

__Edata = .;

.fill :
{
  FILL(0x00000000);
  BYTE(0x00);
  . = ALIGN(0x1000);
}

__Eloadimg = .;

Solution

  • I found the error and it was mine. After evaluating all calculations in my linker script I found out that MEM_START was 0x905c00 which made a hexdump of the binary look non aligned in the case of 0x1000 alignment.