aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-12-14 18:47:58 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-01 17:51:19 -0700
commitc49957dbe82d7f0db555160b50306335bfa03165 (patch)
tree529e84e430b27c3e6f13cb7a2c956b0ee445339c /src/link
parentf54471b54c471bb6f8e51a1383be09d01c24d0c3 (diff)
downloadzig-c49957dbe82d7f0db555160b50306335bfa03165.tar.gz
zig-c49957dbe82d7f0db555160b50306335bfa03165.zip
fix a round of compile errors caused by this branch
Diffstat (limited to 'src/link')
-rw-r--r--src/link/C.zig12
-rw-r--r--src/link/Coff.zig5
-rw-r--r--src/link/Coff/Atom.zig9
-rw-r--r--src/link/Dwarf.zig2
-rw-r--r--src/link/Elf.zig52
-rw-r--r--src/link/Elf/Atom.zig14
-rw-r--r--src/link/MachO.zig42
-rw-r--r--src/link/MachO/Atom.zig12
-rw-r--r--src/link/Plan9.zig1
9 files changed, 80 insertions, 69 deletions
diff --git a/src/link/C.zig b/src/link/C.zig
index ce44cc4c06..3592052cf8 100644
--- a/src/link/C.zig
+++ b/src/link/C.zig
@@ -84,7 +84,8 @@ pub fn getString(this: C, s: String) []const u8 {
}
pub fn addString(this: *C, s: []const u8) Allocator.Error!String {
- const gpa = this.base.allocator;
+ const comp = this.base.comp;
+ const gpa = comp.gpa;
try this.string_bytes.appendSlice(gpa, s);
return .{
.start = @intCast(this.string_bytes.items.len - s.len),
@@ -98,6 +99,15 @@ pub fn open(
emit: Compilation.Emit,
options: link.File.OpenOptions,
) !*C {
+ return createEmpty(arena, comp, emit, options);
+}
+
+pub fn createEmpty(
+ arena: Allocator,
+ comp: *Compilation,
+ emit: Compilation.Emit,
+ options: link.File.OpenOptions,
+) !*C {
const target = comp.root_mod.resolved_target.result;
assert(target.ofmt == .c);
const optimize_mode = comp.root_mod.optimize_mode;
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index eba24f0d17..762591442b 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -8,7 +8,6 @@ llvm_object: ?*LlvmObject = null,
base: link.File,
image_base: u64,
-error_flags: link.File.ErrorFlags = .{},
dll_export_fns: bool,
subsystem: ?std.Target.SubSystem,
tsaware: bool,
@@ -1825,10 +1824,10 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
if (self.entry_addr == null and self.base.comp.config.output_mode == .Exe) {
log.debug("flushing. no_entry_point_found = true\n", .{});
- self.error_flags.no_entry_point_found = true;
+ self.base.error_flags.no_entry_point_found = true;
} else {
log.debug("flushing. no_entry_point_found = false\n", .{});
- self.error_flags.no_entry_point_found = false;
+ self.base.error_flags.no_entry_point_found = false;
try self.writeHeader();
}
diff --git a/src/link/Coff/Atom.zig b/src/link/Coff/Atom.zig
index 9e55575755..4aa97fa6ac 100644
--- a/src/link/Coff/Atom.zig
+++ b/src/link/Coff/Atom.zig
@@ -94,7 +94,8 @@ pub fn freeListEligible(self: Atom, coff_file: *const Coff) bool {
}
pub fn addRelocation(coff_file: *Coff, atom_index: Index, reloc: Relocation) !void {
- const gpa = coff_file.base.allocator;
+ const comp = coff_file.base.comp;
+ const gpa = comp.gpa;
log.debug(" (adding reloc of type {s} to target %{d})", .{ @tagName(reloc.type), reloc.target.sym_index });
const gop = try coff_file.relocs.getOrPut(gpa, atom_index);
if (!gop.found_existing) {
@@ -104,7 +105,8 @@ pub fn addRelocation(coff_file: *Coff, atom_index: Index, reloc: Relocation) !vo
}
pub fn addBaseRelocation(coff_file: *Coff, atom_index: Index, offset: u32) !void {
- const gpa = coff_file.base.allocator;
+ const comp = coff_file.base.comp;
+ const gpa = comp.gpa;
log.debug(" (adding base relocation at offset 0x{x} in %{d})", .{
offset,
coff_file.getAtom(atom_index).getSymbolIndex().?,
@@ -117,7 +119,8 @@ pub fn addBaseRelocation(coff_file: *Coff, atom_index: Index, offset: u32) !void
}
pub fn freeRelocations(coff_file: *Coff, atom_index: Index) void {
- const gpa = coff_file.base.allocator;
+ const comp = coff_file.base.comp;
+ const gpa = comp.gpa;
var removed_relocs = coff_file.relocs.fetchOrderedRemove(atom_index);
if (removed_relocs) |*relocs| relocs.value.deinit(gpa);
var removed_base_relocs = coff_file.base_relocs.fetchOrderedRemove(atom_index);
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
index 525ca90bc3..faaf5100a4 100644
--- a/src/link/Dwarf.zig
+++ b/src/link/Dwarf.zig
@@ -1205,7 +1205,7 @@ pub fn commitDeclState(
const decl = zcu.declPtr(decl_index);
const ip = &zcu.intern_pool;
const namespace = zcu.namespacePtr(decl.src_namespace);
- const target = namespace.file_scope.mod.target;
+ const target = namespace.file_scope.mod.resolved_target.result;
const target_endian = target.cpu.arch.endian();
var dbg_line_buffer = &decl_state.dbg_line;
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 5f96e195ab..3e237fe494 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -196,9 +196,6 @@ resolver: std.AutoArrayHashMapUnmanaged(u32, Symbol.Index) = .{},
has_text_reloc: bool = false,
num_ifunc_dynrelocs: usize = 0,
-error_flags: link.File.ErrorFlags = link.File.ErrorFlags{},
-misc_errors: std.ArrayListUnmanaged(link.File.ErrorMsg) = .{},
-
/// List of atoms that are owned directly by the linker.
atoms: std.ArrayListUnmanaged(Atom) = .{},
@@ -477,7 +474,6 @@ pub fn deinit(self: *Elf) void {
}
self.last_atom_and_free_list_table.deinit(gpa);
- self.misc_errors.deinit(gpa);
self.comdat_groups.deinit(gpa);
self.comdat_groups_owners.deinit(gpa);
self.comdat_groups_table.deinit(gpa);
@@ -1168,7 +1164,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
}
// libc dep
- self.error_flags.missing_libc = false;
+ self.base.error_flags.missing_libc = false;
if (self.base.comp.config.link_libc) {
if (self.base.comp.libc_installation) |lc| {
const flags = target_util.libcFullLinkFlags(target);
@@ -1219,7 +1215,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
});
try system_libs.append(.{ .path = path });
} else {
- self.error_flags.missing_libc = true;
+ self.base.error_flags.missing_libc = true;
}
}
@@ -1257,7 +1253,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
};
}
- if (self.misc_errors.items.len > 0) return error.FlushFailure;
+ if (self.base.misc_errors.items.len > 0) return error.FlushFailure;
// Init all objects
for (self.objects.items) |index| {
@@ -1267,7 +1263,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
try self.file(index).?.shared_object.init(self);
}
- if (self.misc_errors.items.len > 0) return error.FlushFailure;
+ if (self.base.misc_errors.items.len > 0) return error.FlushFailure;
// Dedup shared objects
{
@@ -1389,14 +1385,14 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
if (self.entry_index == null and self.base.isExe()) {
log.debug("flushing. no_entry_point_found = true", .{});
- self.error_flags.no_entry_point_found = true;
+ self.base.error_flags.no_entry_point_found = true;
} else {
log.debug("flushing. no_entry_point_found = false", .{});
- self.error_flags.no_entry_point_found = false;
+ self.base.error_flags.no_entry_point_found = false;
try self.writeElfHeader();
}
- if (self.misc_errors.items.len > 0) return error.FlushFailure;
+ if (self.base.misc_errors.items.len > 0) return error.FlushFailure;
}
pub fn flushStaticLib(self: *Elf, comp: *Compilation, module_obj_path: ?[]const u8) link.File.FlushError!void {
@@ -1428,7 +1424,7 @@ pub fn flushStaticLib(self: *Elf, comp: *Compilation, module_obj_path: ?[]const
};
}
- if (self.misc_errors.items.len > 0) return error.FlushFailure;
+ if (self.base.misc_errors.items.len > 0) return error.FlushFailure;
// First, we flush relocatable object file generated with our backends.
if (self.zigObjectPtr()) |zig_object| {
@@ -1540,7 +1536,7 @@ pub fn flushStaticLib(self: *Elf, comp: *Compilation, module_obj_path: ?[]const
try self.base.file.?.setEndPos(total_size);
try self.base.file.?.pwriteAll(buffer.items, 0);
- if (self.misc_errors.items.len > 0) return error.FlushFailure;
+ if (self.base.misc_errors.items.len > 0) return error.FlushFailure;
}
pub fn flushObject(self: *Elf, comp: *Compilation, module_obj_path: ?[]const u8) link.File.FlushError!void {
@@ -1571,14 +1567,14 @@ pub fn flushObject(self: *Elf, comp: *Compilation, module_obj_path: ?[]const u8)
};
}
- if (self.misc_errors.items.len > 0) return error.FlushFailure;
+ if (self.base.misc_errors.items.len > 0) return error.FlushFailure;
// Init all objects
for (self.objects.items) |index| {
try self.file(index).?.object.init(self);
}
- if (self.misc_errors.items.len > 0) return error.FlushFailure;
+ if (self.base.misc_errors.items.len > 0) return error.FlushFailure;
// Now, we are ready to resolve the symbols across all input files.
// We will first resolve the files in the ZigObject, next in the parsed
@@ -1612,7 +1608,7 @@ pub fn flushObject(self: *Elf, comp: *Compilation, module_obj_path: ?[]const u8)
try self.writeShdrTable();
try self.writeElfHeader();
- if (self.misc_errors.items.len > 0) return error.FlushFailure;
+ if (self.base.misc_errors.items.len > 0) return error.FlushFailure;
}
/// --verbose-link output
@@ -2891,7 +2887,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
}
// libc dep
- self.error_flags.missing_libc = false;
+ self.base.error_flags.missing_libc = false;
if (comp.config.link_libc) {
if (self.base.comp.libc_installation != null) {
const needs_grouping = link_mode == .Static;
@@ -2912,7 +2908,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
.Dynamic => "libc.so",
}));
} else {
- self.error_flags.missing_libc = true;
+ self.base.error_flags.missing_libc = true;
}
}
}
@@ -3135,7 +3131,7 @@ fn writePhdrTable(self: *Elf) !void {
}
fn writeElfHeader(self: *Elf) !void {
- if (self.misc_errors.items.len > 0) return; // We had errors, so skip flushing to render the output unusable
+ if (self.base.misc_errors.items.len > 0) return; // We had errors, so skip flushing to render the output unusable
var hdr_buf: [@sizeOf(elf.Elf64_Ehdr)]u8 = undefined;
@@ -6067,8 +6063,9 @@ const ErrorWithNotes = struct {
comptime format: []const u8,
args: anytype,
) error{OutOfMemory}!void {
- const gpa = elf_file.base.allocator;
- const err_msg = &elf_file.misc_errors.items[err.index];
+ const comp = elf_file.base.comp;
+ const gpa = comp.gpa;
+ const err_msg = &elf_file.base.misc_errors.items[err.index];
err_msg.msg = try std.fmt.allocPrint(gpa, format, args);
}
@@ -6078,8 +6075,9 @@ const ErrorWithNotes = struct {
comptime format: []const u8,
args: anytype,
) error{OutOfMemory}!void {
- const gpa = elf_file.base.allocator;
- const err_msg = &elf_file.misc_errors.items[err.index];
+ const comp = elf_file.base.comp;
+ const gpa = comp.gpa;
+ const err_msg = &elf_file.base.misc_errors.items[err.index];
assert(err.note_slot < err_msg.notes.len);
err_msg.notes[err.note_slot] = .{ .msg = try std.fmt.allocPrint(gpa, format, args) };
err.note_slot += 1;
@@ -6088,14 +6086,14 @@ const ErrorWithNotes = struct {
pub fn addErrorWithNotes(self: *Elf, note_count: usize) error{OutOfMemory}!ErrorWithNotes {
const gpa = self.base.comp.gpa;
- try self.misc_errors.ensureUnusedCapacity(gpa, 1);
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, 1);
return self.addErrorWithNotesAssumeCapacity(note_count);
}
fn addErrorWithNotesAssumeCapacity(self: *Elf, note_count: usize) error{OutOfMemory}!ErrorWithNotes {
const gpa = self.base.comp.gpa;
- const index = self.misc_errors.items.len;
- const err = self.misc_errors.addOneAssumeCapacity();
+ const index = self.base.misc_errors.items.len;
+ const err = self.base.misc_errors.addOneAssumeCapacity();
err.* = .{ .msg = undefined, .notes = try gpa.alloc(link.File.ErrorMsg, note_count) };
return .{ .index = index };
}
@@ -6130,7 +6128,7 @@ fn reportUndefinedSymbols(self: *Elf, undefs: anytype) !void {
const gpa = self.base.comp.gpa;
const max_notes = 4;
- try self.misc_errors.ensureUnusedCapacity(gpa, undefs.count());
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, undefs.count());
var it = undefs.iterator();
while (it.next()) |entry| {
diff --git a/src/link/Elf/Atom.zig b/src/link/Elf/Atom.zig
index dc330fa54b..9f57dab283 100644
--- a/src/link/Elf/Atom.zig
+++ b/src/link/Elf/Atom.zig
@@ -227,7 +227,8 @@ pub fn grow(self: *Atom, elf_file: *Elf) !void {
pub fn free(self: *Atom, elf_file: *Elf) void {
log.debug("freeAtom {d} ({s})", .{ self.atom_index, self.name(elf_file) });
- const gpa = elf_file.base.allocator;
+ const comp = elf_file.base.comp;
+ const gpa = comp.gpa;
const shndx = self.outputShndx().?;
const meta = elf_file.last_atom_and_free_list_table.getPtr(shndx).?;
const free_list = &meta.free_list;
@@ -352,7 +353,8 @@ pub fn markFdesDead(self: Atom, elf_file: *Elf) void {
}
pub fn addReloc(self: Atom, elf_file: *Elf, reloc: elf.Elf64_Rela) !void {
- const gpa = elf_file.base.allocator;
+ const comp = elf_file.base.comp;
+ const gpa = comp.gpa;
const file_ptr = self.file(elf_file).?;
assert(file_ptr == .zig_object);
const zig_object = file_ptr.zig_object;
@@ -747,6 +749,8 @@ fn reportUndefined(
rel: elf.Elf64_Rela,
undefs: anytype,
) !void {
+ const comp = elf_file.base.comp;
+ const gpa = comp.gpa;
const rel_esym = switch (self.file(elf_file).?) {
.zig_object => |x| x.elfSym(rel.r_sym()).*,
.object => |x| x.symtab.items[rel.r_sym()],
@@ -761,7 +765,7 @@ fn reportUndefined(
{
const gop = try undefs.getOrPut(sym_index);
if (!gop.found_existing) {
- gop.value_ptr.* = std.ArrayList(Atom.Index).init(elf_file.base.allocator);
+ gop.value_ptr.* = std.ArrayList(Atom.Index).init(gpa);
}
try gop.value_ptr.append(self.atom_index);
}
@@ -957,6 +961,8 @@ fn resolveDynAbsReloc(
elf_file: *Elf,
writer: anytype,
) !void {
+ const comp = elf_file.base.comp;
+ const gpa = comp.gpa;
const P = self.value + rel.r_offset;
const A = rel.r_addend;
const S = @as(i64, @intCast(target.address(.{}, elf_file)));
@@ -967,7 +973,7 @@ fn resolveDynAbsReloc(
.shared_object => unreachable,
inline else => |x| x.num_dynrelocs,
};
- try elf_file.rela_dyn.ensureUnusedCapacity(elf_file.base.allocator, num_dynrelocs);
+ try elf_file.rela_dyn.ensureUnusedCapacity(gpa, num_dynrelocs);
switch (action) {
.@"error",
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index 25d59f3de3..104c83b357 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -67,9 +67,6 @@ tlv_ptr_table: TableSection(SymbolWithLoc) = .{},
thunk_table: std.AutoHashMapUnmanaged(Atom.Index, thunks.Thunk.Index) = .{},
thunks: std.ArrayListUnmanaged(thunks.Thunk) = .{},
-error_flags: File.ErrorFlags = File.ErrorFlags{},
-misc_errors: std.ArrayListUnmanaged(File.ErrorMsg) = .{},
-
segment_table_dirty: bool = false,
got_table_count_dirty: bool = false,
got_table_contents_dirty: bool = false,
@@ -337,8 +334,8 @@ pub fn flush(self: *MachO, comp: *Compilation, prog_node: *std.Progress.Node) li
if (build_options.have_llvm) {
return self.base.linkAsArchive(comp, prog_node);
} else {
- try self.misc_errors.ensureUnusedCapacity(gpa, 1);
- self.misc_errors.appendAssumeCapacity(.{
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, 1);
+ self.base.misc_errors.appendAssumeCapacity(.{
.msg = try gpa.dupe(u8, "TODO: non-LLVM archiver for MachO object files"),
});
return error.FlushFailure;
@@ -492,7 +489,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
try self.resolveSymbols();
if (self.getEntryPoint() == null) {
- self.error_flags.no_entry_point_found = true;
+ self.base.error_flags.no_entry_point_found = true;
}
if (self.unresolved.count() > 0) {
try self.reportUndefined();
@@ -2097,11 +2094,6 @@ pub fn deinit(self: *MachO) void {
bindings.deinit(gpa);
}
self.bindings.deinit(gpa);
-
- for (self.misc_errors.items) |*err| {
- err.deinit(gpa);
- }
- self.misc_errors.deinit(gpa);
}
fn freeAtom(self: *MachO, atom_index: Atom.Index) void {
@@ -5341,13 +5333,13 @@ fn reportMissingLibraryError(
args: anytype,
) error{OutOfMemory}!void {
const gpa = self.base.comp.gpa;
- try self.misc_errors.ensureUnusedCapacity(gpa, 1);
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, 1);
const notes = try gpa.alloc(File.ErrorMsg, checked_paths.len);
errdefer gpa.free(notes);
for (checked_paths, notes) |path, *note| {
note.* = .{ .msg = try std.fmt.allocPrint(gpa, "tried {s}", .{path}) };
}
- self.misc_errors.appendAssumeCapacity(.{
+ self.base.misc_errors.appendAssumeCapacity(.{
.msg = try std.fmt.allocPrint(gpa, format, args),
.notes = notes,
});
@@ -5361,14 +5353,14 @@ fn reportDependencyError(
args: anytype,
) error{OutOfMemory}!void {
const gpa = self.base.comp.gpa;
- try self.misc_errors.ensureUnusedCapacity(gpa, 1);
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, 1);
var notes = try std.ArrayList(File.ErrorMsg).initCapacity(gpa, 2);
defer notes.deinit();
if (path) |p| {
notes.appendAssumeCapacity(.{ .msg = try std.fmt.allocPrint(gpa, "while parsing {s}", .{p}) });
}
notes.appendAssumeCapacity(.{ .msg = try std.fmt.allocPrint(gpa, "a dependency of {s}", .{parent}) });
- self.misc_errors.appendAssumeCapacity(.{
+ self.base.misc_errors.appendAssumeCapacity(.{
.msg = try std.fmt.allocPrint(gpa, format, args),
.notes = try notes.toOwnedSlice(),
});
@@ -5381,11 +5373,11 @@ pub fn reportParseError(
args: anytype,
) error{OutOfMemory}!void {
const gpa = self.base.comp.gpa;
- try self.misc_errors.ensureUnusedCapacity(gpa, 1);
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, 1);
var notes = try gpa.alloc(File.ErrorMsg, 1);
errdefer gpa.free(notes);
notes[0] = .{ .msg = try std.fmt.allocPrint(gpa, "while parsing {s}", .{path}) };
- self.misc_errors.appendAssumeCapacity(.{
+ self.base.misc_errors.appendAssumeCapacity(.{
.msg = try std.fmt.allocPrint(gpa, format, args),
.notes = notes,
});
@@ -5398,11 +5390,11 @@ pub fn reportUnresolvedBoundarySymbol(
args: anytype,
) error{OutOfMemory}!void {
const gpa = self.base.comp.gpa;
- try self.misc_errors.ensureUnusedCapacity(gpa, 1);
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, 1);
var notes = try gpa.alloc(File.ErrorMsg, 1);
errdefer gpa.free(notes);
notes[0] = .{ .msg = try std.fmt.allocPrint(gpa, "while resolving {s}", .{sym_name}) };
- self.misc_errors.appendAssumeCapacity(.{
+ self.base.misc_errors.appendAssumeCapacity(.{
.msg = try std.fmt.allocPrint(gpa, format, args),
.notes = notes,
});
@@ -5411,7 +5403,7 @@ pub fn reportUnresolvedBoundarySymbol(
pub fn reportUndefined(self: *MachO) error{OutOfMemory}!void {
const gpa = self.base.comp.gpa;
const count = self.unresolved.count();
- try self.misc_errors.ensureUnusedCapacity(gpa, count);
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, count);
for (self.unresolved.keys()) |global_index| {
const global = self.globals.items[global_index];
@@ -5432,7 +5424,7 @@ pub fn reportUndefined(self: *MachO) error{OutOfMemory}!void {
};
err_msg.notes = try notes.toOwnedSlice();
- self.misc_errors.appendAssumeCapacity(err_msg);
+ self.base.misc_errors.appendAssumeCapacity(err_msg);
}
}
@@ -5442,7 +5434,7 @@ fn reportSymbolCollision(
other: SymbolWithLoc,
) error{OutOfMemory}!void {
const gpa = self.base.comp.gpa;
- try self.misc_errors.ensureUnusedCapacity(gpa, 1);
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, 1);
var notes = try std.ArrayList(File.ErrorMsg).initCapacity(gpa, 2);
defer notes.deinit();
@@ -5465,12 +5457,12 @@ fn reportSymbolCollision(
}) };
err_msg.notes = try notes.toOwnedSlice();
- self.misc_errors.appendAssumeCapacity(err_msg);
+ self.base.misc_errors.appendAssumeCapacity(err_msg);
}
fn reportUnhandledSymbolType(self: *MachO, sym_with_loc: SymbolWithLoc) error{OutOfMemory}!void {
const gpa = self.base.comp.gpa;
- try self.misc_errors.ensureUnusedCapacity(gpa, 1);
+ try self.base.misc_errors.ensureUnusedCapacity(gpa, 1);
const notes = try gpa.alloc(File.ErrorMsg, 1);
errdefer gpa.free(notes);
@@ -5488,7 +5480,7 @@ fn reportUnhandledSymbolType(self: *MachO, sym_with_loc: SymbolWithLoc) error{Ou
else
unreachable;
- self.misc_errors.appendAssumeCapacity(.{
+ self.base.misc_errors.appendAssumeCapacity(.{
.msg = try std.fmt.allocPrint(gpa, "unhandled symbol type: '{s}' has type {s}", .{
self.getSymbolName(sym_with_loc),
sym_type,
diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig
index 0263995359..d76a6de841 100644
--- a/src/link/MachO/Atom.zig
+++ b/src/link/MachO/Atom.zig
@@ -253,7 +253,8 @@ pub fn addRelocation(macho_file: *MachO, atom_index: Index, reloc: Relocation) !
}
pub fn addRelocations(macho_file: *MachO, atom_index: Index, relocs: []const Relocation) !void {
- const gpa = macho_file.base.allocator;
+ const comp = macho_file.base.comp;
+ const gpa = comp.gpa;
const gop = try macho_file.relocs.getOrPut(gpa, atom_index);
if (!gop.found_existing) {
gop.value_ptr.* = .{};
@@ -269,7 +270,8 @@ pub fn addRelocations(macho_file: *MachO, atom_index: Index, relocs: []const Rel
}
pub fn addRebase(macho_file: *MachO, atom_index: Index, offset: u32) !void {
- const gpa = macho_file.base.allocator;
+ const comp = macho_file.base.comp;
+ const gpa = comp.gpa;
const atom = macho_file.getAtom(atom_index);
log.debug(" (adding rebase at offset 0x{x} in %{?d})", .{ offset, atom.getSymbolIndex() });
const gop = try macho_file.rebases.getOrPut(gpa, atom_index);
@@ -280,7 +282,8 @@ pub fn addRebase(macho_file: *MachO, atom_index: Index, offset: u32) !void {
}
pub fn addBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void {
- const gpa = macho_file.base.allocator;
+ const comp = macho_file.base.comp;
+ const gpa = comp.gpa;
const atom = macho_file.getAtom(atom_index);
log.debug(" (adding binding to symbol {s} at offset 0x{x} in %{?d})", .{
macho_file.getSymbolName(binding.target),
@@ -307,7 +310,8 @@ pub fn resolveRelocations(
}
pub fn freeRelocations(macho_file: *MachO, atom_index: Index) void {
- const gpa = macho_file.base.allocator;
+ const comp = macho_file.base.comp;
+ const gpa = comp.gpa;
var removed_relocs = macho_file.relocs.fetchOrderedRemove(atom_index);
if (removed_relocs) |*relocs| relocs.value.deinit(gpa);
var removed_rebases = macho_file.rebases.fetchOrderedRemove(atom_index);
diff --git a/src/link/Plan9.zig b/src/link/Plan9.zig
index c970e72e51..3fe6aee009 100644
--- a/src/link/Plan9.zig
+++ b/src/link/Plan9.zig
@@ -28,7 +28,6 @@ pub const base_tag = .plan9;
base: link.File,
sixtyfour_bit: bool,
-error_flags: File.ErrorFlags = File.ErrorFlags{},
bases: Bases,
/// A symbol's value is just casted down when compiling