Page MenuHomePhabricator

[ELF] Rename .plt to .iplt and decrease EM_PPC{,64} alignment of .glink to 4
ClosedPublic

Authored by MaskRay on Dec 14 2019, 6:09 PM.

Details

Summary

GNU ld creates the synthetic section .iplt, and has a built-in linker
script that assigns .iplt to the output section .plt . There is no
output section named .iplt .

Making .iplt an output section actually has a benefit that makes the
tricky toolchain feature stand out. Symbolizers don't have to deal with
mixed PLT entries (e.g. llvm-objdump -d incorrectly annotates such jump
targets).

On EM_PPC{,64}, .glink contains a PLT resolver and a series of jump
instructions. The 4-byte entry size makes it unnecessary to have an
alignment of 16.

Mark ppc32-gnu-ifunc.s as XFAIL: *. It tests IPLT on EM_PPC, which
never works.

Diff Detail

Event Timeline

MaskRay created this revision.Dec 14 2019, 6:09 PM
MaskRay updated this revision to Diff 233975.Dec 15 2019, 9:49 AM
MaskRay retitled this revision from [ELF] Rename .plt to .iplt and decrease EM_PPC64 alignment of .glink to 4 to [ELF] Rename .plt to .iplt and decrease EM_PPC{,64} alignment of .glink to 4.
MaskRay edited the summary of this revision. (Show Details)

Update tests

MaskRay updated this revision to Diff 233978.Dec 15 2019, 10:08 AM
MaskRay edited the summary of this revision. (Show Details)
MaskRay added reviewers: Restricted Project, grimar, peter.smith, ruiu, sfertile.
MaskRay removed a subscriber: wuzish.

Add reviewers

ruiu added inline comments.Dec 15 2019, 9:42 PM
lld/ELF/SyntheticSections.cpp
2453

Could you add a comment explaining why PPC is special?

MaskRay marked an inline comment as done.Dec 15 2019, 10:56 PM
MaskRay added inline comments.
lld/ELF/SyntheticSections.cpp
2453

I think the user will likely also read PPC64.cpp:writePlt to understand why its alignment is different. The comment may be redundant. (.glink is a series of bl instructions. Over-aligning to 16 does not improve anything.)

It is not that PPC is special. I think x86/ARM/AArch64 just happen to find 32 is the optimal alignment. Though, I believe on AArch64, at least with -z pac-plt or -z bti, 16 as the alignment is no longer optimal or necessary.

peter.smith accepted this revision.Dec 16 2019, 1:39 AM

Looks good to me too.

lld/ELF/SyntheticSections.cpp
2453

I think the alignment of 16 comes from the cache line size, this obviously doesn't help when the PLT entry size is > 16. I've not got any data to know if it is worth increasing alignment for larger sequences.

This revision is now accepted and ready to land.Dec 16 2019, 1:39 AM
MaskRay updated this revision to Diff 234075.Dec 16 2019, 8:30 AM

Address comments

MaskRay updated this revision to Diff 234103.Dec 16 2019, 10:37 AM
MaskRay edited the summary of this revision. (Show Details)

Rebase (update tests) after D71519

This revision was automatically updated to reflect the committed changes.