HomePhabricator

[PowerPC] Fix issue where binary uses a .got but is missing a .TOC.

Authored by stefanp on Apr 5 2021, 6:07 AM.

Description

[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

Details

Committed
stefanpApr 5 2021, 7:13 AM
Reviewer
MaskRay
Differential Revision
D91426: [PowerPC] Fix issue where binary uses a .got but is missing a .TOC.
Parents
rG2aebb7cb3c88: [OpenMP] Fix incorrect KMP_STRLEN() macro
Branches
Unknown
Tags
Unknown