| author | |
| committer | |
| log | 5dfeb6cbc89d64f2a44eece41918e1c391c7c989 |
| tree | 65b5a182a9f8819635f38e401d81fde82cb19e77 |
| parent | 1cef0be01b80b087492c652b18304ec1946a81e6 |
| signature |
* macho: unblock stage2 on 32bit platforms
Unblocks compilation of stage2 on 32bit platforms, and fixes #7630.
* Use libstd convention: reads - usize, writes - u645 files changed, 20 insertions(+), 21 deletions(-)
src/link/MachO.zig+8-8| ... | ... | @@ -907,7 +907,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 907 | 907 | const size = try self.binding_info_table.calcSize(); |
| 908 | 908 | assert(dyld_info.bind_size >= size); |
| 909 | 909 | |
| 910 | var buffer = try self.base.allocator.alloc(u8, size); | |
| 910 | var buffer = try self.base.allocator.alloc(u8, @intCast(usize, size)); | |
| 911 | 911 | defer self.base.allocator.free(buffer); |
| 912 | 912 | |
| 913 | 913 | var stream = std.io.fixedBufferStream(buffer); |
| ... | ... | @@ -919,7 +919,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 919 | 919 | const size = try self.lazy_binding_info_table.calcSize(); |
| 920 | 920 | assert(dyld_info.lazy_bind_size >= size); |
| 921 | 921 | |
| 922 | var buffer = try self.base.allocator.alloc(u8, size); | |
| 922 | var buffer = try self.base.allocator.alloc(u8, @intCast(usize, size)); | |
| 923 | 923 | defer self.base.allocator.free(buffer); |
| 924 | 924 | |
| 925 | 925 | var stream = std.io.fixedBufferStream(buffer); |
| ... | ... | @@ -1875,13 +1875,13 @@ pub fn makeStaticString(comptime bytes: []const u8) [16]u8 { |
| 1875 | 1875 | |
| 1876 | 1876 | fn makeString(self: *MachO, bytes: []const u8) !u32 { |
| 1877 | 1877 | try self.string_table.ensureCapacity(self.base.allocator, self.string_table.items.len + bytes.len + 1); |
| 1878 | const result = self.string_table.items.len; | |
| 1878 | const result = @intCast(u32, self.string_table.items.len); | |
| 1879 | 1879 | self.string_table.appendSliceAssumeCapacity(bytes); |
| 1880 | 1880 | self.string_table.appendAssumeCapacity(0); |
| 1881 | 1881 | self.string_table_dirty = true; |
| 1882 | 1882 | if (self.d_sym) |*ds| |
| 1883 | 1883 | ds.string_table_dirty = true; |
| 1884 | return @intCast(u32, result); | |
| 1884 | return result; | |
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | 1887 | fn getString(self: *MachO, str_off: u32) []const u8 { |
| ... | ... | @@ -2245,7 +2245,7 @@ fn writeExportTrie(self: *MachO) !void { |
| 2245 | 2245 | } |
| 2246 | 2246 | |
| 2247 | 2247 | try trie.finalize(); |
| 2248 | var buffer = try self.base.allocator.alloc(u8, trie.size); | |
| 2248 | var buffer = try self.base.allocator.alloc(u8, @intCast(usize, trie.size)); | |
| 2249 | 2249 | defer self.base.allocator.free(buffer); |
| 2250 | 2250 | var stream = std.io.fixedBufferStream(buffer); |
| 2251 | 2251 | const nwritten = try trie.write(stream.writer()); |
| ... | ... | @@ -2275,7 +2275,7 @@ fn writeBindingInfoTable(self: *MachO) !void { |
| 2275 | 2275 | defer tracy.end(); |
| 2276 | 2276 | |
| 2277 | 2277 | const size = try self.binding_info_table.calcSize(); |
| 2278 | var buffer = try self.base.allocator.alloc(u8, size); | |
| 2278 | var buffer = try self.base.allocator.alloc(u8, @intCast(usize, size)); | |
| 2279 | 2279 | defer self.base.allocator.free(buffer); |
| 2280 | 2280 | |
| 2281 | 2281 | var stream = std.io.fixedBufferStream(buffer); |
| ... | ... | @@ -2303,7 +2303,7 @@ fn writeLazyBindingInfoTable(self: *MachO) !void { |
| 2303 | 2303 | if (!self.lazy_binding_info_dirty) return; |
| 2304 | 2304 | |
| 2305 | 2305 | const size = try self.lazy_binding_info_table.calcSize(); |
| 2306 | var buffer = try self.base.allocator.alloc(u8, size); | |
| 2306 | var buffer = try self.base.allocator.alloc(u8, @intCast(usize, size)); | |
| 2307 | 2307 | defer self.base.allocator.free(buffer); |
| 2308 | 2308 | |
| 2309 | 2309 | var stream = std.io.fixedBufferStream(buffer); |
| ... | ... | @@ -2400,7 +2400,7 @@ fn updateLinkeditSegmentSizes(self: *MachO) !void { |
| 2400 | 2400 | fn writeLoadCommands(self: *MachO) !void { |
| 2401 | 2401 | if (!self.load_commands_dirty) return; |
| 2402 | 2402 | |
| 2403 | var sizeofcmds: usize = 0; | |
| 2403 | var sizeofcmds: u32 = 0; | |
| 2404 | 2404 | for (self.load_commands.items) |lc| { |
| 2405 | 2405 | sizeofcmds += lc.cmdsize(); |
| 2406 | 2406 | } |
src/link/MachO/CodeSignature.zig+1-1| ... | ... | @@ -84,7 +84,7 @@ pub fn calcAdhocSignature( |
| 84 | 84 | .identOffset = 0, |
| 85 | 85 | .nSpecialSlots = 0, |
| 86 | 86 | .nCodeSlots = 0, |
| 87 | .codeLimit = @intCast(u32, file_size), | |
| 87 | .codeLimit = file_size, | |
| 88 | 88 | .hashSize = hash_size, |
| 89 | 89 | .hashType = macho.CS_HASHTYPE_SHA256, |
| 90 | 90 | .platform = 0, |
src/link/MachO/DebugSymbols.zig+1-1| ... | ... | @@ -747,7 +747,7 @@ fn updateDwarfSegment(self: *DebugSymbols) void { |
| 747 | 747 | fn writeLoadCommands(self: *DebugSymbols, allocator: *Allocator) !void { |
| 748 | 748 | if (!self.load_commands_dirty) return; |
| 749 | 749 | |
| 750 | var sizeofcmds: usize = 0; | |
| 750 | var sizeofcmds: u32 = 0; | |
| 751 | 751 | for (self.load_commands.items) |lc| { |
| 752 | 752 | sizeofcmds += lc.cmdsize(); |
| 753 | 753 | } |
src/link/MachO/Trie.zig+6-7| ... | ... | @@ -52,7 +52,7 @@ pub const Node = struct { |
| 52 | 52 | } = null, |
| 53 | 53 | |
| 54 | 54 | /// Offset of this node in the trie output byte stream. |
| 55 | trie_offset: ?usize = null, | |
| 55 | trie_offset: ?u64 = null, | |
| 56 | 56 | |
| 57 | 57 | /// List of all edges originating from this node. |
| 58 | 58 | edges: std.ArrayListUnmanaged(Edge) = .{}, |
| ... | ... | @@ -199,7 +199,6 @@ pub const Node = struct { |
| 199 | 199 | assert(!self.node_dirty); |
| 200 | 200 | if (self.terminal_info) |info| { |
| 201 | 201 | // Terminal node info: encode export flags and vmaddr offset of this symbol. |
| 202 | var info_buf_len: usize = 0; | |
| 203 | 202 | var info_buf: [@sizeOf(u64) * 2]u8 = undefined; |
| 204 | 203 | var info_stream = std.io.fixedBufferStream(&info_buf); |
| 205 | 204 | // TODO Implement for special flags. |
| ... | ... | @@ -233,7 +232,7 @@ pub const Node = struct { |
| 233 | 232 | |
| 234 | 233 | const FinalizeResult = struct { |
| 235 | 234 | /// Current size of this node in bytes. |
| 236 | node_size: usize, | |
| 235 | node_size: u64, | |
| 237 | 236 | |
| 238 | 237 | /// True if the trie offset of this node in the output byte stream |
| 239 | 238 | /// would need updating; false otherwise. |
| ... | ... | @@ -241,11 +240,11 @@ pub const Node = struct { |
| 241 | 240 | }; |
| 242 | 241 | |
| 243 | 242 | /// Updates offset of this node in the output byte stream. |
| 244 | fn finalize(self: *Node, offset_in_trie: usize) !FinalizeResult { | |
| 243 | fn finalize(self: *Node, offset_in_trie: u64) !FinalizeResult { | |
| 245 | 244 | var stream = std.io.countingWriter(std.io.null_writer); |
| 246 | 245 | var writer = stream.writer(); |
| 247 | 246 | |
| 248 | var node_size: usize = 0; | |
| 247 | var node_size: u64 = 0; | |
| 249 | 248 | if (self.terminal_info) |info| { |
| 250 | 249 | try leb.writeULEB128(writer, info.export_flags); |
| 251 | 250 | try leb.writeULEB128(writer, info.vmaddr_offset); |
| ... | ... | @@ -288,7 +287,7 @@ ordered_nodes: std.ArrayListUnmanaged(*Node) = .{}, |
| 288 | 287 | /// insertions performed after `finalize` was called. |
| 289 | 288 | /// Call `finalize` before accessing this value to ensure |
| 290 | 289 | /// it is up-to-date. |
| 291 | size: usize = 0, | |
| 290 | size: u64 = 0, | |
| 292 | 291 | |
| 293 | 292 | /// Number of nodes currently in the trie. |
| 294 | 293 | node_count: usize = 0, |
| ... | ... | @@ -374,7 +373,7 @@ pub fn read(self: *Trie, reader: anytype) ReadError!usize { |
| 374 | 373 | |
| 375 | 374 | /// Write the trie to a byte stream. |
| 376 | 375 | /// Panics if the trie was not finalized using `finalize` before calling this method. |
| 377 | pub fn write(self: Trie, writer: anytype) !usize { | |
| 376 | pub fn write(self: Trie, writer: anytype) !u64 { | |
| 378 | 377 | assert(!self.trie_dirty); |
| 379 | 378 | var counting_writer = std.io.countingWriter(writer); |
| 380 | 379 | for (self.ordered_nodes.items) |node| { |
src/link/MachO/imports.zig+4-4| ... | ... | @@ -138,10 +138,10 @@ pub const BindingInfoTable = struct { |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /// Calculate size in bytes of this binding info table. |
| 141 | pub fn calcSize(self: *BindingInfoTable) !usize { | |
| 141 | pub fn calcSize(self: *BindingInfoTable) !u64 { | |
| 142 | 142 | var stream = std.io.countingWriter(std.io.null_writer); |
| 143 | 143 | var writer = stream.writer(); |
| 144 | var size: usize = 1; | |
| 144 | var size: u64 = 1; | |
| 145 | 145 | |
| 146 | 146 | if (self.dylib_ordinal > 15) { |
| 147 | 147 | try leb.writeULEB128(writer, @bitCast(u64, self.dylib_ordinal)); |
| ... | ... | @@ -296,10 +296,10 @@ pub const LazyBindingInfoTable = struct { |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /// Calculate size in bytes of this binding info table. |
| 299 | pub fn calcSize(self: *LazyBindingInfoTable) !usize { | |
| 299 | pub fn calcSize(self: *LazyBindingInfoTable) !u64 { | |
| 300 | 300 | var stream = std.io.countingWriter(std.io.null_writer); |
| 301 | 301 | var writer = stream.writer(); |
| 302 | var size: usize = 0; | |
| 302 | var size: u64 = 0; | |
| 303 | 303 | |
| 304 | 304 | for (self.symbols.items) |symbol| { |
| 305 | 305 | size += 1; |