[all-commits] [llvm/llvm-project] 660c4e: [PowerPC] Fix issue where binary uses a .got but i...

stefanp-ibm via All-commits all-commits at lists.llvm.org
Mon Apr 5 07:14:07 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 660c4e57b4a7ac71f9595f31bfdec114369f4ca0
      https://github.com/llvm/llvm-project/commit/660c4e57b4a7ac71f9595f31bfdec114369f4ca0
  Author: Stefan Pintilie <stefanp at ca.ibm.com>
  Date:   2021-04-05 (Mon, 05 Apr 2021)

  Changed paths:
    M lld/ELF/SyntheticSections.cpp
    A lld/test/ELF/ppc64-check-missing-tocbase.s
    M lld/test/ELF/ppc64-ld-got-dtprel.s
    M lld/test/ELF/ppc64-reloc-got-pcrel34.s
    M lld/test/ELF/ppc64-tls-gd.s
    M lld/test/ELF/ppc64-tls-ie.s
    M lld/test/ELF/ppc64-tls-missing-gdld.s
    M lld/test/ELF/ppc64-tls-pcrel-gd.s
    M lld/test/ELF/ppc64-tls-pcrel-ie.s

  Log Message:
  -----------
  [PowerPC] Fix issue where binary uses a .got but is missing a .TOC.

>From the PowerPC ELFv2 ABI section 4.2.3. Global Offset Table.
```
The GOT consists of an 8-byte header that contains the TOC base (the first TOC
base when multiple TOCs are present), followed by an array of 8-byte addresses.
```

Due to the introduction of PC Relative code it is now possible to require a GOT
without having a .TOC. symbol in the object that is being linked. Since LLD uses
the .TOC. symbol to determine whether or not a GOT is required the GOT header is
not setup correctly and the 8-byte header is missing.

This patch allows the Power PC GOT setup to happen when an element is added to
the GOT instead of at the very begining. When this header is added a .TOC.
symbol is also added.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D91426




More information about the All-commits mailing list