This is the mail archive of the binutils@sourceware.org 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]

Load addresses for ELF program headers on ARM


I'm trying to link an executable for bare-metal ARM, and am running
across something that seems like it's in violation of ARM's ELF spec.
I'm still learning some of this, so please let me know if this is just
a misunderstanding on my part.

I'm attempting to make a ROM-style executable, where the data segment
is tacked onto the end of the text segment, and code in the startup
routine copies it to its final address in RAM. ?Here's a test program,
and the corresponding linker script:

int x=5;
void _start()
{
?int y = x;
}

SECTIONS
{
?TEXT 0 : { *(.init) *(.fini) *(.text) *(.init_array) *(.fini_array) *(.jcr)}
?DATA 0x10000000 : AT( ADDR( TEXT ) + SIZEOF( TEXT ) ) { *(.data) }
}

I'm attempting to give the TEXT section an address of 0, and then give
the DATA segment a relocation address of 0x10000000, but a load
address directly after the text segment. ?After linking this program,
the resulting executable has the following:

Section Headers:
?[Nr] Name ? ? ? ? ? ? ?Type ? ? ? ? ? ?Addr ? ? Off ? ?Size ? ES Flg Lk Inf Al
?[ 1] TEXT ? ? ? ? ? ? ?PROGBITS ? ? ? ?00000000 008000 0000b4 00 WAX ?0 ? 0 ?4
?[ 2] DATA ? ? ? ? ? ? ?PROGBITS ? ? ? ?10000000 010000 000008 00 ?WA ?0 ? 0 ?4

Program Headers:
?Type ? ? ? ? ? Offset ? VirtAddr ? PhysAddr ? FileSiz MemSiz ?Flg Align
?LOAD ? ? ? ? ? 0x008000 0x00000000 0x00000000 0x000b4 0x000b4 RWE 0x8000
?LOAD ? ? ? ? ? 0x010000 0x10000000 0x000000b4 0x00008 0x00009 RW ?0x8000

The linker created two program headers, one for TEXT, and one for
DATA. ?The TEXT one looks fine--both vaddr and paddr are at 0. ?The
DATA segment, however, has a problem. ?It's been given a vaddr of
0x10000000, and a paddr of 0x000000b4. ?The former is the section's
relocation address, and the latter is its load address. ?However, the
ARM spec for ELF states that segments should have vaddr set to their
load address, and paddr set to 0 . ?Is there a way to convince the
linker to do this?

Thanks,
Matt

P.S. ?After typing all of this, I ran across
http://cygwin.ru/ml/binutils/2002-09/msg00516.html, which basically
seems to describe my problem. ?Is this pretty much just broken by
design, then, or is there some way around it? ?The reason it's a
problem for me is that I may be using these executables with other
tools which do obey the ARM spec, so as it stands they will try to put
code in the wrong places.


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