[PATCH] LoongArch: Detect relocations out of section range

mengqinggang mengqinggang@loongson.cn
Mon Nov 23 03:35:27 GMT 2026


Hi Harshit,

Thanks — please use the existing patch and ignore mine.
By the way, how about adding the relocation name to the error message?


在 2026/11/20 18:37, Harshit Kumar 写道:
> On Fri, Nov 20, 2026 at 07:36:28AM +1030, Alan Modra wrote:
>> This is better done in relocate_section, unless loongarch reads
>> section contents in check_relocs.  check_relocs is not called for some
>> sections (see _bfd_elf_link_iterate_on_relocs), so for instance, debug
>> sections won't have their relocations sanity checked.
> The RFC I posted on Monday does this check for every ELF target where
> the linker reads relocations (elf_link_read_relocs_from_section), so it
> covers the sections check_relocs skips, and runs before relaxation:
> https://inbox.sourceware.org/binutils/20261116184333.3297411-1-harshit7kr@gmail.com/
>
> LoongArch is 15/17; the howto sizes cover the other relocations:
> https://inbox.sourceware.org/binutils/20261116184333.3297411-16-harshit7kr@gmail.com/
>
> With the series, a loongarch64 ld rejects the reloc-offset.s test from
> this patch, and the same kind of relocation in .debug_info:
>
>    dbg.o: bad reloc offset (0x1 + 0x8 > 0x1) for section `.debug_info'
>
> mengqinggang, if the generic check is acceptable, this patch may not be
> needed.  Comments on 15/17 would be very welcome.
>
> Thanks,
> Harshit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20261123/7437bd8b/attachment.htm>


More information about the Binutils mailing list