1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00
mold/test/ifunc-export.sh
Rui Ueyama dd04357363 Do not set STT_GNU_IFUNC to symbols .dynsym
We should not set STT_GNU_IFUNC to symbols in .dynsym because
from the other ELF module's point of view, it doens't matter
whether a symbol is IFUNC or not.

This is needed by Gentoo's sci-mathematics/nauty-2.6.7 package.
2021-06-21 10:32:30 +09:00

38 lines
701 B
Bash
Executable File

#!/bin/bash
set -e
cd $(dirname $0)
echo -n "Testing $(basename -s .sh $0) ... "
t=$(pwd)/tmp/$(basename -s .sh $0)
mkdir -p $t
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
.globl resolve_foobar
resolve_foobar:
pushq %rbp
movq %rsp, %rbp
movq real_foobar@GOTPCREL(%rip), %rax
popq %rbp
ret
.globl foobar
.type foobar, @gnu_indirect_function
.set foobar, resolve_foobar
.data
.Lmsg:
.string "Hello world\n"
EOF
clang -fuse-ld=`pwd`/../mold -shared -o $t/b.so $t/a.o
readelf --dyn-syms $t/b.so | grep -Pq '0 FUNC GLOBAL DEFAULT \d+ foobar'
echo OK