mirror of
https://github.com/rui314/mold.git
synced 2024-12-25 17:34:02 +03:00
temporary
This commit is contained in:
parent
5bb0439bff
commit
df3498769b
2
main.cc
2
main.cc
@ -417,8 +417,6 @@ static void write_got(u8 *buf, ArrayRef<ObjectFile *> files) {
|
||||
u8 *dynsym_buf = buf + out::dynsym->shdr.sh_offset;
|
||||
u8 *dynstr_buf = buf + out::dynstr->shdr.sh_offset;
|
||||
|
||||
memset(buf + out::gotplt->shdr.sh_offset, 0, out::gotplt->shdr.sh_size);
|
||||
|
||||
tbb::parallel_for_each(files, [&](ObjectFile *file) {
|
||||
u32 dynstr_offset = file->dynstr_offset;
|
||||
|
||||
|
6
mold.h
6
mold.h
@ -340,16 +340,14 @@ public:
|
||||
class GotPltSection : public OutputChunk {
|
||||
public:
|
||||
GotPltSection() : OutputChunk(SYNTHETIC) {
|
||||
this->name = ".gotplt";
|
||||
this->name = ".got.plt";
|
||||
shdr.sh_type = llvm::ELF::SHT_PROGBITS;
|
||||
shdr.sh_flags = llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE;
|
||||
shdr.sh_addralign = GOT_SIZE;
|
||||
shdr.sh_size = GOT_SIZE * 3;
|
||||
}
|
||||
|
||||
void initialize(u8 *buf) override {
|
||||
memset(buf + shdr.sh_offset, 0, GOT_SIZE * 3);
|
||||
}
|
||||
void initialize(u8 *buf) override;
|
||||
};
|
||||
|
||||
class PltSection : public OutputChunk {
|
||||
|
@ -71,6 +71,13 @@ bool OutputSection::empty() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void GotPltSection::initialize(u8 *buf) {
|
||||
u8 *base = buf + shdr.sh_offset;
|
||||
memset(base, 0, shdr.sh_size);
|
||||
if (out::dynamic)
|
||||
*(u64 *)base = out::dynamic->shdr.sh_addr;
|
||||
}
|
||||
|
||||
void PltSection::initialize(u8 *buf) {
|
||||
const u8 data[] = {
|
||||
0xff, 0x35, 0, 0, 0, 0, // pushq GOTPLT+8(%rip)
|
||||
|
17
test/plt.s
17
test/plt.s
@ -11,13 +11,18 @@
|
||||
// RUN: /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
|
||||
|
||||
// RUN: readelf --sections %t.exe | FileCheck --check-prefix=SECTIONS %s
|
||||
// SECTIONS: [19] .gotplt PROGBITS 0000000000202058 00002058
|
||||
// SECTIONS: 0000000000000028 0000000000000000 WA 0 0 8
|
||||
// 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
|
||||
|
||||
// RUN: objdump -d -j .plt %t.exe | FileCheck %s
|
||||
// CHECK: 2011a8: ff 35 b2 0e 00 00 pushq 0xeb2(%rip) # 202060
|
||||
// CHECK: 2011ae: ff 25 b4 0e 00 00 jmpq *0xeb4(%rip) # 202068
|
||||
// CHECK: 2011b4: 0f 1f 40 00 nopl 0x0(%rax)
|
||||
// RUN: readelf -x .got.plt %t.exe | FileCheck --check-prefix=GOTPLT %s
|
||||
// GOTPLT: 0x00202058 80202000 00000000 00000000 00000000
|
||||
|
||||
// RUN: objdump -d -j .plt %t.exe | FileCheck --check-prefix=PLT %s
|
||||
// PLT: 2011a8: ff 35 b2 0e 00 00 pushq 0xeb2(%rip) # 202060
|
||||
// PLT: 2011ae: ff 25 b4 0e 00 00 jmpq *0xeb4(%rip) # 202068
|
||||
// PLT: 2011b4: 0f 1f 40 00 nopl 0x0(%rax)
|
||||
|
||||
.globl main
|
||||
main:
|
||||
|
Loading…
Reference in New Issue
Block a user