public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Load addresses for ELF program headers on ARM
@ 2010-10-11  0:47 Matt Fischer
  2010-10-11  1:55 ` Alan Modra
  0 siblings, 1 reply; 14+ messages in thread
From: Matt Fischer @ 2010-10-11  0:47 UTC (permalink / raw)
  To: binutils

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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-03-17  2:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-11  0:47 Load addresses for ELF program headers on ARM Matt Fischer
2010-10-11  1:55 ` Alan Modra
2010-10-11  2:43   ` Matt Fischer
2010-10-11  3:29     ` Alan Modra
2010-10-11  3:39       ` Matt Fischer
2010-10-11 14:44         ` Daniel Jacobowitz
2010-10-11 15:21           ` Matt Fischer
2011-03-15 15:36             ` Matt Fischer
2011-03-16  4:29               ` Alan Modra
2011-03-17  0:37                 ` Matt Fischer
2011-03-17  2:38                   ` Alan Modra
2011-03-17  2:56                     ` Matt Fischer
2010-10-11  2:50   ` Daniel Jacobowitz
2010-10-11  3:28     ` Matt Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).