mirror of
https://github.com/rui314/mold.git
synced 2024-10-04 00:31:41 +03:00
32 lines
472 B
Bash
Executable File
32 lines
472 B
Bash
Executable File
#!/bin/bash
|
|
. $(dirname $0)/common.inc
|
|
|
|
supports_ifunc || skip
|
|
|
|
cat <<EOF | $CC -fPIC -o $t/a.o -c -xc - -fno-plt
|
|
#include <stdio.h>
|
|
|
|
__attribute__((ifunc("resolve_foo")))
|
|
void foo(void);
|
|
|
|
void hello(void) {
|
|
printf("Hello world\n");
|
|
}
|
|
|
|
typedef void Fn();
|
|
|
|
Fn *resolve_foo(void) {
|
|
return hello;
|
|
}
|
|
|
|
int main() {
|
|
foo();
|
|
}
|
|
EOF
|
|
|
|
$CC -B. -o $t/exe1 $t/a.o -pie
|
|
$QEMU $t/exe1 | grep -q 'Hello world'
|
|
|
|
$CC -B. -o $t/exe2 $t/a.o -no-pie
|
|
$QEMU $t/exe2 | grep -q 'Hello world'
|