mirror of
https://github.com/rui314/mold.git
synced 2024-12-25 01:14:32 +03:00
temporary
This commit is contained in:
parent
fde6b02df6
commit
8f5ec2b5ca
@ -30,12 +30,14 @@ void ObjectFile::initialize_soname() {
|
||||
CHECK(obj.template getSectionContentsAsArray<ELF64LE::Dyn>(shdr), this);
|
||||
|
||||
for (const ELF64LE::Dyn &dyn : tags) {
|
||||
if (dyn.d_tag == DT_NEEDED) {
|
||||
if (dyn.d_tag == DT_SONAME) {
|
||||
this->soname = StringRef(symbol_strtab.data() + dyn.d_un.d_val);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->soname = this->name;
|
||||
}
|
||||
|
||||
void ObjectFile::initialize_sections() {
|
||||
@ -340,7 +342,7 @@ void ObjectFile::maybe_override_symbol(const ELF64LE::Sym &esym, Symbol &sym, in
|
||||
sym.input_section = isec;
|
||||
sym.piece_ref = sym_pieces[idx];
|
||||
sym.value = esym.st_value;
|
||||
sym.type = esym.getType();
|
||||
sym.type = (is_dso && esym.getType() == STT_GNU_IFUNC) ? STT_FUNC : esym.getType();
|
||||
sym.binding = esym.getBinding();
|
||||
sym.visibility = esym.getVisibility();
|
||||
sym.esym = &esym;
|
||||
|
@ -267,6 +267,7 @@ static std::vector<u64> create_dynamic_section() {
|
||||
if (!file->soname.empty()) {
|
||||
define(DT_NEEDED, i);
|
||||
i += file->soname.size() + 1;
|
||||
llvm::outs() << "file=" << file->name << " soname=" << file->soname << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,9 @@
|
||||
// RUN: /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
|
||||
|
||||
// RUN: readelf --dynamic %t.exe | FileCheck %s
|
||||
// CHECK: Dynamic section at offset 0x2080 contains 19 entries:
|
||||
// CHECK: Dynamic section at offset 0x2080 contains 20 entries:
|
||||
// CHECK: Tag Type Name/Value
|
||||
// CHECK: 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
|
||||
// CHECK: 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
|
||||
// CHECK: 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2]
|
||||
// CHECK: 0x0000000000000007 (RELA) 0x2003a0
|
||||
@ -25,8 +26,8 @@
|
||||
// CHECK: 0x0000000000000006 (SYMTAB) 0x200418
|
||||
// CHECK: 0x000000000000000b (SYMENT) 24 (bytes)
|
||||
// CHECK: 0x0000000000000005 (STRTAB) 0x2004d8
|
||||
// CHECK: 0x000000000000000a (STRSZ) 116 (bytes)
|
||||
// CHECK: 0x0000000000000004 (HASH) 0x20054c
|
||||
// CHECK: 0x000000000000000a (STRSZ) 129 (bytes)
|
||||
// CHECK: 0x0000000000000004 (HASH) 0x20055c
|
||||
// CHECK: 0x0000000000000019 (INIT_ARRAY) 0x202028
|
||||
// CHECK: 0x000000000000001b (INIT_ARRAYSZ) 8 (bytes)
|
||||
// CHECK: 0x000000000000001a (FINI_ARRAY) 0x202020
|
||||
|
25
test/ifunc-dso.s
Normal file
25
test/ifunc-dso.s
Normal file
@ -0,0 +1,25 @@
|
||||
// RUN: cc -shared -fPIC -o %t.so %p/input/ifunc-dso.s
|
||||
// RUN: cc -o %t.o -c %s
|
||||
// RUN: mold -o %t.exe /usr/lib/x86_64-linux-gnu/crt1.o \
|
||||
// RUN: /usr/lib/x86_64-linux-gnu/crti.o \
|
||||
// RUN: /usr/lib/gcc/x86_64-linux-gnu/9/crtbegin.o \
|
||||
// RUN: %t.o \
|
||||
// RUN: %t.so \
|
||||
// RUN: /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a \
|
||||
// RUN: /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 \
|
||||
// RUN: /lib/x86_64-linux-gnu/libc.so.6 \
|
||||
// RUN: /usr/lib/x86_64-linux-gnu/libc_nonshared.a \
|
||||
// RUN: /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 \
|
||||
// RUN: /usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \
|
||||
// RUN: /usr/lib/x86_64-linux-gnu/crtn.o
|
||||
// RUN: %t.exe | grep 'Hello world'
|
||||
|
||||
.text
|
||||
.globl main
|
||||
main:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
call foobar@PLT
|
||||
xor %rax, %rax
|
||||
popq %rbp
|
||||
ret
|
23
test/input/ifunc-dso.s
Normal file
23
test/input/ifunc-dso.s
Normal file
@ -0,0 +1,23 @@
|
||||
.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"
|
@ -12,6 +12,7 @@ import lit.util
|
||||
|
||||
config.name = 'mold'
|
||||
config.suffixes = ['.s', '.test']
|
||||
config.excludes = ['input']
|
||||
config.test_format = lit.formats.ShTest(False)
|
||||
config.test_source_root = os.path.dirname(__file__)
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
// SECTIONS: [19] .got.plt PROGBITS 0000000000202058 00002058
|
||||
// SECTIONS: 0000000000000028 0000000000000000 WA 0 0 8
|
||||
// SECTIONS: [20] .dynamic DYNAMIC 0000000000202080 00002080
|
||||
// SECTIONS: 0000000000000130 0000000000000010 WA 9 0 8
|
||||
// SECTIONS: 0000000000000140 0000000000000010 WA 9 0 8
|
||||
|
||||
// RUN: readelf -x .got.plt %t.exe | FileCheck --check-prefix=GOTPLT %s
|
||||
// GOTPLT: 0x00202058 80202000 00000000 00000000 00000000
|
||||
|
Loading…
Reference in New Issue
Block a user