[PATCH v2 00/10] mips hi16/lo16 reloc handling
Maciej W. Rozycki
macro@orcam.me.uk
Wed Nov 5 02:46:28 GMT 2025
More information about the Binutils mailing list
Wed Nov 5 02:46:28 GMT 2025
- Previous message (by thread): [PATCH] RISC-V: Fix missing instruction classes in error messages
- Next message (by thread): [PATCH v2 01/10] BFD: Unify relocation error reporting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
See the original patch series[1] for the previous iteration.
This is an updated ELF side fix[2] for a MIPS issue with handling REL
HI16/LO16 relocation pairs in BFD, where certain input causes invalid
output to be produced or the linker to crash.
In the course of reviewing the change I have realised there are a number
of issues in this area which have to be addressed first for the fix to
make sense. In particular any outstanding orphan HI16 relocations ought
to be processed at finishing with the containing section rather than at
the file closing time. And that the incoming in-place addend oughtn't to
ever be ignored.
Then I realised that we should issue a warning in GAS already for orphan
HI16 relocations since we'll warn in the linker anyway. The sooner the
better, and the diagnostic can be more accurate at assembly time, pointing
at the offending source location and not missing the cases where unrelated
relocations end up next to each other, which the linker cannot figure out.
I have updated the original fix accordingly then.
There are more issues outstanding in this area (which just indicates how
silly it was to choose the REL format for a split-calculation target), but
I'll leave it up to another time; I consider this patch set good enough to
go already and it'd be counterproductive not to release it just to address
further issues. Given that there are generic or cross-target preparatory
changes included I'm asking for the approval of these patches.
Also, Alan, would you be able to share a test case that prompted the fix?
I appreciate it's been a while and I might be able to cook something up
based on your change description alone, but having a reference case would
surely help, also to verify I haven't lost anything among the numerous
updates. Ideally I'd convert any such case to a proper testsuite case,
which I'll try to come up with anyway before pushing your final member of
the patch set.
The generic changes included have passed regression testing across 249
targets (MIPS-specific ones that do not touch code outside were verified
with MIPS targets only).
NB the COFF side of the fix[3] is not addressed at this time. Neither
the COFF backend is enabled for GAS nor is the COFF emulation for LD
anymore so that would be mainly a proof of concept only, although if you
bend backwards, assemble for ELF, objcopy the result to COFF and then
supply that to the linker then COFF relocation code will still trigger.
I may choose to rewrite it sometime so as to wire into the updated
infrastructure or I will be happy to review any updated version submitted.
I suspect it suffers from the same addend processing issue, because COFF
code is structured similarly to ELF howto processing code, so analogous
updates would be required.
OK to apply?
References:
[1] Alan Modra, "mips hi16/lo16 reloc handling",
<https://inbox.sourceware.org/binutils/20231219093546.2112095-1-amodra@gmail.com/>
[2] Alan Modra, "Move mips_hi16_list to mips_elf_section_data",
<https://inbox.sourceware.org/binutils/20231219093546.2112095-2-amodra@gmail.com/>
[3] Alan Modra, "coff-mips refhi list",
<https://inbox.sourceware.org/binutils/20231219093546.2112095-3-amodra@gmail.com/>
Maciej
- Previous message (by thread): [PATCH] RISC-V: Fix missing instruction classes in error messages
- Next message (by thread): [PATCH v2 01/10] BFD: Unify relocation error reporting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list