This patch supports the situation where caller does not have a valid TOC and
calls using the R_PPC64_REL24_NOTOC relocation and the callee is not DSO local.
In this case the call cannot be made directly since the callee may or may not
require a valid TOC pointer. As a result this situation requires an R12 setup
plt stub.
Details
- Reviewers
nemanjai sfertile MaskRay ruiu hfinkel • espindola stefanp - Group Reviewers
Restricted Project - Commits
- rG8dbea4785c10: [PowerPC] Support for R_PPC64_REL24_NOTOC calls where the caller has no TOC and…
Diff Detail
Event Timeline
lld/ELF/Thunks.cpp | ||
---|---|---|
1008 | I'll need to check what instruction we are using in the R12SetupStub, I see the comment says pld right now, but where is it loading from? | |
lld/test/ELF/ppc64-pcrel-call-to-extern.s | ||
47 | Whats the offset that gets encoded into the instruction? What offset are you expecting? |
- Added a new plt gep setup stub.
- Updated the test case and checks if the offset func@plt@pcrel properly computed.
- Re-based the patch with ToT master and merged in latest changes in https://reviews.llvm.org/D83504
lld/ELF/Thunks.cpp | ||
---|---|---|
1008 | Thanks Sean.
| |
lld/test/ELF/ppc64-pcrel-call-to-extern.s | ||
47 |
|
lld/ELF/Arch/PPC64.cpp | ||
---|---|---|
1039–1040 | No need for a extra case to handle the NOTOC plt calls, the following case handles it perfectly. | |
lld/ELF/Thunks.cpp | ||
308 | If you look at the existing plt stub it also sets up R12, this is expected of any plt stub variety on PPC64. The important details about this stub type is that it is a plt stub that uses pc-relative instructions, that it sets up R12 is just an implementation detail. // PPC64 PLT R12 Setup Stub --> // PPC64 PC-relative PLT Stub | |
315 | Change the name to PPC64PCRelPLTStub. | |
894 | Both plt stub types perform the setup for the gep so the name doesn't really disambiguate which stub type we have. I suggest trying to use pc-rel in the name instead of gep. |
Thanks Sean.
- Removed the redundant check in needsThunk
- Renamed the new stub as suggested, updated comments and the test case accordingly.
I only had one nit.
LGTM.
lld/ELF/Thunks.cpp | ||
---|---|---|
894 | nit: |
Thank you all for the review!
- Addressed the nits and update the test case.
- Combined ppc64-callee-global.s with ppc64-pcrel-call-to-extern.s using extract.
lld/ELF/Thunks.cpp | ||
---|---|---|
1012 | Yeah, the ternary conditional operator would complain since make<PPC64PCRelPLTStub>(s) and make<PPC64PltCallStub>(s) has different value type. |
As the patch https://reviews.llvm.org/D83834 is reverted, updated the test case accordingly to combine ppc64-callee-global.s and ppc64-pcrel-call-to-extern.s with .ifdef AUX
lld/ELF/Thunks.cpp | ||
---|---|---|
1011 | nit: clang-format | |
1012 | Thanks. | |
lld/test/ELF/ppc64-pcrel-call-to-extern.s | ||
31 | minor nit: add whitepace so it lines up with the following lines | |
36 | Can you add spaces to the lines that are missing '-NEXT' to keep the columns aligned. | |
51 | I believe plt[1] is the dynamic object identifier. Maybe its best to say the first 2 entries in the plt are reserved for the dynamic linkers usage and skip mentioning what they are used for. |
Thanks Sean for the review. Addressed the nits for clang-format and alignment issues.
nit: remove this comment