Re: [PATCH] elf: Avoid relocating non-allocated code sections

Alan Modra <[email protected]> Thu, 30 Jul 2026 21:17:29 +0930
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
On Thu, Jul 30, 2026 at 01:21:34PM +0200, Jan Beulich wrote:
> On 30.07.2026 12:48, H.J. Lu wrote:
> > When non-alloced sections use GOT or PLT,  their
> > usages aren't counted.   Then elf_link_input_bfd
> > calls relocate_section on these sections.   When
> > x86 backend tries to use GOT or PLT to resolve
> > relocations in non-alloced sections, everything goes
> > downhill from there.
> 
> So that may be where a correction is needed then.

Exactly.  Also, don't rely on check_relocs to validate relocs.  Checks
must be repeated in relocate_section precisely because non-alloc
sections are not and should not be handled by check_relocs.  It is
fine to error on relocs that don't make sense in non-alloc sections.

-- 
Alan Modra