[ELF][PPC64] Actually implement --no-power10-stubs
authorFangrui Song <i@maskray.me>
Tue, 28 Feb 2023 00:19:13 +0000 (16:19 -0800)
committerFangrui Song <i@maskray.me>
Tue, 28 Feb 2023 00:19:13 +0000 (16:19 -0800)
commit7198c87f42f6c15d76b127c1c63530e9b4d5dd39
tree023c183cf970df2ad707c3166de7b3cae72aea8e
parentd77f96a9e0c86a35f5d5986058b4dcce30113cca
[ELF][PPC64] Actually implement --no-power10-stubs

When a caller that does not use TOC calls a function, a call stub is needed if
the function may use TOC. --no-power10-stubs avoids PC-relative instructions in
the code sequence.

The --no-power10-stubs=no implementation added in D94627 is wrong.
First, the first instruction incorrectly uses `mflr 0` (instead of `mflr 12`).
Second, for the PLT case, it uses addis+addi with getVA instead of addis+ld with
getGotPltVA.
lld/ELF/Thunks.cpp
lld/ELF/Thunks.h
lld/test/ELF/ppc64-pcrel-call-to-extern.s
lld/test/ELF/ppc64-pcrel-call-to-toc.s