| ... | ... | @@ -517,7 +517,7 @@ fn allocateSegment(self: *Zld, index: u16, offset: u64, start: u64, reverse: boo |
| 517 | 517 | var count: usize = seg.sections.items.len; |
| 518 | 518 | while (count > 0) : (count -= 1) { |
| 519 | 519 | const sec = &seg.sections.items[count - 1]; |
| 520 | | end_off -= mem.alignForwardGeneric(u64, sec.size, @alignOf(u64)); // TODO is 8-byte aligned correct? |
| 520 | end_off -= mem.alignForwardGeneric(u64, sec.size, @alignOf(u128)); // TODO is 8-byte aligned correct? |
| 521 | 521 | sec.offset = @intCast(u32, end_off); |
| 522 | 522 | sec.addr = base_vmaddr + end_off; |
| 523 | 523 | } |
| ... | ... | @@ -526,7 +526,7 @@ fn allocateSegment(self: *Zld, index: u16, offset: u64, start: u64, reverse: boo |
| 526 | 526 | for (seg.sections.items) |*sect| { |
| 527 | 527 | sect.offset = @intCast(u32, next_off); |
| 528 | 528 | sect.addr = base_vmaddr + next_off; |
| 529 | | next_off += mem.alignForwardGeneric(u64, sect.size, @alignOf(u64)); // TODO is 8-byte aligned correct? |
| 529 | next_off += mem.alignForwardGeneric(u64, sect.size, @alignOf(u128)); // TODO is 8-byte aligned correct? |
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | } |
| ... | ... | @@ -1120,6 +1120,11 @@ fn doRelocs(self: *Zld) !void { |
| 1120 | 1120 | const narrowed = @truncate(u12, ta); |
| 1121 | 1121 | const offset: u12 = blk: { |
| 1122 | 1122 | if (parsed.size == 0) { |
| 1123 | if (parsed.v == 1) { |
| 1124 | // 128-bit SIMD is scaled by 16. |
| 1125 | break :blk try math.divExact(u12, narrowed, 16); |
| 1126 | } |
| 1127 | // Otherwise, 8-bit SIMD or ldrb. |
| 1123 | 1128 | break :blk narrowed; |
| 1124 | 1129 | } else { |
| 1125 | 1130 | const denom: u4 = try math.powi(u4, 2, parsed.size); |
| ... | ... | @@ -2184,25 +2189,26 @@ fn writeSymbolTable(self: *Zld) !void { |
| 2184 | 2189 | |
| 2185 | 2190 | for (self.locals.items()) |entries| { |
| 2186 | 2191 | log.warn("'{s}': {} entries", .{ entries.key, entries.value.items.len }); |
| 2187 | | var symbol: ?macho.nlist_64 = null; |
| 2192 | // var symbol: ?macho.nlist_64 = null; |
| 2188 | 2193 | for (entries.value.items) |entry| { |
| 2189 | 2194 | log.warn(" | {}", .{entry.inner}); |
| 2190 | 2195 | log.warn(" | {}", .{entry.tt}); |
| 2191 | 2196 | log.warn(" | {s}", .{entry.object.name}); |
| 2192 | | switch (entry.tt) { |
| 2193 | | .Global => { |
| 2194 | | symbol = entry.inner; |
| 2195 | | break; |
| 2196 | | }, |
| 2197 | | .WeakGlobal => { |
| 2198 | | symbol = entry.inner; |
| 2199 | | }, |
| 2200 | | .Local => {}, |
| 2201 | | } |
| 2202 | | } |
| 2203 | | if (symbol) |s| { |
| 2204 | | try locals.append(s); |
| 2197 | // switch (entry.tt) { |
| 2198 | // .Global => { |
| 2199 | // symbol = entry.inner; |
| 2200 | // break; |
| 2201 | // }, |
| 2202 | // .WeakGlobal => { |
| 2203 | // symbol = entry.inner; |
| 2204 | // }, |
| 2205 | // .Local => {}, |
| 2206 | // } |
| 2207 | try locals.append(entry.inner); |
| 2205 | 2208 | } |
| 2209 | // if (symbol) |s| { |
| 2210 | // try locals.append(s); |
| 2211 | // } |
| 2206 | 2212 | } |
| 2207 | 2213 | const nlocals = locals.items.len; |
| 2208 | 2214 | |