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: Ian Lance Taylor <ian at zembu dot com>
- Subject: Re: Specifying LMA's after unallocated sections?
- From: Jonathan Larmour <jlarmour at redhat dot co dot uk>
- Date: Thu, 06 Apr 2000 23:31:43 +0100
- CC: binutils at sourceware dot cygnus dot com
- Organization: Red Hat UK Ltd.
- References: <38ED0BF2.CF8FA3BE@redhat.co.uk> <20000406222050.11608.qmail@daffy.airs.com>
Ian Lance Taylor wrote:
> .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.
>
> 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().
I was thinking of some way to avoid outputting the section regardless.
Suppose for example you want to put .bar after .rel.* relocation
information. I know (because I accidentally stumbled across it) that
outputting an empty .rel section makes BFD very unhappy. And to be honest,
I think BFD is right: you shouldn't be emitting "unused" empty output
sections in general.
Jifl
--
Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS Tel: +44 (1223) 728762
"Plan to be spontaneous tomorrow." || These opinions are all my own fault