[all-commits] [llvm/llvm-project] fb2944: [ELF][PPC32] Implement IPLT code sequence for non-...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Sun Dec 29 22:45:44 PST 2019
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: fb2944bd7f8ac6d7c4bccd3ac2033ba58c690038
https://github.com/llvm/llvm-project/commit/fb2944bd7f8ac6d7c4bccd3ac2033ba58c690038
Author: Fangrui Song <maskray at google.com>
Date: 2019-12-29 (Sun, 29 Dec 2019)
Changed paths:
M lld/ELF/Arch/PPC.cpp
M lld/ELF/Thunks.cpp
M lld/ELF/Thunks.h
R lld/test/ELF/ppc32-gnu-ifunc-nonpreemptable.s
A lld/test/ELF/ppc32-ifunc-nonpreemptible-nopic.s
A lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s
Log Message:
-----------
[ELF][PPC32] Implement IPLT code sequence for non-preemptible IFUNC
Similar to D71509 (EM_PPC64), on EM_PPC, the IPLT code sequence should
be similar to a PLT call stub. Unlike EM_PPC64, EM_PPC -msecure-plt has
small/large PIC model differences.
* -fpic/-fpie: R_PPC_PLTREL24 r_addend=0. The call stub loads an address relative to `_GLOBAL_OFFSET_TABLE_`.
* -fPIC/-fPIE: R_PPC_PLTREL24 r_addend=0x8000. (A partial linked object
file may have an addend larger than 0x8000.) The call stub loads an address relative to .got2+0x8000.
Just assume large PIC model for now. This patch makes:
// clang -fuse-ld=lld -msecure-plt -fno-pie -no-pie a.c
// clang -fuse-ld=lld -msecure-plt -fPIE -pie a.c
#include <stdio.h>
static void impl(void) { puts("meow"); }
void thefunc(void) __attribute__((ifunc("resolver")));
void *resolver(void) { return &impl; }
int main(void) {
thefunc();
void (*theptr)(void) = &thefunc;
theptr();
}
work on Linux glibc. -fpie will crash because the compiler and the
linker do not agree on the value which r30 stores (_GLOBAL_OFFSET_TABLE_
vs .got2+0x8000).
Differential Revision: https://reviews.llvm.org/D71621
More information about the All-commits
mailing list