This is an archive of the discontinued LLVM Phabricator instance.

[PPC64] Add offset to local entry point when calling functions without plt
ClosedPublic

Authored by syzaara on Apr 17 2018, 11:39 AM.

Details

Summary

PPC64 V2 ABI describes two entry points to a function. The global entry point sets up the TOC base pointer. When calling a local function, the call should branch to the local entry point rather than the global entry point. Section 3.4.1 describes using the 3 most significant bits of the st_other field to find out how many instructions there are between the local and global entry point. This patch adds the correct offset required to branch to the local entry point of a function.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

syzaara created this revision.Apr 17 2018, 11:39 AM
ruiu added inline comments.Apr 17 2018, 3:29 PM
lld/ELF/Arch/PPC64.cpp
25–26 ↗(On Diff #142804)

Can you please expand the comment to include the explanation that you wrote in the commit message? I found that's very useful.

35 ↗(On Diff #142804)

nit: no else after return

lld/ELF/InputSection.cpp
591–592 ↗(On Diff #142804)

Perhaps, it is better to inline the function here? I think that getLocalEntryOffset is called only once here and short enough to be inlined.

syzaara updated this revision to Diff 143131.Apr 19 2018, 11:12 AM

@ruiu Hi Rui, is this okay to approve now?

ruiu accepted this revision.Apr 26 2018, 11:02 AM

Apologies, I missed this patch. LGTM.

This revision is now accepted and ready to land.Apr 26 2018, 11:02 AM
This revision was automatically updated to reflect the committed changes.
grimar added a subscriber: grimar.Apr 28 2018, 1:55 AM
grimar added inline comments.
ELF/InputSection.cpp
598

This produces a warning for me now:
InputSection.cpp(598): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)

syzaara added inline comments.Apr 30 2018, 7:47 AM
ELF/InputSection.cpp
598
grimar added inline comments.Apr 30 2018, 7:52 AM
ELF/InputSection.cpp
598

It`s fixed for me, thanks!