mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 15:42:49 +00:00
link: clean up type resolution in Elf.Atom and MachO.Atom
This commit is contained in:
parent
c430e9afa7
commit
9fdc32c96e
@ -119,7 +119,7 @@ pub fn addBaseRelocation(coff_file: *Coff, atom_index: Index, offset: u32) !void
|
||||
try gop.value_ptr.append(gpa, offset);
|
||||
}
|
||||
|
||||
pub fn freeRelocations(coff_file: *Coff, atom_index: Atom.Index) void {
|
||||
pub fn freeRelocations(coff_file: *Coff, atom_index: Index) void {
|
||||
const gpa = coff_file.base.allocator;
|
||||
var removed_relocs = coff_file.relocs.fetchRemove(atom_index);
|
||||
if (removed_relocs) |*relocs| relocs.value.deinit(gpa);
|
||||
|
@ -20,8 +20,8 @@ offset_table_index: u32,
|
||||
|
||||
/// Points to the previous and next neighbors, based on the `text_offset`.
|
||||
/// This can be used to find, for example, the capacity of this `TextBlock`.
|
||||
prev_index: ?Atom.Index,
|
||||
next_index: ?Atom.Index,
|
||||
prev_index: ?Index,
|
||||
next_index: ?Index,
|
||||
|
||||
dbg_info_atom: Dwarf.Atom,
|
||||
|
||||
|
@ -40,8 +40,8 @@ alignment: u32,
|
||||
|
||||
/// Points to the previous and next neighbours
|
||||
/// TODO use the same trick as with symbols: reserve index 0 as null atom
|
||||
next_index: ?Atom.Index,
|
||||
prev_index: ?Atom.Index,
|
||||
next_index: ?Index,
|
||||
prev_index: ?Index,
|
||||
|
||||
dbg_info_atom: Dwarf.Atom,
|
||||
|
||||
@ -119,13 +119,13 @@ pub fn freeListEligible(self: Atom, macho_file: *MachO) bool {
|
||||
return surplus >= MachO.min_text_capacity;
|
||||
}
|
||||
|
||||
pub fn addRelocation(macho_file: *MachO, atom_index: Atom.Index, reloc: Relocation) !void {
|
||||
pub fn addRelocation(macho_file: *MachO, atom_index: Index, reloc: Relocation) !void {
|
||||
return addRelocations(macho_file, atom_index, 1, .{reloc});
|
||||
}
|
||||
|
||||
pub fn addRelocations(
|
||||
macho_file: *MachO,
|
||||
atom_index: Atom.Index,
|
||||
atom_index: Index,
|
||||
comptime count: comptime_int,
|
||||
relocs: [count]Relocation,
|
||||
) !void {
|
||||
@ -145,7 +145,7 @@ pub fn addRelocations(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn addRebase(macho_file: *MachO, atom_index: Atom.Index, offset: u32) !void {
|
||||
pub fn addRebase(macho_file: *MachO, atom_index: Index, offset: u32) !void {
|
||||
const gpa = macho_file.base.allocator;
|
||||
const atom = macho_file.getAtom(atom_index);
|
||||
log.debug(" (adding rebase at offset 0x{x} in %{?d})", .{ offset, atom.getSymbolIndex() });
|
||||
@ -156,7 +156,7 @@ pub fn addRebase(macho_file: *MachO, atom_index: Atom.Index, offset: u32) !void
|
||||
try gop.value_ptr.append(gpa, offset);
|
||||
}
|
||||
|
||||
pub fn addBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) !void {
|
||||
pub fn addBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void {
|
||||
const gpa = macho_file.base.allocator;
|
||||
const atom = macho_file.getAtom(atom_index);
|
||||
log.debug(" (adding binding to symbol {s} at offset 0x{x} in %{?d})", .{
|
||||
@ -171,7 +171,7 @@ pub fn addBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding)
|
||||
try gop.value_ptr.append(gpa, binding);
|
||||
}
|
||||
|
||||
pub fn addLazyBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) !void {
|
||||
pub fn addLazyBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void {
|
||||
const gpa = macho_file.base.allocator;
|
||||
const atom = macho_file.getAtom(atom_index);
|
||||
log.debug(" (adding lazy binding to symbol {s} at offset 0x{x} in %{?d})", .{
|
||||
@ -186,7 +186,7 @@ pub fn addLazyBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Bindi
|
||||
try gop.value_ptr.append(gpa, binding);
|
||||
}
|
||||
|
||||
pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void {
|
||||
pub fn resolveRelocations(macho_file: *MachO, atom_index: Index) !void {
|
||||
const atom = macho_file.getAtom(atom_index);
|
||||
const relocs = macho_file.relocs.get(atom_index) orelse return;
|
||||
const source_sym = atom.getSymbol(macho_file);
|
||||
@ -203,7 +203,7 @@ pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn freeRelocations(macho_file: *MachO, atom_index: Atom.Index) void {
|
||||
pub fn freeRelocations(macho_file: *MachO, atom_index: Index) void {
|
||||
const gpa = macho_file.base.allocator;
|
||||
var removed_relocs = macho_file.relocs.fetchOrderedRemove(atom_index);
|
||||
if (removed_relocs) |*relocs| relocs.value.deinit(gpa);
|
||||
|
Loading…
Reference in New Issue
Block a user