diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-03-17 12:48:02 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-03-17 12:48:02 +0100 |
| commit | 4012fcb0a383dbf5564ef15e4c607705a1859a20 (patch) | |
| tree | 702bd6ad9d95dcbcd3a53bbb72dca4e1c1100cda | |
| parent | d53e0234a35560e611a808f30ec33541e7900893 (diff) | |
| download | zig-4012fcb0a383dbf5564ef15e4c607705a1859a20.tar.gz zig-4012fcb0a383dbf5564ef15e4c607705a1859a20.zip | |
macho: do not allocate new GOT atom when target atom has grown
That's the entire point of our GOT so that we don't have to do that;
simply overwrite the address in the GOT.
| -rw-r--r-- | src/link/MachO.zig | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 4695a7c4b4..694ddc5613 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -4012,27 +4012,8 @@ fn placeDecl(self: *MachO, decl: *Module.Decl, code_len: usize) !*macho.nlist_64 if (need_realloc) { const vaddr = try self.growAtom(&decl.link.macho, code_len, required_alignment, match); - log.debug("growing {s} and moving from 0x{x} to 0x{x}", .{ sym_name, symbol.n_value, vaddr }); log.debug(" (required alignment 0x{x})", .{required_alignment}); - - if (vaddr != symbol.n_value) { - log.debug(" (writing new GOT entry)", .{}); - const got_index = self.got_entries_table.get(.{ .local = decl.link.macho.local_sym_index }).?; - const got_atom = self.got_entries.items[got_index].atom; - const got_sym = &self.locals.items[got_atom.local_sym_index]; - const got_vaddr = try self.allocateAtom(got_atom, @sizeOf(u64), 8, .{ - .seg = self.data_const_segment_cmd_index.?, - .sect = self.got_section_index.?, - }); - got_sym.n_value = got_vaddr; - got_sym.n_sect = @intCast(u8, self.section_ordinals.getIndex(.{ - .seg = self.data_const_segment_cmd_index.?, - .sect = self.got_section_index.?, - }).? + 1); - got_atom.dirty = true; - } - symbol.n_value = vaddr; } else if (code_len < decl.link.macho.size) { self.shrinkAtom(&decl.link.macho, code_len, match); |
