GNU ld removes section

Posted by Jonatan on Stack Overflow See other posts from Stack Overflow or by Jonatan
Published on 2010-04-21T11:27:21Z Indexed on 2010/04/21 11:33 UTC
Read the original article Hit count: 372

Filed under:
|
|
|
|

I'm writing a boot script for an ARM-Cortex M3 based device. If I compile the assembler boot script and the C application code and then combine the object files and transfer them to my device everything works.

However, if I use ar to create an archive (libboot.a) and combine that archive with the C application there is a problem:

I've put the boot code in a section:

    .section    .boot, "ax"
    .global     _start

_start:
    .word       0x10000800  /* Initial stack pointer (FIXME!) */
    .word       start
    .word       nmi_handler
    .word       hard_fault_handler
    ... etc ...

I've found that ld strips this from the final binary (the section "boot" is not available). This is quite natural as there is no dependency on it that ld knows about, but it causes the device to not boot correctly.

So my question is: what is the best way to force this code to be included?

© Stack Overflow or respective owner

Related posts about gcc

Related posts about as