Skip to content

Commit debed5c

Browse files
authored
Merge branch 'main' into kubkon/macos-15
2 parents 5a6eaf6 + 718ff23 commit debed5c

File tree

14 files changed

+167
-128
lines changed

14 files changed

+167
-128
lines changed

src/Archive.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
objects: std.ArrayListUnmanaged(Object) = .{},
1+
objects: std.ArrayListUnmanaged(Object) = .empty,
22

33
// Archive files start with the ARMAG identifying string. Then follows a
44
// `struct ar_hdr', and as many bytes of member file data as its `ar_size'

src/Atom.zig

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ n_sect: u32 = 0,
2323
value: u64 = 0,
2424

2525
/// Name of this Atom.
26-
name: MachO.String = .{},
26+
name: MachO.String = .init,
2727

2828
/// Index of the output section.
2929
out_n_sect: u8 = 0,
@@ -312,7 +312,7 @@ fn reportUndefSymbol(self: Atom, rel: Relocation, macho_file: *MachO) !bool {
312312
const gpa = macho_file.allocator;
313313
const gop = try macho_file.undefs.getOrPut(gpa, file.getGlobals()[@intFromEnum(rel.target.symbol)]); // TODO unsafe
314314
if (!gop.found_existing) {
315-
gop.value_ptr.* = .{ .atom_refs = .{} };
315+
gop.value_ptr.* = .{ .atom_refs = .empty };
316316
}
317317
try gop.value_ptr.atom_refs.append(gpa, self.atom_index.toRef(self.file));
318318
return true;
@@ -950,31 +950,43 @@ pub const UnwrappedRef = struct {
950950

951951
pub const Extra = struct {
952952
/// Index of the range extension thunk of this atom.
953-
thunk: u32 = 0,
953+
thunk: u32,
954954

955955
/// Start index of relocations belonging to this atom.
956-
rel_index: u32 = 0,
956+
rel_index: u32,
957957

958958
/// Count of relocations belonging to this atom.
959-
rel_count: u32 = 0,
959+
rel_count: u32,
960960

961961
/// Start index of relocations being written out to file for this atom.
962-
rel_out_index: u32 = 0,
962+
rel_out_index: u32,
963963

964964
/// Count of relocations written out to file for this atom.
965-
rel_out_count: u32 = 0,
965+
rel_out_count: u32,
966966

967967
/// Start index of relocations belonging to this atom.
968-
unwind_index: u32 = 0,
968+
unwind_index: u32,
969969

970970
/// Count of relocations belonging to this atom.
971-
unwind_count: u32 = 0,
971+
unwind_count: u32,
972972

973973
/// Index into LiteralPool entry for this atom.
974-
literal_pool_index: u32 = 0,
974+
literal_pool_index: u32,
975975

976976
/// Index into the File's symbol table for local symbol representing this literal atom.
977-
literal_symbol_index: u32 = 0,
977+
literal_symbol_index: u32,
978+
979+
pub const init: Extra = .{
980+
.thunk = 0,
981+
.rel_index = 0,
982+
.rel_count = 0,
983+
.rel_out_index = 0,
984+
.rel_out_count = 0,
985+
.unwind_index = 0,
986+
.unwind_count = 0,
987+
.literal_pool_index = 0,
988+
.literal_symbol_index = 0,
989+
};
978990
};
979991

980992
const aarch64 = @import("aarch64.zig");

src/CodeSignature.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const CodeDirectory = struct {
5252
inner: macho.CodeDirectory,
5353
ident: []const u8,
5454
special_slots: [n_special_slots][hash_size]u8,
55-
code_slots: std.ArrayListUnmanaged([hash_size]u8) = .{},
55+
code_slots: std.ArrayListUnmanaged([hash_size]u8) = .empty,
5656

5757
const n_special_slots: usize = 7;
5858

src/Dylib.zig

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ index: File.Index,
55
file_handle: ?File.HandleIndex = null,
66
lib_stub: ?LibStub = null,
77

8-
exports: std.MultiArrayList(Export) = .{},
9-
strtab: std.ArrayListUnmanaged(u8) = .{},
8+
exports: std.MultiArrayList(Export) = .empty,
9+
strtab: std.ArrayListUnmanaged(u8) = .empty,
1010
id: ?Id = null,
1111
ordinal: u16 = 0,
1212

13-
symbols: std.ArrayListUnmanaged(Symbol) = .{},
14-
symbols_extra: std.ArrayListUnmanaged(u32) = .{},
15-
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .{},
16-
dependents: std.ArrayListUnmanaged(Id) = .{},
17-
rpaths: std.StringArrayHashMapUnmanaged(void) = .{},
13+
symbols: std.ArrayListUnmanaged(Symbol) = .empty,
14+
symbols_extra: std.ArrayListUnmanaged(u32) = .empty,
15+
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .empty,
16+
dependents: std.ArrayListUnmanaged(Id) = .empty,
17+
rpaths: std.StringArrayHashMapUnmanaged(void) = .empty,
1818
umbrella: File.Index,
1919

2020
needed: bool,
@@ -24,7 +24,7 @@ explicit: bool,
2424
hoisted: bool = true,
2525
referenced: bool = false,
2626

27-
output_symtab_ctx: MachO.SymtabCtx = .{},
27+
output_symtab_ctx: MachO.SymtabCtx = .init,
2828

2929
pub fn deinit(self: *Dylib, allocator: Allocator) void {
3030
if (self.lib_stub) |*ls| ls.deinit();
@@ -216,7 +216,7 @@ pub fn addExport(self: *Dylib, allocator: Allocator, name: []const u8, flags: Ex
216216
const index = try self.addSymbol(allocator);
217217
const symbol = &self.symbols.items[@intFromEnum(index)];
218218
symbol.name = str;
219-
symbol.extra = try self.addSymbolExtra(allocator, .{});
219+
symbol.extra = try self.addSymbolExtra(allocator, .init);
220220
symbol.flags.weak = flags.weak;
221221
symbol.flags.tlv = flags.tlv;
222222
symbol.visibility = .global;
@@ -616,7 +616,7 @@ fn initSymbols(self: *Dylib, macho_file: *MachO) !void {
616616
const index = self.addSymbolAssumeCapacity();
617617
const symbol = &self.symbols.items[@intFromEnum(index)];
618618
symbol.name = noff;
619-
symbol.extra = self.addSymbolExtraAssumeCapacity(.{});
619+
symbol.extra = self.addSymbolExtraAssumeCapacity(.init);
620620
symbol.flags.weak = flags.weak;
621621
symbol.flags.tlv = flags.tlv;
622622
symbol.visibility = .global;
@@ -842,7 +842,7 @@ pub const TargetMatcher = struct {
842842
allocator: Allocator,
843843
cpu_arch: std.Target.Cpu.Arch,
844844
platform: macho.PLATFORM,
845-
target_strings: std.ArrayListUnmanaged([]const u8) = .{},
845+
target_strings: std.ArrayListUnmanaged([]const u8) = .empty,
846846

847847
pub fn init(allocator: Allocator, cpu_arch: std.Target.Cpu.Arch, platform: macho.PLATFORM) !TargetMatcher {
848848
var self = TargetMatcher{

src/InternalObject.zig

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
index: File.Index,
22

3-
sections: std.MultiArrayList(Section) = .{},
4-
atoms: std.ArrayListUnmanaged(Atom) = .{},
5-
atoms_indexes: std.ArrayListUnmanaged(Atom.Index) = .{},
6-
atoms_extra: std.ArrayListUnmanaged(u32) = .{},
7-
symtab: std.ArrayListUnmanaged(macho.nlist_64) = .{},
8-
strtab: std.ArrayListUnmanaged(u8) = .{},
9-
symbols: std.ArrayListUnmanaged(Symbol) = .{},
10-
symbols_extra: std.ArrayListUnmanaged(u32) = .{},
11-
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .{},
12-
13-
objc_methnames: std.ArrayListUnmanaged(u8) = .{},
3+
sections: std.MultiArrayList(Section) = .empty,
4+
atoms: std.ArrayListUnmanaged(Atom) = .empty,
5+
atoms_indexes: std.ArrayListUnmanaged(Atom.Index) = .empty,
6+
atoms_extra: std.ArrayListUnmanaged(u32) = .empty,
7+
symtab: std.ArrayListUnmanaged(macho.nlist_64) = .empty,
8+
strtab: std.ArrayListUnmanaged(u8) = .empty,
9+
symbols: std.ArrayListUnmanaged(Symbol) = .empty,
10+
symbols_extra: std.ArrayListUnmanaged(u32) = .empty,
11+
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .empty,
12+
13+
objc_methnames: std.ArrayListUnmanaged(u8) = .empty,
1414
objc_selrefs: [@sizeOf(u64)]u8 = [_]u8{0} ** @sizeOf(u64),
1515

16-
force_undefined: std.ArrayListUnmanaged(Symbol.Index) = .{},
16+
force_undefined: std.ArrayListUnmanaged(Symbol.Index) = .empty,
1717
entry_index: ?Symbol.Index = null,
1818
dyld_stub_binder_index: ?Symbol.Index = null,
1919
dyld_private_index: ?Symbol.Index = null,
2020
objc_msg_send_index: ?Symbol.Index = null,
2121
mh_execute_header_index: ?Symbol.Index = null,
2222
mh_dylib_header_index: ?Symbol.Index = null,
2323
dso_handle_index: ?Symbol.Index = null,
24-
boundary_symbols: std.ArrayListUnmanaged(Symbol.Index) = .{},
24+
boundary_symbols: std.ArrayListUnmanaged(Symbol.Index) = .empty,
2525

26-
output_symtab_ctx: MachO.SymtabCtx = .{},
26+
output_symtab_ctx: MachO.SymtabCtx = .init,
2727

2828
pub fn deinit(self: *InternalObject, allocator: Allocator) void {
2929
for (self.sections.items(.relocs)) |*relocs| {
@@ -57,7 +57,7 @@ pub fn initSymbols(self: *InternalObject, macho_file: *MachO) !void {
5757
const index = obj.addSymbolAssumeCapacity();
5858
const symbol = &obj.symbols.items[@intFromEnum(index)];
5959
symbol.name = name;
60-
symbol.extra = obj.addSymbolExtraAssumeCapacity(.{});
60+
symbol.extra = obj.addSymbolExtraAssumeCapacity(.init);
6161
symbol.flags.dyn_ref = args.desc & macho.REFERENCED_DYNAMICALLY != 0;
6262
symbol.visibility = if (args.type & macho.N_EXT != 0) blk: {
6363
break :blk if (args.type & macho.N_PEXT != 0) .hidden else .global;
@@ -211,7 +211,7 @@ pub fn resolveBoundarySymbols(self: *InternalObject, macho_file: *MachO) !void {
211211
.n_value = 0,
212212
};
213213
sym.nlist_idx = nlist_idx;
214-
sym.extra = self.addSymbolExtraAssumeCapacity(.{});
214+
sym.extra = self.addSymbolExtraAssumeCapacity(.init);
215215

216216
const idx = ref.getFile(macho_file).object.globals.items[@intFromEnum(ref.symbol)];
217217
self.globals.addOneAssumeCapacity().* = idx;
@@ -266,7 +266,7 @@ fn addObjcMethnameSection(self: *InternalObject, methname: []const u8, macho_fil
266266
const sym = &self.symbols.items[@intFromEnum(sym_index)];
267267
sym.name = name_str;
268268
sym.atom_ref = atom_index.toRef(self.index);
269-
sym.extra = try self.addSymbolExtra(gpa, .{});
269+
sym.extra = try self.addSymbolExtra(gpa, .init);
270270
const nlist_idx: u32 = @intCast(self.symtab.items.len);
271271
const nlist = try self.symtab.addOne(gpa);
272272
nlist.* = .{
@@ -317,7 +317,7 @@ fn addObjcSelrefsSection(self: *InternalObject, methname_sym_index: Symbol.Index
317317
const sym_index = try self.addSymbol(gpa);
318318
const sym = &self.symbols.items[@intFromEnum(sym_index)];
319319
sym.atom_ref = atom_index.toRef(self.index);
320-
sym.extra = try self.addSymbolExtra(gpa, .{});
320+
sym.extra = try self.addSymbolExtra(gpa, .init);
321321
const nlist_idx: u32 = @intCast(self.symtab.items.len);
322322
const nlist = try self.symtab.addOne(gpa);
323323
nlist.* = .{
@@ -685,7 +685,7 @@ fn addAtom(self: *InternalObject, allocator: Allocator, size: u64, alignment: u3
685685
.alignment = alignment,
686686
.file = self.index,
687687
.atom_index = atom_index,
688-
.extra = try self.addAtomExtra(allocator, .{}),
688+
.extra = try self.addAtomExtra(allocator, .init),
689689
};
690690
return atom_index;
691691
}
@@ -884,7 +884,7 @@ fn formatSymtab(
884884

885885
const Section = struct {
886886
header: macho.section_64,
887-
relocs: std.ArrayListUnmanaged(Relocation) = .{},
887+
relocs: std.ArrayListUnmanaged(Relocation) = .empty,
888888
extra: Extra = .{},
889889

890890
const Extra = packed struct {

0 commit comments

Comments
 (0)