[all-commits] [llvm/llvm-project] 684c21: [ELF][PPC32] Support --emit-relocs link of R_PPC_P...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Tue Jan 28 11:05:49 PST 2020
Branch: refs/heads/release/10.x
Home: https://github.com/llvm/llvm-project
Commit: 684c216d73cdcd64fc0186b533870cb79dc03810
https://github.com/llvm/llvm-project/commit/684c216d73cdcd64fc0186b533870cb79dc03810
Author: Fangrui Song <i at maskray.me>
Date: 2020-01-28 (Tue, 28 Jan 2020)
Changed paths:
M lld/ELF/InputSection.cpp
A lld/test/ELF/ppc32-relocatable-got2.s
Log Message:
-----------
[ELF][PPC32] Support --emit-relocs link of R_PPC_PLTREL24
Similar to R_MIPS_GPREL16 and R_MIPS_GPREL32 (D45972).
If the addend of an R_PPC_PLTREL24 is >= 0x8000, it indicates that r30
is relative to the input section .got2.
```
addis 30, 30, .got2+0x8000-.L1$pb at ha
addi 30, 30, .got2+0x8000-.L1$pb at l
...
bl foo+0x8000 at PLT
```
After linking, the relocation will be relative to the output section .got2.
To compensate for the shift `address(input section .got2) - address(output section .got2) = ppc32Got2OutSecOff`, adjust by `ppc32Got2OutSecOff`:
```
addis 30, 30, .got2+0x8000-.L1+ppc32Got2OutSecOff$pb at ha
addi 30, 30, .got2+0x8000-.L1+ppc32Got2OutSecOff$pb at ha$pb at l
...
bl foo+0x8000+ppc32Got2OutSecOff at PLT
```
This rule applys to a relocatable link or a non-relocatable link with --emit-relocs.
Reviewed By: Bdragon28
Differential Revision: https://reviews.llvm.org/D73532
(cherry picked from commit e11b709b1922ca46b443fcfa5d76b87edca48721)
More information about the All-commits
mailing list