Re: [PATCH v2] elf: Set this_idx to -1 for invalid relocations

Alan Modra <[email protected]> Mon, 3 Aug 2026 09:13:42 +0930
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
On Sun, Aug 02, 2026 at 08:55:00AM +0800, H.J. Lu wrote:
> On Sun, Aug 2, 2026 at 6:18 AM H.J. Lu <[email protected]> wrote:
> >
> > When invalid relocation is reported by elf_link_read_relocs_from_section
> > called from lang_gc_sections:
> >
> > ld: pr34448-bug_18.o: bad reloc symbol index (0xf2000005 >= 0x13) for
> > offset 0x4 in section `.text.get_tls[get_tls]'
> >
> > the same error is reported again:
> >
> > ld: pr34448-bug_18.o: bad reloc symbol index (0xf2000005 >= 0x13) for
> > offset 0x4 in section `.text.get_tls[get_tls]'

Using this_idx as a flag is a bad idea.

I also think that no one should be too concerned about error messages
from fuzzed object files, so if you are going to fix this minor
problem do so in a way that won't potentially break the linker.

-- 
Alan Modra