mirror of
https://github.com/rui314/mold.git
synced 2024-11-15 14:36:25 +03:00
Fix tests for AARCH63
This commit is contained in:
parent
e4547c31d3
commit
2a3639a7d8
@ -6,11 +6,11 @@ echo -n "Testing $(basename -s .sh $0) ... "
|
||||
t=$(pwd)/tmp/$(basename -s .sh $0)
|
||||
mkdir -p $t
|
||||
|
||||
cat <<EOF | cc -o $t/a.o -c -x assembler -
|
||||
.text
|
||||
.globl _start
|
||||
_start:
|
||||
call fn1@PLT
|
||||
cat <<EOF | cc -o $t/a.o -c -xc -
|
||||
void fn1();
|
||||
int main() {
|
||||
fn1();
|
||||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF | cc -o $t/b.so -shared -fPIC -Wl,-soname,libfoo.so -xc -
|
||||
@ -21,13 +21,13 @@ cat <<EOF | cc -o $t/c.so -shared -fPIC -Wl,-soname,libbar.so -xc -
|
||||
int fn2() { return 42; }
|
||||
EOF
|
||||
|
||||
$mold -o $t/exe $t/a.o $t/b.so $t/c.so
|
||||
clang -fuse-ld=$mold -o $t/exe $t/a.o $t/b.so $t/c.so
|
||||
|
||||
readelf --dynamic $t/exe > $t/readelf
|
||||
fgrep -q 'Shared library: [libfoo.so]' $t/readelf
|
||||
fgrep -q 'Shared library: [libbar.so]' $t/readelf
|
||||
|
||||
$mold -o $t/exe $t/a.o --as-needed $t/b.so $t/c.so
|
||||
clang -fuse-ld=$mold -o $t/exe $t/a.o -Wl,--as-needed $t/b.so $t/c.so
|
||||
|
||||
readelf --dynamic $t/exe > $t/readelf
|
||||
fgrep -q 'Shared library: [libfoo.so]' $t/readelf
|
||||
|
@ -10,33 +10,24 @@ mkdir -p $t
|
||||
echo 'int main() {}' | cc -o $t/exe -xc -
|
||||
ldd $t/exe | grep -q ld-musl && { echo OK; exit; }
|
||||
|
||||
cat <<EOF | cc -c -fPIC -o $t/a.o -x assembler -
|
||||
.text
|
||||
real_foobar:
|
||||
lea .Lmsg(%rip), %rdi
|
||||
xor %rax, %rax
|
||||
call printf
|
||||
xor %rax, %rax
|
||||
ret
|
||||
cat <<EOF | cc -c -fPIC -o $t/a.o -xc -
|
||||
#include <stdio.h>
|
||||
|
||||
.globl resolve_foobar
|
||||
resolve_foobar:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
movq real_foobar@GOTPCREL(%rip), %rax
|
||||
popq %rbp
|
||||
ret
|
||||
__attribute__((ifunc("resolve_foobar")))
|
||||
void foobar(void);
|
||||
|
||||
.globl foobar
|
||||
.type foobar, @gnu_indirect_function
|
||||
.set foobar, resolve_foobar
|
||||
void real_foobar(void) {
|
||||
printf("Hello world\n");
|
||||
}
|
||||
|
||||
.data
|
||||
.Lmsg:
|
||||
.string "Hello world\n"
|
||||
typedef void Func();
|
||||
|
||||
Func *resolve_foobar(void) {
|
||||
return real_foobar;
|
||||
}
|
||||
EOF
|
||||
|
||||
clang -fuse-ld=$mold -shared -o $t/b.so $t/a.o
|
||||
readelf --dyn-syms $t/b.so | grep -Pq '0 (IFUNC|<OS specific>: 10)\s+GLOBAL DEFAULT \d+ foobar'
|
||||
readelf --dyn-syms $t/b.so | grep -Pq '(IFUNC|<OS specific>: 10)\s+GLOBAL DEFAULT \d+ foobar'
|
||||
|
||||
echo OK
|
||||
|
@ -13,19 +13,19 @@ _start:
|
||||
nop
|
||||
|
||||
.section .note.foo, "a", @note
|
||||
.align 8
|
||||
.p2align 3
|
||||
.quad 42
|
||||
|
||||
.section .note.bar, "a", @note
|
||||
.align 4
|
||||
.p2align 2
|
||||
.quad 42
|
||||
|
||||
.section .note.baz, "a", @note
|
||||
.align 8
|
||||
.p2align 3
|
||||
.quad 42
|
||||
|
||||
.section .note.nonalloc, "", @note
|
||||
.align 1
|
||||
.p2align 0
|
||||
.quad 42
|
||||
EOF
|
||||
|
||||
|
@ -10,6 +10,9 @@ mkdir -p $t
|
||||
echo 'int main() {}' | cc -o $t/exe -xc -
|
||||
ldd $t/exe | grep -q ld-musl && { echo OK; exit; }
|
||||
|
||||
# Skip if target is not x86-64
|
||||
[ $(uname -m) = x86_64 ] || { echo skipped; exit; }
|
||||
|
||||
cat <<'EOF' | clang -c -o $t/a.o -x assembler -
|
||||
.globl fn1
|
||||
fn1:
|
||||
|
Loading…
Reference in New Issue
Block a user