Re: [PATCH] AArch64: Optimize ADD relocations that resolve to zero
Jan Beulich <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <[email protected]> |
On 13.08.2026 19:12, Alice Carlotti wrote: > On Fri, Jul 24, 2026 at 09:58:59AM +0000, Sivan Shani wrote: >> The "ELF for the Arm 64-bit Architecture" specification, section 5.7.9, >> recommends that linkers optimize ADD instructions whose immediate >> becomes zero after relocation. In particular: >> >> ADD x0, x1, 0 >> ADD x2, x2, 0 >> >> may be replaced with: >> >> MOV x0, x1 >> NOP >> >> Apply this optimization to all supported relocations that set an ADD >> immediate field. > > > I think this optimization is invalid if we're still emitting relocations, > because it breaks idempotency, so we probably need to add a check for that. > > I'm not particularly familiar with this generic part of the linker, so I'd > appreciate any clarification from other maintainers on how to check this. Do you perhaps refer to the bfd_link_relocatable() predicate? Jan