This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Linker script section assignment issue

Since I wanted to prefix my firmware with a custom header containing a checksum, I've added an empty section called ".header". My target has a RAM and a FLASH region, so I assigned the ".header" section to the FLASH region. Whenever I leave the section completely empty it ends up in a segment different from the others (.text/.rodata) and gets ignored when I try to copy it using objcopy. Yet if I add a single BYTE(0), or even a C array sized 0 to the section, it ends up in the same segment as the others and I have no issues copying it. I would like to understand why it ends up in a different segment when left empty.


Linker script excerpt:
  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
  FLASH (rx) : ORIGIN = 0x8010000, LENGTH = 1024K
    .header : /* size and checksum */
        _sflash = .;
        /* BYTE(0) This solves the problem */
        . = _sflash + 0x200;

    .isr_vector : /* interrupt vector */
        . = ALIGN(4);
        _svector = .;
        . = ALIGN(4);

    .text : /* code goes here*/
        . = ALIGN(4);
        . = ALIGN(4);
            _etext = .;
    } > FLASH
Output from arm-none-eabi-readelf -S -l
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz Flg Align
  LOAD           0x008000 0x08010000 0x08010000 0x00000 0x00200 RW  0x8000
  LOAD           0x000200 0x08010200 0x08010200 0x24ca8 0x24ca8 R E 0x8000
  LOAD           0x028000 0x10000000 0x08034ea8 0x002c8 0x012b4 RW  0x8000

 Section to Segment mapping:
  Segment Sections...
   00     .header
   01     .isr_vector .text .rodata
02 .data .bss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]