Specifying LMA's after unallocated sections?
Jonathan Larmour
jlarmour@redhat.co.uk
Thu Apr 6 15:31:00 GMT 2000
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
More information about the Binutils
mailing list