brintos

brintos / llvm-project-archived public Read only

0
0
Text · 955 B · d5b56d9 Raw
38 lines · c
1// This test checks that the ifuncs works after bolt.2// Compiling with 00 results in IFUNC indirect calling.3 4// RUN: %clang %cflags -O0 -no-pie %s -fuse-ld=lld \5// RUN:    -o %t.exe -Wl,-q6// RUN: llvm-bolt %t.exe -o %t.bolt.exe --use-old-text=0 --lite=07// RUN: %t.bolt.exe  | FileCheck %s8 9// RUN: %clang %cflags -O3 -no-pie %s -fuse-ld=lld \10// RUN:    -o %t.O3.exe -Wl,-q11// RUN: llvm-bolt %t.O3.exe -o %t.O3.bolt.exe --use-old-text=0 --lite=012// RUN: %t.O3.bolt.exe  | FileCheck %s13 14// CHECK: foo15 16#include <stdio.h>17#include <string.h>18 19static void foo() { printf("foo\n"); }20 21static void *resolver_foo(void) { return foo; }22 23__attribute__((ifunc("resolver_foo"))) void ifoo();24 25static void *resolver_memcpy(void) { return memcpy; }26 27__attribute__((ifunc("resolver_memcpy"))) void *28imemcpy(void *dest, const void *src, size_t n);29 30int main() {31  int a = 0xdeadbeef, b = 0;32  imemcpy(&b, &a, sizeof(b));33  if (a != b)34    return -1;35 36  ifoo();37}38