authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-12-06 10:45:14+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-12-06 22:25:44+01:00
log79316ee10bcee1dcc6ed966fd405699ce51155d4
tree8d1067d5157b2e23703c3e7ee02f57a14754e1df
parent559e216f3fd86329c29e9f8ff70e0d00b1e903b9

lib/std/macho: add missing LC defs and missing N_NO_DEAD_STRIP desc for nlists


1 files changed, 27 insertions(+), 12 deletions(-)

lib/std/macho.zig+27-12
...@@ -843,15 +843,15 @@ pub const nlist_64 = extern struct {...@@ -843,15 +843,15 @@ pub const nlist_64 = extern struct {
843 n_value: u64,843 n_value: u64,
844844
845 pub fn stab(sym: nlist_64) bool {845 pub fn stab(sym: nlist_64) bool {
846 return (N_STAB & sym.n_type) != 0;846 return N_STAB & sym.n_type != 0;
847 }847 }
848848
849 pub fn pext(sym: nlist_64) bool {849 pub fn pext(sym: nlist_64) bool {
850 return (N_PEXT & sym.n_type) != 0;850 return N_PEXT & sym.n_type != 0;
851 }851 }
852852
853 pub fn ext(sym: nlist_64) bool {853 pub fn ext(sym: nlist_64) bool {
854 return (N_EXT & sym.n_type) != 0;854 return N_EXT & sym.n_type != 0;
855 }855 }
856856
857 pub fn sect(sym: nlist_64) bool {857 pub fn sect(sym: nlist_64) bool {
...@@ -875,15 +875,19 @@ pub const nlist_64 = extern struct {...@@ -875,15 +875,19 @@ pub const nlist_64 = extern struct {
875 }875 }
876876
877 pub fn weakDef(sym: nlist_64) bool {877 pub fn weakDef(sym: nlist_64) bool {
878 return (sym.n_desc & N_WEAK_DEF) != 0;878 return sym.n_desc & N_WEAK_DEF != 0;
879 }879 }
880880
881 pub fn weakRef(sym: nlist_64) bool {881 pub fn weakRef(sym: nlist_64) bool {
882 return (sym.n_desc & N_WEAK_REF) != 0;882 return sym.n_desc & N_WEAK_REF != 0;
883 }883 }
884884
885 pub fn discarded(sym: nlist_64) bool {885 pub fn discarded(sym: nlist_64) bool {
886 return (sym.n_desc & N_DESC_DISCARDED) != 0;886 return sym.n_desc & N_DESC_DISCARDED != 0;
887 }
888
889 pub fn noDeadStrip(sym: nlist_64) bool {
890 return sym.n_desc & N_NO_DEAD_STRIP != 0;
887 }891 }
888892
889 pub fn tentative(sym: nlist_64) bool {893 pub fn tentative(sym: nlist_64) bool {
...@@ -1002,7 +1006,7 @@ pub const LC = enum(u32) {...@@ -1002,7 +1006,7 @@ pub const LC = enum(u32) {
10021006
1003 /// load a dynamically linked shared library that is allowed to be missing1007 /// load a dynamically linked shared library that is allowed to be missing
1004 /// (all symbols are weak imported).1008 /// (all symbols are weak imported).
1005 LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD),1009 LOAD_WEAK_DYLIB = 0x18 | LC_REQ_DYLD,
10061010
1007 /// 64-bit segment of this file to be mapped1011 /// 64-bit segment of this file to be mapped
1008 SEGMENT_64 = 0x19,1012 SEGMENT_64 = 0x19,
...@@ -1014,7 +1018,7 @@ pub const LC = enum(u32) {...@@ -1014,7 +1018,7 @@ pub const LC = enum(u32) {
1014 UUID = 0x1b,1018 UUID = 0x1b,
10151019
1016 /// runpath additions1020 /// runpath additions
1017 RPATH = (0x1c | LC_REQ_DYLD),1021 RPATH = 0x1c | LC_REQ_DYLD,
10181022
1019 /// local of code signature1023 /// local of code signature
1020 CODE_SIGNATURE = 0x1d,1024 CODE_SIGNATURE = 0x1d,
...@@ -1023,7 +1027,7 @@ pub const LC = enum(u32) {...@@ -1023,7 +1027,7 @@ pub const LC = enum(u32) {
1023 SEGMENT_SPLIT_INFO = 0x1e,1027 SEGMENT_SPLIT_INFO = 0x1e,
10241028
1025 /// load and re-export dylib1029 /// load and re-export dylib
1026 REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD),1030 REEXPORT_DYLIB = 0x1f | LC_REQ_DYLD,
10271031
1028 /// delay load of dylib until first use1032 /// delay load of dylib until first use
1029 LAZY_LOAD_DYLIB = 0x20,1033 LAZY_LOAD_DYLIB = 0x20,
...@@ -1035,10 +1039,10 @@ pub const LC = enum(u32) {...@@ -1035,10 +1039,10 @@ pub const LC = enum(u32) {
1035 DYLD_INFO = 0x22,1039 DYLD_INFO = 0x22,
10361040
1037 /// compressed dyld information only1041 /// compressed dyld information only
1038 DYLD_INFO_ONLY = (0x22 | LC_REQ_DYLD),1042 DYLD_INFO_ONLY = 0x22 | LC_REQ_DYLD,
10391043
1040 /// load upward dylib1044 /// load upward dylib
1041 LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD),1045 LOAD_UPWARD_DYLIB = 0x23 | LC_REQ_DYLD,
10421046
1043 /// build for MacOSX min OS version1047 /// build for MacOSX min OS version
1044 VERSION_MIN_MACOSX = 0x24,1048 VERSION_MIN_MACOSX = 0x24,
...@@ -1053,7 +1057,7 @@ pub const LC = enum(u32) {...@@ -1053,7 +1057,7 @@ pub const LC = enum(u32) {
1053 DYLD_ENVIRONMENT = 0x27,1057 DYLD_ENVIRONMENT = 0x27,
10541058
1055 /// replacement for LC_UNIXTHREAD1059 /// replacement for LC_UNIXTHREAD
1056 MAIN = (0x28 | LC_REQ_DYLD),1060 MAIN = 0x28 | LC_REQ_DYLD,
10571061
1058 /// table of non-instructions in __text1062 /// table of non-instructions in __text
1059 DATA_IN_CODE = 0x29,1063 DATA_IN_CODE = 0x29,
...@@ -1085,6 +1089,12 @@ pub const LC = enum(u32) {...@@ -1085,6 +1089,12 @@ pub const LC = enum(u32) {
1085 /// build for platform min OS version1089 /// build for platform min OS version
1086 BUILD_VERSION = 0x32,1090 BUILD_VERSION = 0x32,
10871091
1092 /// used with linkedit_data_command, payload is trie
1093 DYLD_EXPORTS_TRIE = 0x33 | LC_REQ_DYLD,
1094
1095 /// used with linkedit_data_command
1096 DYLD_CHAINED_FIXUPS = 0x34 | LC_REQ_DYLD,
1097
1088 _,1098 _,
1089};1099};
10901100
...@@ -1629,6 +1639,11 @@ pub const REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY: u16 = 5;...@@ -1629,6 +1639,11 @@ pub const REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY: u16 = 5;
1629/// to avoid removing symbols that must exist: If the symbol has this bit set, strip does not strip it.1639/// to avoid removing symbols that must exist: If the symbol has this bit set, strip does not strip it.
1630pub const REFERENCED_DYNAMICALLY: u16 = 0x10;1640pub const REFERENCED_DYNAMICALLY: u16 = 0x10;
16311641
1642/// The N_NO_DEAD_STRIP bit of the n_desc field only ever appears in a
1643/// relocatable .o file (MH_OBJECT filetype). And is used to indicate to the
1644/// static link editor it is never to dead strip the symbol.
1645pub const N_NO_DEAD_STRIP: u16 = 0x20;
1646
1632/// Used by the dynamic linker at runtime. Do not set this bit.1647/// Used by the dynamic linker at runtime. Do not set this bit.
1633pub const N_DESC_DISCARDED: u16 = 0x20;1648pub const N_DESC_DISCARDED: u16 = 0x20;
16341649