mirror of
https://github.com/rui314/mold.git
synced 2024-09-21 09:57:18 +03:00
[Mach-O] wip
This commit is contained in:
parent
18cfe1f4ca
commit
15215b1f71
@ -124,10 +124,12 @@ void Subsection::scan_relocations(Context &ctx) {
|
||||
|
||||
switch (rel.type) {
|
||||
case X86_64_RELOC_GOT_LOAD:
|
||||
case X86_64_RELOC_GOT:
|
||||
if (sym->file->is_dylib)
|
||||
sym->flags |= NEEDS_GOT;
|
||||
break;
|
||||
case X86_64_RELOC_GOT:
|
||||
sym->flags |= NEEDS_GOT;
|
||||
break;
|
||||
case X86_64_RELOC_TLV:
|
||||
if (sym->file->is_dylib)
|
||||
sym->flags |= NEEDS_THREAD_PTR;
|
||||
|
@ -569,6 +569,7 @@ public:
|
||||
}
|
||||
|
||||
void add(Context &ctx, Symbol *sym);
|
||||
void copy_buf(Context &ctx) override;
|
||||
|
||||
std::vector<Symbol *> syms;
|
||||
|
||||
@ -595,6 +596,7 @@ public:
|
||||
}
|
||||
|
||||
void add(Context &ctx, Symbol *sym);
|
||||
void copy_buf(Context &ctx) override;
|
||||
|
||||
std::vector<Symbol *> syms;
|
||||
|
||||
|
@ -491,6 +491,16 @@ void OutputRebaseSection::compute_size(Context &ctx) {
|
||||
ctx.lazy_symbol_ptr.hdr.addr + i * LazySymbolPtrSection::ENTRY_SIZE -
|
||||
ctx.data_seg->cmd.vmaddr);
|
||||
|
||||
for (Symbol *sym : ctx.got.syms)
|
||||
if (!sym->file->is_dylib)
|
||||
enc.add(ctx.data_const_seg->seg_idx,
|
||||
sym->get_got_addr(ctx) - ctx.data_const_seg->cmd.vmaddr);
|
||||
|
||||
for (Symbol *sym : ctx.thread_ptrs.syms)
|
||||
if (!sym->file->is_dylib)
|
||||
enc.add(ctx.data_seg->seg_idx,
|
||||
sym->get_tlv_addr(ctx) - ctx.data_seg->cmd.vmaddr);
|
||||
|
||||
for (std::unique_ptr<OutputSegment> &seg : ctx.segments)
|
||||
for (Chunk *chunk : seg->chunks)
|
||||
if (chunk->is_regular)
|
||||
@ -1162,6 +1172,13 @@ void GotSection::add(Context &ctx, Symbol *sym) {
|
||||
hdr.size = syms.size() * ENTRY_SIZE;
|
||||
}
|
||||
|
||||
void GotSection::copy_buf(Context &ctx) {
|
||||
u64 *buf = (u64 *)(ctx.buf + hdr.offset);
|
||||
for (i64 i = 0; i < syms.size(); i++)
|
||||
if (!syms[i]->file->is_dylib)
|
||||
buf[i] = syms[i]->get_addr(ctx);
|
||||
}
|
||||
|
||||
void LazySymbolPtrSection::copy_buf(Context &ctx) {
|
||||
u64 *buf = (u64 *)(ctx.buf + hdr.offset);
|
||||
|
||||
@ -1177,4 +1194,11 @@ void ThreadPtrsSection::add(Context &ctx, Symbol *sym) {
|
||||
hdr.size = syms.size() * ENTRY_SIZE;
|
||||
}
|
||||
|
||||
void ThreadPtrsSection::copy_buf(Context &ctx) {
|
||||
u64 *buf = (u64 *)(ctx.buf + hdr.offset);
|
||||
for (i64 i = 0; i < syms.size(); i++)
|
||||
if (!syms[i]->file->is_dylib)
|
||||
buf[i] = syms[i]->get_addr(ctx);
|
||||
}
|
||||
|
||||
} // namespace mold::macho
|
||||
|
Loading…
Reference in New Issue
Block a user