Re: how to keep some basic relocation information in executable binary

Jason McMullan <[email protected]>
Newsgroups gmane.linux.ports.arm.general
Organization Netronome Systems
Message-ID <1255025619.6786.13.camel@jmcmullan-laptop>
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 <[email protected]>
Netronome Systems

_______________________________________________
linux-arm mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkrOK88ACgkQ8/0vJ5szK6lWQACgpYxtYYZ1CoYFSkUeOME8wkSc
UYUAoMoXA/b/0AAA1V4hHCj/KZdlZWnj
=vhOC
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.