| ... | @@ -517,7 +517,7 @@ fn allocateSegment(self: *Zld, index: u16, offset: u64, start: u64, reverse: boo | ... | @@ -517,7 +517,7 @@ fn allocateSegment(self: *Zld, index: u16, offset: u64, start: u64, reverse: boo |
| 517 | var count: usize = seg.sections.items.len; | 517 | var count: usize = seg.sections.items.len; |
| 518 | while (count > 0) : (count -= 1) { | 518 | while (count > 0) : (count -= 1) { |
| 519 | const sec = &seg.sections.items[count - 1]; | 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 | sec.offset = @intCast(u32, end_off); | 521 | sec.offset = @intCast(u32, end_off); |
| 522 | sec.addr = base_vmaddr + end_off; | 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,7 +526,7 @@ fn allocateSegment(self: *Zld, index: u16, offset: u64, start: u64, reverse: boo |
| 526 | for (seg.sections.items) |*sect| { | 526 | for (seg.sections.items) |*sect| { |
| 527 | sect.offset = @intCast(u32, next_off); | 527 | sect.offset = @intCast(u32, next_off); |
| 528 | sect.addr = base_vmaddr + next_off; | 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,6 +1120,11 @@ fn doRelocs(self: *Zld) !void { |
| 1120 | const narrowed = @truncate(u12, ta); | 1120 | const narrowed = @truncate(u12, ta); |
| 1121 | const offset: u12 = blk: { | 1121 | const offset: u12 = blk: { |
| 1122 | if (parsed.size == 0) { | 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 | break :blk narrowed; | 1128 | break :blk narrowed; |
| 1124 | } else { | 1129 | } else { |
| 1125 | const denom: u4 = try math.powi(u4, 2, parsed.size); | 1130 | const denom: u4 = try math.powi(u4, 2, parsed.size); |
| ... | @@ -2184,25 +2189,26 @@ fn writeSymbolTable(self: *Zld) !void { | ... | @@ -2184,25 +2189,26 @@ fn writeSymbolTable(self: *Zld) !void { |
| 2184 | | 2189 | |
| 2185 | for (self.locals.items()) |entries| { | 2190 | for (self.locals.items()) |entries| { |
| 2186 | log.warn("'{s}': {} entries", .{ entries.key, entries.value.items.len }); | 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 | for (entries.value.items) |entry| { | 2193 | for (entries.value.items) |entry| { |
| 2189 | log.warn(" | {}", .{entry.inner}); | 2194 | log.warn(" | {}", .{entry.inner}); |
| 2190 | log.warn(" | {}", .{entry.tt}); | 2195 | log.warn(" | {}", .{entry.tt}); |
| 2191 | log.warn(" | {s}", .{entry.object.name}); | 2196 | log.warn(" | {s}", .{entry.object.name}); |
| 2192 | switch (entry.tt) { | 2197 | // switch (entry.tt) { |
| 2193 | .Global => { | 2198 | // .Global => { |
| 2194 | symbol = entry.inner; | 2199 | // symbol = entry.inner; |
| 2195 | break; | 2200 | // break; |
| 2196 | }, | 2201 | // }, |
| 2197 | .WeakGlobal => { | 2202 | // .WeakGlobal => { |
| 2198 | symbol = entry.inner; | 2203 | // symbol = entry.inner; |
| 2199 | }, | 2204 | // }, |
| 2200 | .Local => {}, | 2205 | // .Local => {}, |
| 2201 | } | 2206 | // } |
| 2202 | } | 2207 | try locals.append(entry.inner); |
| 2203 | if (symbol) |s| { | | |
| 2204 | try locals.append(s); | | |
| 2205 | } | 2208 | } |
| | 2209 | // if (symbol) |s| { |
| | 2210 | // try locals.append(s); |
| | 2211 | // } |
| 2206 | } | 2212 | } |
| 2207 | const nlocals = locals.items.len; | 2213 | const nlocals = locals.items.len; |
| 2208 | | 2214 | |