mirror of
https://github.com/rui314/mold.git
synced 2024-12-26 01:44:29 +03:00
Do not directly call imported functions
This is needed by Gentoo's sci-libs/lapack-3.9.0-r1 package.
This commit is contained in:
parent
d9ecc2e3e6
commit
5046fae0cf
12
mold.h
12
mold.h
@ -1770,8 +1770,12 @@ public:
|
||||
: ctx.dynbss->shdr.sh_addr + value;
|
||||
}
|
||||
|
||||
if (has_plt(ctx) && esym().st_type == STT_GNU_IFUNC)
|
||||
return get_plt_addr(ctx);
|
||||
if (has_plt(ctx)) {
|
||||
if (esym().st_type == STT_GNU_IFUNC)
|
||||
return get_plt_addr(ctx);
|
||||
if (is_imported)
|
||||
return get_plt_addr(ctx);
|
||||
}
|
||||
|
||||
if (input_section) {
|
||||
if (input_section->is_ehframe) {
|
||||
@ -1793,12 +1797,8 @@ public:
|
||||
// relocations.
|
||||
return 0;
|
||||
}
|
||||
|
||||
return input_section->get_addr() + value;
|
||||
}
|
||||
|
||||
if (has_plt(ctx))
|
||||
return get_plt_addr(ctx);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
40
test/plt-dso.sh
Executable file
40
test/plt-dso.sh
Executable file
@ -0,0 +1,40 @@
|
||||
#!/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 -fPIC -c -o $t/a.o -xc -
|
||||
#include <stdio.h>
|
||||
|
||||
void world() {
|
||||
printf("world\n");
|
||||
}
|
||||
|
||||
void hello() {
|
||||
printf("Hello ");
|
||||
world();
|
||||
}
|
||||
EOF
|
||||
|
||||
clang -fuse-ld=`pwd`/../mold -shared -o $t/b.so $t/a.o
|
||||
|
||||
cat <<EOF | cc -c -o $t/c.o -xc -
|
||||
#include <stdio.h>
|
||||
|
||||
void world() {
|
||||
printf("WORLD\n");
|
||||
}
|
||||
|
||||
void hello();
|
||||
|
||||
int main() {
|
||||
hello();
|
||||
}
|
||||
EOF
|
||||
|
||||
clang -fuse-ld=`pwd`/../mold -o $t/exe -Wl,-rpath=$t $t/c.o $t/b.so
|
||||
$t/exe | grep -q 'Hello WORLD'
|
||||
|
||||
echo OK
|
Loading…
Reference in New Issue
Block a user