| ... | ... | @@ -27,7 +27,7 @@ nodes: std.MultiArrayList(Node), |
| 27 | 27 | members: std.ArrayList(Member), |
| 28 | 28 | pending_members: std.AutoArrayHashMapUnmanaged(Member.Index, void), |
| 29 | 29 | lib_string_table: std.ArrayList(String), |
| 30 | | lib_string_len: u64, |
| 30 | lib_string_len: u32, |
| 31 | 31 | long_names_table: LongNamesTable, |
| 32 | 32 | import_table: ImportTable, |
| 33 | 33 | export_table: ExportTable, |
| ... | ... | @@ -528,7 +528,7 @@ pub const Member = struct { |
| 528 | 528 | |
| 529 | 529 | try Node.known.longnames_member.resize(&coff.mf, gpa, new_size); |
| 530 | 530 | const name_table_slice = Node.known.longnames_member.slice(&coff.mf); |
| 531 | | const name_slice = name_table_slice[old_size..][0 .. name.len + 1]; |
| 531 | const name_slice = name_table_slice[@intCast(old_size)..][0 .. name.len + 1]; |
| 532 | 532 | @memcpy(name_slice[0..name.len], name); |
| 533 | 533 | name_slice[name.len] = 0; |
| 534 | 534 | |
| ... | ... | @@ -608,7 +608,7 @@ pub const LongNamesTable = struct { |
| 608 | 608 | assert(adapter.coff.isArchive()); |
| 609 | 609 | const longnames_slice = Node.known.longnames_member.slice(&adapter.coff.mf); |
| 610 | 610 | const rhs = adapter.coff.long_names_table.entries.values()[rhs_index]; |
| 611 | | return std.mem.eql(u8, longnames_slice[rhs.offset..][0..rhs.len], lhs_key); |
| 611 | return std.mem.eql(u8, longnames_slice[@intCast(rhs.offset)..][0..@intCast(rhs.len)], lhs_key); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | pub fn hash(_: Adapter, key: []const u8) u32 { |
| ... | ... | @@ -2721,8 +2721,8 @@ fn getOrPutSymbolName(coff: *Coff, name: []const u8, opt_string: ?String) !Symbo |
| 2721 | 2721 | |
| 2722 | 2722 | try coff.symbol_table.strings_ni.resize(&coff.mf, gpa, string_index + name.len + 1); |
| 2723 | 2723 | const slice = coff.symbol_table.strings_ni.slice(&coff.mf); |
| 2724 | | @memcpy(slice[string_index..][0..name.len], name); |
| 2725 | | slice[string_index + name.len] = 0; |
| 2724 | @memcpy(slice[@intCast(string_index)..][0..name.len], name); |
| 2725 | slice[@intCast(string_index + name.len)] = 0; |
| 2726 | 2726 | } |
| 2727 | 2727 | |
| 2728 | 2728 | break :name .{ .long = string_gop.value_ptr.* }; |
| ... | ... | @@ -2941,7 +2941,7 @@ pub fn getVAddr(coff: *Coff, reloc_info: link.File.RelocInfo, target_si: Symbol. |
| 2941 | 2941 | } |
| 2942 | 2942 | |
| 2943 | 2943 | /// Caller guarantees there is capacity for one member and two nodes |
| 2944 | | fn addMemberAssumeCapacity(coff: *Coff, kind: std.coff.ArchiveMemberHeader.Kind, size: usize) !Member.Index { |
| 2944 | fn addMemberAssumeCapacity(coff: *Coff, kind: std.coff.ArchiveMemberHeader.Kind, size: u64) !Member.Index { |
| 2945 | 2945 | const comp = coff.base.comp; |
| 2946 | 2946 | const gpa = comp.gpa; |
| 2947 | 2947 | |
| ... | ... | @@ -2987,7 +2987,7 @@ fn addMemberAssumeCapacity(coff: *Coff, kind: std.coff.ArchiveMemberHeader.Kind, |
| 2987 | 2987 | |
| 2988 | 2988 | const old_size = Node.known.second_linker_member.location(&coff.mf).resolve(&coff.mf)[1]; |
| 2989 | 2989 | const old_header_size = new_num_members * @sizeOf(u32); |
| 2990 | | const trailing_size = old_size - old_header_size; |
| 2990 | const trailing_size: usize = @intCast(old_size - old_header_size); |
| 2991 | 2991 | try Node.known.second_linker_member.resize(&coff.mf, gpa, old_size + @sizeOf(u32)); |
| 2992 | 2992 | |
| 2993 | 2993 | const slice = Node.known.second_linker_member.slice(&coff.mf); |
| ... | ... | @@ -3053,12 +3053,12 @@ fn ensureMemberSymbol(coff: *Coff, mi: Member.Index, name: String) !void { |
| 3053 | 3053 | // can't guarantee that they will be tightly packed after resizing |
| 3054 | 3054 | |
| 3055 | 3055 | const name_slice = name.toSlice(coff); |
| 3056 | | const new_string_table_size = coff.lib_string_len + name_slice.len + 1; |
| 3056 | const new_string_table_size: u32 = @intCast(coff.lib_string_len + name_slice.len + 1); |
| 3057 | 3057 | defer coff.lib_string_len = new_string_table_size; |
| 3058 | 3058 | |
| 3059 | 3059 | { |
| 3060 | | const old_header_size = @sizeOf(u32) + @intFromEnum(mfli) * @sizeOf(u32); |
| 3061 | | const new_header_size = old_header_size + @sizeOf(u32); |
| 3060 | const old_header_size: usize = @intCast(@sizeOf(u32) + @intFromEnum(mfli) * @sizeOf(u32)); |
| 3061 | const new_header_size: usize = @intCast(old_header_size + @sizeOf(u32)); |
| 3062 | 3062 | try Node.known.first_linker_member.resize(&coff.mf, gpa, new_header_size + new_string_table_size); |
| 3063 | 3063 | |
| 3064 | 3064 | const slice = Node.known.first_linker_member.slice(&coff.mf); |
| ... | ... | @@ -3231,7 +3231,7 @@ fn flushSymbolTableEntry(coff: *Coff, index: u32, pt: Zcu.PerThread) !void { |
| 3231 | 3231 | .unused = @splat(0), |
| 3232 | 3232 | }; |
| 3233 | 3233 | if (coff.targetEndian() != native_endian) |
| 3234 | | std.mem.byteSwapAllFields(std.coff.SectionDefinition, .@"2", aux_ptr); |
| 3234 | std.mem.byteSwapAllFieldsAligned(std.coff.WeakExternalDefinition, .@"2", aux_ptr); |
| 3235 | 3235 | |
| 3236 | 3236 | break :aux_init; |
| 3237 | 3237 | } else switch (coff.getNode(sym.ni)) { |
| ... | ... | @@ -3249,7 +3249,7 @@ fn flushSymbolTableEntry(coff: *Coff, index: u32, pt: Zcu.PerThread) !void { |
| 3249 | 3249 | .unused = @splat(0), |
| 3250 | 3250 | }; |
| 3251 | 3251 | if (coff.targetEndian() != native_endian) |
| 3252 | | std.mem.byteSwapAllFields(std.coff.SectionDefinition, .@"2", aux_ptr); |
| 3252 | std.mem.byteSwapAllFieldsAligned(std.coff.SectionDefinition, .@"2", aux_ptr); |
| 3253 | 3253 | |
| 3254 | 3254 | break :aux_init; |
| 3255 | 3255 | }, |
| ... | ... | @@ -4269,7 +4269,7 @@ fn loadObject( |
| 4269 | 4269 | var weak_external: std.coff.WeakExternalDefinition = undefined; |
| 4270 | 4270 | @memcpy(std.mem.asBytes(&weak_external)[0..symbol_size], aux_symbols[0..symbol_size]); |
| 4271 | 4271 | if (target_endian != native_endian) |
| 4272 | | std.mem.byteSwapAllFields(std.coff.SectionDefinition, &weak_external); |
| 4272 | std.mem.byteSwapAllFields(std.coff.WeakExternalDefinition, &weak_external); |
| 4273 | 4273 | |
| 4274 | 4274 | if (weak_external.tag_index >= header.number_of_symbols) |
| 4275 | 4275 | return diags.failParse( |
| ... | ... | @@ -5131,7 +5131,7 @@ fn loadArchive(coff: *Coff, path: std.Build.Cache.Path, fr: *Io.File.Reader) Loa |
| 5131 | 5131 | symbol_member_indices.addOneAssumeCapacity().* = (try r.takeInt(u16, target_endian)) - 1; |
| 5132 | 5132 | |
| 5133 | 5133 | pos = fr.logicalPos(); |
| 5134 | | try coff.ensureManyUnusedStringCapacity(num_symbols, member_end - pos); |
| 5134 | try coff.ensureManyUnusedStringCapacity(num_symbols, @intCast(member_end - pos)); |
| 5135 | 5135 | try coff.input_archive_members.ensureUnusedCapacity(gpa, num_members); |
| 5136 | 5136 | try coff.input_archive_symbols.ensureUnusedCapacity(gpa, num_symbols); |
| 5137 | 5137 | try coff.input_archive_symbol_indices.ensureUnusedCapacity(gpa, num_symbols); |
| ... | ... | @@ -5202,7 +5202,7 @@ fn loadArchive(coff: *Coff, path: std.Build.Cache.Path, fr: *Io.File.Reader) Loa |
| 5202 | 5202 | .longnames => { |
| 5203 | 5203 | // This member is optional |
| 5204 | 5204 | if (std.mem.eql(u8, res.name, "//")) |
| 5205 | | opt_longnames = try r.readAlloc(gpa, res.size); |
| 5205 | opt_longnames = try r.readAlloc(gpa, @intCast(res.size)); |
| 5206 | 5206 | |
| 5207 | 5207 | opt_expected_kind = null; |
| 5208 | 5208 | break; |
| ... | ... | @@ -5753,9 +5753,8 @@ fn reportUndefs(coff: *Coff, tid: Zcu.PerThread.Id) !void { |
| 5753 | 5753 | // TODO: Make this a helper for anything that needs to report "referenced by" notes |
| 5754 | 5754 | switch (coff.getNode(loc_sym.ni)) { |
| 5755 | 5755 | .data_directories => { |
| 5756 | | const dir_align = std.mem.Alignment.of(std.coff.ImageDataDirectory); |
| 5757 | 5756 | const dir: std.coff.IMAGE.DIRECTORY_ENTRY = |
| 5758 | | @enumFromInt(dir_align.backward(reloc.offset) / @sizeOf(std.coff.IMAGE.DIRECTORY_ENTRY)); |
| 5757 | @enumFromInt(reloc.offset / @sizeOf(std.coff.ImageDataDirectory)); |
| 5759 | 5758 | err.addNote("referenced by data directory entry: {t}", .{dir}); |
| 5760 | 5759 | }, |
| 5761 | 5760 | .optional_header => err.addNote("referenced by optional header field", .{}), |
| ... | ... | @@ -6566,7 +6565,7 @@ fn flushGlobal(coff: *Coff, gmi: Node.GlobalMapIndex) !bool { |
| 6566 | 6565 | const Entry = std.coff.ImportLookupTableEntry(ct_magic); |
| 6567 | 6566 | const import_lookup_table: []Entry = @ptrCast(@alignCast(import_lookup_slice)); |
| 6568 | 6567 | const import_address_table: []Entry = @ptrCast(@alignCast(import_address_slice)); |
| 6569 | | const import_hint_name_rvas: [2]Entry = .{ |
| 6568 | var import_hint_name_rvas: [2]Entry = .{ |
| 6570 | 6569 | .{ |
| 6571 | 6570 | .payload = if (import.name == .none) |
| 6572 | 6571 | .{ .ordinal = .{ .ordinal = import.ordinal_hint } } |
| ... | ... | @@ -6577,7 +6576,7 @@ fn flushGlobal(coff: *Coff, gmi: Node.GlobalMapIndex) !bool { |
| 6577 | 6576 | @bitCast(@as(@typeInfo(Entry).@"struct".backing_integer.?, 0)), |
| 6578 | 6577 | }; |
| 6579 | 6578 | if (native_endian != target_endian) |
| 6580 | | for (import_hint_name_rvas) |*v| std.mem.byteSwapAllFields(Entry, v); |
| 6579 | for (&import_hint_name_rvas) |*v| std.mem.byteSwapAllFields(Entry, v); |
| 6581 | 6580 | |
| 6582 | 6581 | import_lookup_table[import_symbol_index..][0..2].* = import_hint_name_rvas; |
| 6583 | 6582 | import_address_table[import_symbol_index..][0..2].* = import_hint_name_rvas; |
| ... | ... | @@ -7182,7 +7181,7 @@ fn flushMember(coff: *Coff, mi: Member.Index) !void { |
| 7182 | 7181 | .strings = coff.lib_string_table.items, |
| 7183 | 7182 | }); |
| 7184 | 7183 | |
| 7185 | | var offset: u64 = 0; |
| 7184 | var offset: usize = 0; |
| 7186 | 7185 | var string_table = coff.secondLinkerMemberStringsSlice(); |
| 7187 | 7186 | for (coff.lib_string_table.items) |string| { |
| 7188 | 7187 | const str = string.toSlice(coff); |
| ... | ... | @@ -7419,7 +7418,7 @@ fn updateExportsInner( |
| 7419 | 7418 | if (export_count > std.math.maxInt(@FieldType(std.coff.ExportDirectoryTable, "number_of_entries"))) |
| 7420 | 7419 | return coff.base.comp.link_diags.fail("exceeded maximum number of exports", .{}); |
| 7421 | 7420 | |
| 7422 | | const name_index: u64 = coff.export_table.name_table_ni.location(&coff.mf).resolve(&coff.mf)[1]; |
| 7421 | const name_index: u32 = @intCast(coff.export_table.name_table_ni.location(&coff.mf).resolve(&coff.mf)[1]); |
| 7423 | 7422 | const new_name_table_size = name_index + name.len + 1; |
| 7424 | 7423 | if (new_name_table_size > std.math.maxInt(@FieldType(ExportTable.Entry, "name_index"))) |
| 7425 | 7424 | return coff.base.comp.link_diags.fail("exports name table limit reached", .{}); |