aboutsummaryrefslogtreecommitdiff
path: root/lib/std/macho.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-09-01 16:50:39 +0100
committermlugg <mlugg@mlugg.co.uk>2025-09-30 13:44:49 +0100
commitb750e7cf9e2a1225b20ef7fdf53df9ef97cf8065 (patch)
treed4760dd9e1279db621fbf4318264f951117a2172 /lib/std/macho.zig
parentb706949736fe67e104a14ac1dcaac8b7eb1cc33f (diff)
downloadzig-b750e7cf9e2a1225b20ef7fdf53df9ef97cf8065.tar.gz
zig-b750e7cf9e2a1225b20ef7fdf53df9ef97cf8065.zip
change one million things
Diffstat (limited to 'lib/std/macho.zig')
-rw-r--r--lib/std/macho.zig118
1 files changed, 84 insertions, 34 deletions
diff --git a/lib/std/macho.zig b/lib/std/macho.zig
index 455f5f8fb1..0ce1f4c7ff 100644
--- a/lib/std/macho.zig
+++ b/lib/std/macho.zig
@@ -839,62 +839,112 @@ pub const nlist = extern struct {
pub const nlist_64 = extern struct {
n_strx: u32,
- n_type: u8,
+ n_type: packed union {
+ bits: packed struct(u8) {
+ ext: bool,
+ type: enum(u3) {
+ undf = 0,
+ abs = 1,
+ sect = 7,
+ pbud = 6,
+ indr = 5,
+ _,
+ },
+ pext: bool,
+ /// Any non-zero value indicates this is an stab, so the `stab` field should be used.
+ is_stab: u3,
+ },
+ stab: enum(u8) {
+ gsym = N_GSYM,
+ fname = N_FNAME,
+ fun = N_FUN,
+ stsym = N_STSYM,
+ lcsym = N_LCSYM,
+ bnsym = N_BNSYM,
+ ast = N_AST,
+ opt = N_OPT,
+ rsym = N_RSYM,
+ sline = N_SLINE,
+ ensym = N_ENSYM,
+ ssym = N_SSYM,
+ so = N_SO,
+ oso = N_OSO,
+ lsym = N_LSYM,
+ bincl = N_BINCL,
+ sol = N_SOL,
+ params = N_PARAMS,
+ version = N_VERSION,
+ olevel = N_OLEVEL,
+ psym = N_PSYM,
+ eincl = N_EINCL,
+ entry = N_ENTRY,
+ lbrac = N_LBRAC,
+ excl = N_EXCL,
+ rbrac = N_RBRAC,
+ bcomm = N_BCOMM,
+ ecomm = N_ECOMM,
+ ecoml = N_ECOML,
+ leng = N_LENG,
+ _,
+ },
+ },
n_sect: u8,
- n_desc: u16,
+ n_desc: packed struct(u16) {
+ _pad0: u3 = 0,
+ arm_thumb_def: bool,
+ _pad1: u1 = 0,
+ /// The meaning of this bit is contextual.
+ /// See `N_DESC_DISCARDED` and `N_NO_DEAD_STRIP`.
+ discarded_or_no_dead_strip: bool,
+ weak_ref: bool,
+ /// The meaning of this bit is contextual.
+ /// See `N_WEAK_DEF` and `N_REF_TO_WEAK`.
+ weak_def_or_ref_to_weak: bool,
+ symbol_resolver: bool,
+ alt_entry: bool,
+ _pad2: u6 = 0,
+ },
n_value: u64,
+ // MLUGG TODO DELETE
pub fn stab(sym: nlist_64) bool {
- return N_STAB & sym.n_type != 0;
- }
-
- pub fn pext(sym: nlist_64) bool {
- return N_PEXT & sym.n_type != 0;
- }
-
- pub fn ext(sym: nlist_64) bool {
- return N_EXT & sym.n_type != 0;
+ return sym.n_type.bits.is_stab != 0;
}
-
+ // MLUGG TODO DELETE
pub fn sect(sym: nlist_64) bool {
- const type_ = N_TYPE & sym.n_type;
- return type_ == N_SECT;
+ return sym.n_type.type == .sect;
}
-
+ // MLUGG TODO DELETE
pub fn undf(sym: nlist_64) bool {
- const type_ = N_TYPE & sym.n_type;
- return type_ == N_UNDF;
+ return sym.n_type.type == .undf;
}
-
+ // MLUGG TODO DELETE
pub fn indr(sym: nlist_64) bool {
- const type_ = N_TYPE & sym.n_type;
- return type_ == N_INDR;
+ return sym.n_type.type == .indr;
}
-
+ // MLUGG TODO DELETE
pub fn abs(sym: nlist_64) bool {
- const type_ = N_TYPE & sym.n_type;
- return type_ == N_ABS;
+ return sym.n_type.type == .abs;
}
-
+ // MLUGG TODO DELETE
pub fn weakDef(sym: nlist_64) bool {
- return sym.n_desc & N_WEAK_DEF != 0;
+ return sym.n_desc.weak_def_or_ref_to_weak;
}
-
+ // MLUGG TODO DELETE
pub fn weakRef(sym: nlist_64) bool {
- return sym.n_desc & N_WEAK_REF != 0;
+ return sym.n_desc.weak_ref;
}
-
+ // MLUGG TODO DELETE
pub fn discarded(sym: nlist_64) bool {
- return sym.n_desc & N_DESC_DISCARDED != 0;
+ return sym.n_desc.discarded_or_no_dead_strip;
}
-
+ // MLUGG TODO DELETE
pub fn noDeadStrip(sym: nlist_64) bool {
- return sym.n_desc & N_NO_DEAD_STRIP != 0;
+ return sym.n_desc.discarded_or_no_dead_strip;
}
pub fn tentative(sym: nlist_64) bool {
- if (!sym.undf()) return false;
- return sym.n_value != 0;
+ return sym.n_type.type == .undf and sym.n_value != 0;
}
};
@@ -2046,7 +2096,7 @@ pub const unwind_info_compressed_second_level_page_header = extern struct {
// encodings array
};
-pub const UnwindInfoCompressedEntry = packed struct {
+pub const UnwindInfoCompressedEntry = packed struct(u32) {
funcOffset: u24,
encodingIndex: u8,
};