aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/Object.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2024-07-09 11:22:24 +0200
committerJakub Konka <kubkon@jakubkonka.com>2024-07-18 09:13:08 +0200
commitb9bac32a2562985ca7a67877169343975fd8f851 (patch)
treebf0f26530abc99fee00ba73d2e0a9de1e27f8dfc /src/link/MachO/Object.zig
parentc59583e43de35e91ac194860cd1eb63e61c272aa (diff)
downloadzig-b9bac32a2562985ca7a67877169343975fd8f851.tar.gz
zig-b9bac32a2562985ca7a67877169343975fd8f851.zip
macho: migrate Atom and Symbol
Diffstat (limited to 'src/link/MachO/Object.zig')
-rw-r--r--src/link/MachO/Object.zig14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig
index fcbb31f4ed..17dd198c6b 100644
--- a/src/link/MachO/Object.zig
+++ b/src/link/MachO/Object.zig
@@ -1860,7 +1860,7 @@ pub fn calcStabsSize(self: *Object, macho_file: *MachO) error{Overflow}!void {
const name = sym.getName(macho_file);
if (name.len > 0 and (name[0] == 'L' or name[0] == 'l')) continue;
}
- const sect = macho_file.sections.items(.header)[sym.out_n_sect];
+ const sect = macho_file.sections.items(.header)[sym.getOutputSectionIndex(macho_file)];
if (sect.isCode()) {
self.output_symtab_ctx.nstabs += 4; // N_BNSYM, N_FUN, N_FUN, N_ENSYM
} else if (sym.visibility == .global) {
@@ -2198,13 +2198,13 @@ pub fn writeStabs(self: *const Object, stroff: u32, macho_file: *MachO) void {
const name = sym.getName(macho_file);
if (name.len > 0 and (name[0] == 'L' or name[0] == 'l')) continue;
}
- const sect = macho_file.sections.items(.header)[sym.out_n_sect];
+ const sect = macho_file.sections.items(.header)[sym.getOutputSectionIndex(macho_file)];
const sym_n_strx = n_strx: {
const symtab_index = sym.getOutputSymtabIndex(macho_file).?;
const osym = macho_file.symtab.items[symtab_index];
break :n_strx osym.n_strx;
};
- const sym_n_sect: u8 = if (!sym.flags.abs) @intCast(sym.out_n_sect + 1) else 0;
+ const sym_n_sect: u8 = if (!sym.flags.abs) @intCast(sym.getOutputSectionIndex(macho_file) + 1) else 0;
const sym_n_value = sym.getAddress(.{}, macho_file);
const sym_size = sym.getSize(macho_file);
if (sect.isCode()) {
@@ -2299,7 +2299,7 @@ pub fn writeStabs(self: *const Object, stroff: u32, macho_file: *MachO) void {
const osym = macho_file.symtab.items[symtab_index];
break :n_strx osym.n_strx;
};
- const sym_n_sect: u8 = if (!sym.flags.abs) @intCast(sym.out_n_sect + 1) else 0;
+ const sym_n_sect: u8 = if (!sym.flags.abs) @intCast(sym.getOutputSectionIndex(macho_file) + 1) else 0;
const sym_n_value = sym.getAddress(.{}, macho_file);
const sym_size = sym.getSize(macho_file);
if (stab.is_func) {
@@ -2340,6 +2340,12 @@ pub fn writeStabs(self: *const Object, stroff: u32, macho_file: *MachO) void {
}
}
+pub fn getAtomRelocs(self: *const Object, atom: Atom, macho_file: *MachO) []const Relocation {
+ const extra = atom.getExtra(macho_file).?;
+ const relocs = self.sections.items(.relocs)[atom.n_sect];
+ return relocs.items[extra.rel_index..][0..extra.rel_count];
+}
+
fn addString(self: *Object, allocator: Allocator, name: [:0]const u8) error{OutOfMemory}!u32 {
const off: u32 = @intCast(self.strtab.items.len);
try self.strtab.ensureUnusedCapacity(allocator, name.len + 1);