1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-29 11:24:36 +03:00
This commit is contained in:
Rui Ueyama 2021-02-25 20:46:43 +09:00
parent f9ecf89b16
commit 1d90a5ad5c
2 changed files with 19 additions and 3 deletions

View File

@ -309,7 +309,9 @@ static std::vector<u64> create_dynamic_section() {
for (SharedFile *file : out::dsos) for (SharedFile *file : out::dsos)
define(DT_NEEDED, out::dynstr->find_string(file->soname)); define(DT_NEEDED, out::dynstr->find_string(file->soname));
define(DT_RUNPATH, out::dynstr->find_string(config.rpaths)); if (!config.rpaths.empty())
define(DT_RUNPATH, out::dynstr->find_string(config.rpaths));
define(DT_RELA, out::reldyn->shdr.sh_addr); define(DT_RELA, out::reldyn->shdr.sh_addr);
define(DT_RELASZ, out::reldyn->shdr.sh_size); define(DT_RELASZ, out::reldyn->shdr.sh_size);
define(DT_RELAENT, sizeof(ElfRela)); define(DT_RELAENT, sizeof(ElfRela));

View File

@ -7,14 +7,28 @@ mkdir -p $t
cat <<EOF | clang -fPIC -c -o $t/a.o -x assembler - cat <<EOF | clang -fPIC -c -o $t/a.o -x assembler -
.globl fn1, fn2 .globl fn1, fn2
fn1: fn1:
call fn2 jmp fn2
EOF EOF
clang -shared -fuse-ld=`pwd`/../mold -o $t/b.so $t/a.o clang -shared -fuse-ld=`pwd`/../mold -o $t/b.so $t/a.o
readelf --dyn-syms $t/b.so > $t/log readelf --dyn-syms $t/b.so > $t/log
grep -q '0000000000000000 0 NOTYPE GLOBAL DEFAULT UND fn2' $t/log grep -q '0000000000000000 0 NOTYPE GLOBAL DEFAULT UND fn2' $t/log
grep -q '000000000000111c 0 NOTYPE GLOBAL DEFAULT 16 fn1' $t/log grep -q '000000000000111c 0 NOTYPE GLOBAL DEFAULT 16 fn1' $t/log
cat <<EOF | clang -fPIC -c -o $t/c.o -xc -
int fn1();
int fn2() {
return 3;
}
int main() {
return fn1();
}
EOF
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/c.o $t/b.so
echo OK echo OK