mirror of
https://github.com/rui314/mold.git
synced 2024-11-15 14:36:25 +03:00
Fix DT_INIT and DT_FINI
This commit is contained in:
parent
e0eeb404dc
commit
7f4da62ee9
@ -349,10 +349,10 @@ static std::vector<u64> create_dynamic_section() {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
if (OutputChunk *chunk = find(".init"))
|
||||
define(DT_INIT, chunk->shdr.sh_addr);
|
||||
if (OutputChunk *chunk = find(".fini"))
|
||||
define(DT_FINI, chunk->shdr.sh_addr);
|
||||
if (Symbol *sym = Symbol::intern("_init"); sym->file)
|
||||
define(DT_INIT, sym->get_addr());
|
||||
if (Symbol *sym = Symbol::intern("_fini"); sym->file)
|
||||
define(DT_FINI, sym->get_addr());
|
||||
|
||||
i64 flags = 0;
|
||||
i64 flags1 = 0;
|
||||
|
21
test/dt_init.sh
Executable file
21
test/dt_init.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo -n "Testing $(basename -s .sh $0) ... "
|
||||
t=$(pwd)/tmp/$(basename -s .sh $0)
|
||||
mkdir -p $t
|
||||
|
||||
cat <<EOF | clang -c -o $t/a.o -x assembler -
|
||||
.globl main
|
||||
main:
|
||||
ret
|
||||
EOF
|
||||
|
||||
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o
|
||||
readelf -a $t/exe > $t/log
|
||||
|
||||
grep -Pq '\(INIT\)\s+0x201020' $t/log
|
||||
grep -Pq '\(FINI\)\s+0x201010' $t/log
|
||||
grep -Pq '0000000000201020\s+0 FUNC GLOBAL HIDDEN \d+ _init$' $t/log
|
||||
grep -Pq '0000000000201010\s+0 FUNC GLOBAL HIDDEN \d+ _fini$' $t/log
|
||||
|
||||
echo OK
|
Loading…
Reference in New Issue
Block a user