[llvm] [BOLT] Fix order of R_*_IRELATIVE in .rela.plt (PR #106515)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 02:29:29 PDT 2024
linsinan1995 wrote:
The testcase is generated from bolt/test/runtime/iplt.c with gnu-ld
```
#include "../Inputs/stub.h"
static void foo() { int i = rand(); printf("%d", i); }
static void *resolver_foo(void) { return foo; }
__attribute__((ifunc("resolver_foo"))) void ifoo();
static void *resolver_memcpy(void) { return memcpy; }
__attribute__((ifunc("resolver_memcpy"))) void *
imemcpy(void *dest, const void *src, unsigned long n);
int main() {
int a = 0xdeadbeef, b = 0;
imemcpy(&b, &a, sizeof(b));
if (a != b)
return -1;
ifoo();
}
```
with commands
clang -nostdlib -fpic bolt/test/runtime/iplt.c -o iplt.o -Wl,-q -nostdlib -nodefaultlibs -c
clang -nostdlib -fpic bolt/test/Inputs/stub.c -o stub.o -Wl,-q -nostdlib -nodefaultlibs -c
clang -nostdlib -fpic -shared stub.o -Wl,-q -nostdlib -nodefaultlibs -o libstub.so
clang -nostdlib -fpic iplt.o -Wl,-q -nostdlib -nodefaultlibs -L. -lstub -o test
llvm-strip --strip-unneeded test -o test
https://github.com/llvm/llvm-project/pull/106515
More information about the llvm-commits
mailing list