[PATCH] D71509: [ELF][PowerPC] Set PltSection alignment to 4 and fix IPLT index
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 22:03:46 PST 2019
MaskRay added a comment.
#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();
}
GNU ld powerpc tries very hard to keep the type of `thefunc` as `STT_IFUNC` and uses `R_PPC64_IRELATIVE`
% ~/llvm/Release/bin/clang -fPIC -fuse-ld=bfd -g b.c -o b.bfd
% readelf -r b.bfd
Relocation section '.rela.dyn' at offset 0x380 contains 3 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
000000001001ff08 0000000200000026 R_PPC64_ADDR64 0000000000000000 __gmon_start__ + 0
000000001001ff28 00000000000000f8 R_PPC64_IRELATIVE 10000660
0000000010020028 00000000000000f8 R_PPC64_IRELATIVE 10000660
...
% readelf -Ws b | grep thefunc
50: 0000000010000480 0 NOTYPE LOCAL DEFAULT 12 00000019.plt_call.thefunc
66: 0000000010000660 32 IFUNC GLOBAL DEFAULT [<localentry>: 8] 12 thefunc
% ./b.bfd
meow
meow
% ~/llvm/Release/bin/clang -fPIC -fuse-ld=lld -g b.c -o b.lld
% readelf -r b.lld
Relocation section '.rela.dyn' at offset 0x468 contains 1 entry:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000010030be0 00000000000000f8 R_PPC64_IRELATIVE 10010700
...
% readelf -Ws b.lld | grep thefunc
22: 00000000100108e8 20 FUNC LOCAL DEFAULT 14 __plt_thefunc
39: 00000000100109b8 0 FUNC GLOBAL DEFAULT [<localentry>: 8] 17 thefunc
% ./b
meow
Inconsistency detected by ld.so: dl-runtime.c: 80: _dl_fixup: Assertion `ELFW(R_TYPE)(reloc->r_info) == ELF_MACHINE_JMP_SLOT' failed!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71509/new/
https://reviews.llvm.org/D71509
More information about the llvm-commits
mailing list