mirror of
https://github.com/rui314/mold.git
synced 2024-12-29 11:24:36 +03:00
temporary
This commit is contained in:
parent
841cccd0bf
commit
1fb7418e65
1
main.cc
1
main.cc
@ -1099,6 +1099,7 @@ int main(int argc, char **argv) {
|
||||
out::chunks.push_back(out::strtab);
|
||||
out::chunks.push_back(out::hash);
|
||||
out::chunks.push_back(out::eh_frame);
|
||||
out::chunks.push_back(out::eh_frame_hdr);
|
||||
out::chunks.push_back(out::copyrel);
|
||||
out::chunks.push_back(out::versym);
|
||||
out::chunks.push_back(out::verneed);
|
||||
|
3
mold.h
3
mold.h
@ -707,7 +707,6 @@ public:
|
||||
void copy_buf() override;
|
||||
u64 get_addr(const Symbol &sym);
|
||||
|
||||
private:
|
||||
std::vector<CieRecord *> cies;
|
||||
u32 num_fdes;
|
||||
};
|
||||
@ -722,7 +721,7 @@ public:
|
||||
shdr.sh_size = HEADER_SIZE;
|
||||
}
|
||||
|
||||
void write(std::span<CieRecord *> cies);
|
||||
void write();
|
||||
|
||||
enum { HEADER_SIZE = 12 };
|
||||
};
|
||||
|
@ -757,6 +757,10 @@ void EhFrameSection::construct() {
|
||||
}
|
||||
}
|
||||
shdr.sh_size = offset;
|
||||
|
||||
if (out::eh_frame_hdr)
|
||||
out::eh_frame_hdr->shdr.sh_size =
|
||||
out::eh_frame_hdr->HEADER_SIZE + num_fdes * 8;
|
||||
}
|
||||
|
||||
void EhFrameSection::copy_buf() {
|
||||
@ -809,7 +813,7 @@ void EhFrameSection::copy_buf() {
|
||||
|
||||
// Write to .eh_frame_hdr.
|
||||
if (out::eh_frame_hdr)
|
||||
out::eh_frame_hdr->write(cies);
|
||||
out::eh_frame_hdr->write();
|
||||
}
|
||||
|
||||
u64 EhFrameSection::get_addr(const Symbol &sym) {
|
||||
@ -851,7 +855,7 @@ u64 EhFrameSection::get_addr(const Symbol &sym) {
|
||||
Fatal() << file << ": .eh_frame has bad symbol: " << sym.name;
|
||||
}
|
||||
|
||||
void EhFrameHdrSection::write(std::span<CieRecord *> cies) {
|
||||
void EhFrameHdrSection::write() {
|
||||
u8 *base = out::buf + shdr.sh_offset;
|
||||
|
||||
base[0] = 1;
|
||||
@ -860,7 +864,33 @@ void EhFrameHdrSection::write(std::span<CieRecord *> cies) {
|
||||
base[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4;
|
||||
|
||||
*(u32 *)(base + 4) = out::eh_frame->shdr.sh_addr - shdr.sh_addr - 4;
|
||||
*(u32 *)(base + 8) = out::eh_frame->num_fdes;
|
||||
|
||||
tbb::parallel_for_each(out::eh_frame->cies, [](CieRecord *cie) {
|
||||
u32 input_offset = cie->output_offset;
|
||||
if (cie->output_offset == cie->leader_offset)
|
||||
input_offset += cie->contents.size();
|
||||
|
||||
for (FdeRecord &fde : cie->fdes) {
|
||||
if (!fde.is_alive())
|
||||
continue;
|
||||
if (fde.rels.empty())
|
||||
Fatal() << "FDE has no relocation";
|
||||
|
||||
u32 fde_addr = out::eh_frame->shdr.sh_addr + input_offset;
|
||||
|
||||
u32 init_addr = *(u32 *)(fde.contents.data() + 8);
|
||||
if (fde.rels[0].r_type == R_X86_64_PC32)
|
||||
init_addr += fde_addr + fde.rels[0].offset;
|
||||
|
||||
#if 0
|
||||
*(u32 *)(base + output_offset) = init_addr;
|
||||
*(u32 *)(base + output_offset + 4) = fde_addr;
|
||||
output_offset += 8;
|
||||
input_offset += fde.contents.size();
|
||||
#endif
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void CopyrelSection::add_symbol(Symbol *sym) {
|
||||
|
Loading…
Reference in New Issue
Block a user