mirror of
https://github.com/rui314/mold.git
synced 2024-09-21 09:57:18 +03:00
wip
This commit is contained in:
parent
b31b6da35a
commit
a3df45cb86
@ -439,6 +439,9 @@ void InputSection::scan_relocations() {
|
||||
file->num_dynrel++;
|
||||
};
|
||||
|
||||
if (sym.st_type == STT_GNU_IFUNC)
|
||||
sym.flags |= NEEDS_PLT;
|
||||
|
||||
switch (rel.r_type) {
|
||||
case R_X86_64_NONE:
|
||||
rel_types[i] = R_NONE;
|
||||
@ -511,7 +514,7 @@ void InputSection::scan_relocations() {
|
||||
rel_types[i] = R_GOTPCREL;
|
||||
break;
|
||||
case R_X86_64_PLT32:
|
||||
if (sym.is_imported() || sym.st_type == STT_GNU_IFUNC)
|
||||
if (sym.is_imported())
|
||||
sym.flags |= NEEDS_PLT;
|
||||
rel_types[i] = R_PC;
|
||||
break;
|
||||
|
1
mold.h
1
mold.h
@ -55,6 +55,7 @@ enum class BuildIdKind : u8 { NONE, HASH, UUID };
|
||||
|
||||
struct Config {
|
||||
BuildIdKind build_id = BuildIdKind::NONE;
|
||||
bool Bsymbolic = false;
|
||||
bool allow_multiple_definition = false;
|
||||
bool demangle = true;
|
||||
bool discard_all = false;
|
||||
|
@ -5,53 +5,26 @@ 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 real_foobar
|
||||
real_foobar:
|
||||
lea msg(%rip), %rdi
|
||||
xor %rax, %rax
|
||||
call printf
|
||||
xor %rax, %rax
|
||||
ret
|
||||
cat <<EOF | clang -o $t/a.o -c -xc -
|
||||
#include <stdio.h>
|
||||
|
||||
.globl resolve_foobar
|
||||
resolve_foobar:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
leaq real_foobar(%rip), %rax
|
||||
popq %rbp
|
||||
ret
|
||||
void foo() __attribute__((ifunc("resolve_foo")));
|
||||
|
||||
.globl foobar
|
||||
.type foobar, @gnu_indirect_function
|
||||
.set foobar, resolve_foobar
|
||||
void hello() {
|
||||
printf("Hello world\n");
|
||||
}
|
||||
|
||||
.globl main
|
||||
main:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
call foobar@PLT
|
||||
xor %rax, %rax
|
||||
popq %rbp
|
||||
ret
|
||||
void *resolve_foo() {
|
||||
return hello;
|
||||
}
|
||||
|
||||
.data
|
||||
msg:
|
||||
.string "Hello world\n"
|
||||
int main() {
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
../mold -static -o $t/exe /usr/lib/x86_64-linux-gnu/crt1.o \
|
||||
/usr/lib/x86_64-linux-gnu/crti.o \
|
||||
/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginT.o \
|
||||
$t/a.o \
|
||||
/usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a \
|
||||
/usr/lib/gcc/x86_64-linux-gnu/9/libgcc_eh.a \
|
||||
/usr/lib/x86_64-linux-gnu/libc.a \
|
||||
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \
|
||||
/usr/lib/x86_64-linux-gnu/crtn.o
|
||||
|
||||
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o -static
|
||||
$t/exe | grep -q 'Hello world'
|
||||
|
||||
echo OK
|
||||
|
Loading…
Reference in New Issue
Block a user