Re: [PATCH] AArch64: Optimize ADD relocations that resolve to zero
Sivan Shani <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <[email protected]> |
>> Have you looked at what other ports do?
Thank you for the suggestion. I should indeed have paid more attention,
I have missed several relevant ld details:
1) ld provides '--no-relax'. Currently, the new optimization does not
honor it:
```
$LD --emit-relocs --no-relax -o test.elf test.o
$OBJDUMP -dr test.elf
400120: aa0103e0 mov x0, x1
400120: R_AARCH64_TLSLE_ADD_TPREL_HI12 tlsvar
400124: d503201f nop
400124: R_AARCH64_ADD_ABS_LO12_NC .data
```
'--no-relax' should preserve the original ADD instructions.
2) existing ports do not appear to require every relocation retained by
`--emit-relocs` to remain reapplicable after optimization. There are
cases where the original relocation is retained even though the
instruction has been transformed. This interpretation of `--emit-relocs`
is also discussed by MaskRay here:
https://lists.gnu.org/archive/html/bug-binutils/2023-09/msg00039.html
Other optimizations do rewrite their relocation records, so the behavior
is not completely uniform across ports.
My current conclusion: the ADD-zero optimization do not need to be
disabled with '--emit-relocs', as long as it honor '--no-relax'. This
preserves the existing informational use of '--emit-relocs' while
providing a way to request reapplicable instruction/relocation pairs.