This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: Specifying LMA's after unallocated sections?
- To: jlarmour at redhat dot co dot uk
- Subject: Re: Specifying LMA's after unallocated sections?
- From: Ian Lance Taylor <ian at zembu dot com>
- Date: 6 Apr 2000 15:20:50 -0700
- CC: binutils at sourceware dot cygnus dot com
- References: <38ED0BF2.CF8FA3BE@redhat.co.uk>
Date: Thu, 06 Apr 2000 23:13:06 +0100
From: Jonathan Larmour <jlarmour@redhat.co.uk>
I've encountered a trivial linker script issue where I can't think of a
generalized solution but know there must surely be one:
Imagine you have two sections to be relocated (LMA != VMA) in the linker
script for an ELF target:
.foo 0x1000 : AT 0xf000 { *(.foo) }
.bar 0x2000 : AT (LOADADDR(.foo) + SIZEOF(.foo)) { *(.bar) }
So .bar follows .foo in e.g. a ROM image, but they get relocated to
different places.
But what happens if there are no .foo input sections? Then the section
doesn't get defined and both LOADADDR(.foo) and SIZEOF(.foo) are invalid.
There is a workaround (which is what eCos has been using so far), which is
to force the sections to be output anyway using e.g.
.foo 0x1000 : AT 0xf000 { . = . ; *(.foo) }
but this isn't really the right way to do it, but what is?
The right way to do it is to patch the linker so that if an output
section is mentioned in a LOADADDR or SIZEOF construct, it gets
created even if it has no input sections. This basically means
calling init_os for the right sorts of constructs.
It could be as simple as putting
if (s->load_base != NULL)
exp_init_os (s->addr_tree);
at the end of init_os().
Ian