[PATCH v2] ld: warn about PE base relocations to sections above .reloc

Alan Modra amodra@gmail.com
Mon Mar 29 03:49:59 GMT 2021


On Mon, Mar 22, 2021 at 05:49:10PM +0100, Jan Beulich via Binutils wrote:
> Due to a bogus linker script, or perhaps because a section doesn't get
> placed by a linker script while default placement puts it too high up,
> sections can end up above .reloc. Since the process of determining its
> contents (and hence its size) happens before final section placement,
> relocations needed for such sections would no longer point at the
> correct address in the final binary. Warn about this (down the road this
> may want to become an error, unless size determination and content
> creation for .reloc would get decoupled).
> 
> Two of the testcases would actually trigger the warning, because .reloc
> gets placed at 0 without mentioning it in their linker scripts. Extend
> the two scripts accordingly.

Both of those scripts discard .reloc.  Yes, they get a vma of 0 but
that's not really being "placed".  I think you should probably handle
.reloc being discarded rather than, or perhaps in addition to, this
patch.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list