macho: link hello world in zig compiled with llvm
This commit is contained in:
@@ -1542,6 +1542,9 @@ fn scanRelocs(self: *MachO) !void {
|
||||
for (self.objects.items) |index| {
|
||||
try self.getFile(index).?.createSymbolIndirection(self);
|
||||
}
|
||||
for (self.dylibs.items) |index| {
|
||||
try self.getFile(index).?.createSymbolIndirection(self);
|
||||
}
|
||||
if (self.getInternalObject()) |obj| {
|
||||
try obj.asFile().createSymbolIndirection(self);
|
||||
}
|
||||
@@ -2358,9 +2361,9 @@ fn allocateLinkeditSegment(self: *MachO) !void {
|
||||
|
||||
fn resizeSections(self: *MachO) !void {
|
||||
const slice = self.sections.slice();
|
||||
for (slice.items(.header), slice.items(.atoms), slice.items(.out)) |header, atoms, *out| {
|
||||
if (atoms.items.len == 0) continue;
|
||||
for (slice.items(.header), slice.items(.out), 0..) |header, *out, n_sect| {
|
||||
if (header.isZerofill()) continue;
|
||||
if (self.isZigSection(@intCast(n_sect))) continue; // TODO this is horrible
|
||||
const cpu_arch = self.getTarget().cpu.arch;
|
||||
try out.resize(self.base.comp.gpa, header.size);
|
||||
const padding_byte: u8 = if (header.isCode() and cpu_arch == .x86_64) 0xcc else 0;
|
||||
|
||||
@@ -91,9 +91,9 @@ pub const ZigGotSection = struct {
|
||||
_ = unused_fmt_string;
|
||||
const zig_got = ctx.zig_got;
|
||||
const macho_file = ctx.macho_file;
|
||||
const zo = macho_file.getZigObject().?;
|
||||
try writer.writeAll("__zig_got\n");
|
||||
for (zig_got.entries.items, 0..) |entry, index| {
|
||||
const zo = macho_file.getZigObject().?;
|
||||
const symbol = zo.symbols.items[entry];
|
||||
try writer.print(" {d}@0x{x} => {d}@0x{x} ({s})\n", .{
|
||||
index,
|
||||
|
||||
Reference in New Issue
Block a user