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