1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-11 05:46:58 +03:00

[Mach-O] Programmatically construct __stubs, __stub_helper and __la_symbol_ptr

This commit is contained in:
Rui Ueyama 2021-09-21 17:19:44 +09:00
parent 17c67418f6
commit c66bd302bd

View File

@ -708,12 +708,15 @@ LazySymbolPtrSection::LazySymbolPtrSection() {
strcpy(hdr.sectname, "__la_symbol_ptr");
hdr.p2align = __builtin_ctz(8);
hdr.type = S_LAZY_SYMBOL_POINTERS;
hdr.size = contents.size();
hdr.reserved1 = 2;
}
void LazySymbolPtrSection::copy_buf(Context &ctx) {
write_vector(ctx.buf + hdr.offset, contents);
u64 *buf = (u64 *)(ctx.buf + hdr.offset);
for (i64 i = 0; i < ctx.stubs.entries.size(); i++)
buf[i] = ctx.stub_helper.hdr.addr + StubHelperSection::HEADER_SIZE +
i * StubHelperSection::ENTRY_SIZE;
}
DataSection::DataSection() {