aboutsummaryrefslogtreecommitdiff
path: root/lib/std/macho.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-11-30 13:59:33 +0100
committerJakub Konka <kubkon@jakubkonka.com>2021-11-30 13:59:33 +0100
commit86fe47235eafc03ee4808f8c8b34b7903b816023 (patch)
treeaff3e2796aab4c01c2bc6d7871e21289c38cb6e4 /lib/std/macho.zig
parent2873e19366400b2f11d3a99b10ea17e4f06c6b4b (diff)
downloadzig-86fe47235eafc03ee4808f8c8b34b7903b816023.tar.gz
zig-86fe47235eafc03ee4808f8c8b34b7903b816023.zip
macho: move nlist_64 type/flags helpers to std.macho
Diffstat (limited to 'lib/std/macho.zig')
-rw-r--r--lib/std/macho.zig49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/std/macho.zig b/lib/std/macho.zig
index b4d7964b5e..dce6d10cd5 100644
--- a/lib/std/macho.zig
+++ b/lib/std/macho.zig
@@ -744,6 +744,55 @@ pub const nlist_64 = extern struct {
n_sect: u8,
n_desc: u16,
n_value: u64,
+
+ 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;
+ }
+
+ pub fn sect(sym: nlist_64) bool {
+ const type_ = N_TYPE & sym.n_type;
+ return type_ == N_SECT;
+ }
+
+ pub fn undf(sym: nlist_64) bool {
+ const type_ = N_TYPE & sym.n_type;
+ return type_ == N_UNDF;
+ }
+
+ pub fn indr(sym: nlist_64) bool {
+ const type_ = N_TYPE & sym.n_type;
+ return type_ == N_INDR;
+ }
+
+ pub fn abs(sym: nlist_64) bool {
+ const type_ = N_TYPE & sym.n_type;
+ return type_ == N_ABS;
+ }
+
+ pub fn weakDef(sym: nlist_64) bool {
+ return (sym.n_desc & N_WEAK_DEF) != 0;
+ }
+
+ pub fn weakRef(sym: nlist_64) bool {
+ return (sym.n_desc & N_WEAK_REF) != 0;
+ }
+
+ pub fn discarded(sym: nlist_64) bool {
+ return (sym.n_desc & N_DESC_DISCARDED) != 0;
+ }
+
+ pub fn tentative(sym: nlist_64) bool {
+ if (!sym.undf()) return false;
+ return sym.n_value != 0;
+ }
};
/// Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD