aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/Object.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-07-07 22:15:41 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-07-15 18:49:47 +0200
commite524f43a6fbb5189d24aa42667ababdcd92a2ab2 (patch)
treeec68e9b10d3c6d9e03932db7a09459419ccbf3e4 /src/link/MachO/Object.zig
parent7c662db8d95670f8ac0c88e9a2d6f49ef6782f13 (diff)
downloadzig-e524f43a6fbb5189d24aa42667ababdcd92a2ab2.tar.gz
zig-e524f43a6fbb5189d24aa42667ababdcd92a2ab2.zip
zld: save rebase and TLV offset as part of TextBlock
instead of as part of the Symbol. This seems to be more optimal way of handling dyld ops in presence of no splittable input sections in object files.
Diffstat (limited to 'src/link/MachO/Object.zig')
-rw-r--r--src/link/MachO/Object.zig28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig
index 011aca06c3..f000119edf 100644
--- a/src/link/MachO/Object.zig
+++ b/src/link/MachO/Object.zig
@@ -435,6 +435,8 @@ const TextBlockParser = struct {
.references = std.AutoArrayHashMap(u32, void).init(self.allocator),
.code = try self.allocator.dupe(u8, code),
.relocs = std.ArrayList(Relocation).init(self.allocator),
+ .rebases = std.ArrayList(u64).init(self.allocator),
+ .tlv_offsets = std.ArrayList(u64).init(self.allocator),
.size = size,
.alignment = self.section.@"align",
};
@@ -444,18 +446,6 @@ const TextBlockParser = struct {
try self.object.parseRelocs(self.zld, relocs, block, start_addr);
}
- const is_zerofill = blk: {
- const tseg = self.zld.load_commands.items[self.match.seg].Segment;
- const tsect = tseg.sections.items[self.match.sect];
- const tsect_type = sectionType(tsect);
- break :blk tsect_type == macho.S_ZEROFILL or
- tsect_type == macho.S_THREAD_LOCAL_ZEROFILL or
- tsect_type == macho.S_THREAD_LOCAL_VARIABLES;
- };
- if (is_zerofill) {
- mem.set(u8, block.code, 0);
- }
-
self.index += 1;
return block;
@@ -589,6 +579,8 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
.references = std.AutoArrayHashMap(u32, void).init(self.allocator),
.code = try self.allocator.dupe(u8, code),
.relocs = std.ArrayList(Relocation).init(self.allocator),
+ .rebases = std.ArrayList(u64).init(self.allocator),
+ .tlv_offsets = std.ArrayList(u64).init(self.allocator),
.size = sect.size,
.alignment = sect.@"align",
};
@@ -597,18 +589,6 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
try self.parseRelocs(zld, relocs, block, 0);
}
- const is_zerofill = blk: {
- const tseg = zld.load_commands.items[match.seg].Segment;
- const tsect = tseg.sections.items[match.sect];
- const tsect_type = sectionType(tsect);
- break :blk tsect_type == macho.S_ZEROFILL or
- tsect_type == macho.S_THREAD_LOCAL_ZEROFILL or
- tsect_type == macho.S_THREAD_LOCAL_VARIABLES;
- };
- if (is_zerofill) {
- mem.set(u8, block.code, 0);
- }
-
if (zld.blocks.getPtr(match)) |last| {
last.*.next = block;
block.prev = last.*;