mirror of
https://github.com/rui314/mold.git
synced 2024-10-04 00:31:41 +03:00
25 lines
610 B
Bash
Executable File
25 lines
610 B
Bash
Executable File
#!/bin/bash
|
|
. $(dirname $0)/common.inc
|
|
|
|
cat <<EOF | $CC -o $t/a.o -c -xc -
|
|
#include <stdio.h>
|
|
|
|
int main() {
|
|
printf("Hello world\n");
|
|
return 0;
|
|
}
|
|
EOF
|
|
|
|
$CC -B. -no-pie -o $t/exe1 $t/a.o -Wl,--image-base=0x8000000
|
|
$QEMU $t/exe1 | grep -q 'Hello world'
|
|
readelf -W --sections $t/exe1 | grep -Eq '.interp\s+PROGBITS\s+0*8000...\b'
|
|
|
|
cat <<EOF | $CC -o $t/b.o -c -xc -
|
|
void _start() {}
|
|
EOF
|
|
|
|
if [ $MACHINE = x86-64 -o $MACHINE = aarch64 ]; then
|
|
$CC -B. -no-pie -o $t/exe2 $t/b.o -nostdlib -Wl,--image-base=0xffffffff80000000
|
|
readelf -W --sections $t/exe2 | grep -Eq '.interp\s+PROGBITS\s+ffffffff80000...\b'
|
|
fi
|