|
|
|
Re: how to keep some basic relocation information in executable binary | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
|
On Thu, 2009-10-08 at 06:54 -0700, Peiyu Li wrote:
> I am trying to find a way to build out one ARM-instruction binary that
> can run at any address in the bare metal environment.
Tricky. In my case, I wanted to create a binary that can run from
any address, *including* read-only ROM space.
For my solution, the following requirements were needed:
* I can have no .data segment (only .rodata)
* No exceptions (no C++, setjmp or longjmp)
I compile all the objects with "gcc -fpie -fomit-frame-pointer"
I linked with "gcc -static -nodefaultlibs -nostartfiles -Wl,-Ttext=0
-Wl,-Tdata=0"
The .data == .text is just a linker trick to make sure that the
linker dies with an error if any data or bss segment is defined.
Final binary created with "objcopy -O binary file.elf file.bin"
My 'start.S' routine is as follows:
.global main
.global _start
_start:
ldr sp, =(CHIP_SRAM_64K - 0xf000)
b main
My main.c just has a void main(void) {} routine that works from there.
If you wanted to have a .bss, you can extend your _start to zero it out,
and add -Wl,--section-start=.bss=WHEREVER to locate your BSS at a
constant location.
This may not fully handle what you need, but it may provide you with
some ideas.
--
Jason McMullan <jason.mcmullan@xxxxxxxxxxxxx>
Netronome Systems
Attachment:
signature.asc
Description: This is a digitally signed message part
_______________________________________________ linux-arm mailing list linux-arm@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/linux-arm
[Linux ARM] [Linux ARM MSM] [Linux ARM Kernel] [Fedora ARM] [IETF Annouce] [Security] [Bugtraq] [Linux] [Linux OMAP] [Linux MIPS] [ECOS] [Asterisk Internet PBX] [Linux API]
![]() |
![]() |