[all-commits] [llvm/llvm-project] e11b70: [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:04:10 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e11b709b1922ca46b443fcfa5d76b87edca48721
      https://github.com/llvm/llvm-project/commit/e11b709b1922ca46b443fcfa5d76b87edca48721
  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




More information about the All-commits mailing list