[PATCH v2] elf: Don't match corrupt section header in linker input

Alan Modra amodra@gmail.com
Tue Sep 23 02:36:02 GMT 2025


On Tue, Sep 23, 2025 at 08:14:12AM +0800, H.J. Lu wrote:
> On Tue, Sep 23, 2025 at 7:21 AM Jan Beulich <jbeulich@suse.com> wrote:
> >
> > On 22.09.2025 01:34, H.J. Lu wrote:
> > > Here is the v2 patch to reject link input with corrupt section header.
> >
> > What's the (user visible) effect of this failing to match? I.e. what
> > potentially entirely off diagnostic are they going to see? Or is there
> > perhaps a risk of seeing the same diagnostic multiple times, because
> > of further matching attempts? And is the warning issued here guaranteed
> > to be followed by another, stronger diagnostic?
> >
> > Jan
> 
> The corrupt linker input will be rejected by linker:
> 
> ./ld --version-exports-section symbol --shared -o pr33457.so pr33457.o
> ./ld: warning: pr33457.o has a section extending past end of file
> pr33457.o: file not recognized: file format not recognized
> 
> instead of linker crash.

I think that's a good enough error.  Patch is OK.  I know from
experience with fuzzer induced misbehaviour in the various binutils
that without this sort of heavy-handed fix that you're forever fixing
lots of places that assume sane input.

-- 
Alan Modra


More information about the Binutils mailing list