| ... | ... | @@ -647,6 +647,32 @@ pub const nlist_64 = extern struct { |
| 647 | 647 | n_value: u64, |
| 648 | 648 | }; |
| 649 | 649 | |
| 650 | /// Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD |
| 651 | /// format. The modifications from the original format were changing the value |
| 652 | /// of the r_symbolnum field for "local" (r_extern == 0) relocation entries. |
| 653 | /// This modification is required to support symbols in an arbitrary number of |
| 654 | /// sections not just the three sections (text, data and bss) in a 4.3BSD file. |
| 655 | /// Also the last 4 bits have had the r_type tag added to them. |
| 656 | pub const relocation_info = packed struct { |
| 657 | /// offset in the section to what is being relocated |
| 658 | r_address: i32, |
| 659 | |
| 660 | /// symbol index if r_extern == 1 or section ordinal if r_extern == 0 |
| 661 | r_symbolnum: u24, |
| 662 | |
| 663 | /// was relocated pc relative already |
| 664 | r_pcrel: u1, |
| 665 | |
| 666 | /// 0=byte, 1=word, 2=long, 3=quad |
| 667 | r_length: u2, |
| 668 | |
| 669 | /// does not include value of sym referenced |
| 670 | r_extern: u1, |
| 671 | |
| 672 | /// if not 0, machine specific relocation type |
| 673 | r_type: u4, |
| 674 | }; |
| 675 | |
| 650 | 676 | /// After MacOS X 10.1 when a new load command is added that is required to be |
| 651 | 677 | /// understood by the dynamic linker for the image to execute properly the |
| 652 | 678 | /// LC_REQ_DYLD bit will be or'ed into the load command constant. If the dynamic |
| ... | ... | @@ -1086,13 +1112,58 @@ pub const N_ECOML = 0xe8; |
| 1086 | 1112 | /// second stab entry with length information |
| 1087 | 1113 | pub const N_LENG = 0xfe; |
| 1088 | 1114 | |
| 1089 | | /// If a segment contains any sections marked with S_ATTR_DEBUG then all |
| 1090 | | /// sections in that segment must have this attribute. No section other than |
| 1091 | | /// a section marked with this attribute may reference the contents of this |
| 1092 | | /// section. A section with this attribute may contain no symbols and must have |
| 1093 | | /// a section type S_REGULAR. The static linker will not copy section contents |
| 1094 | | /// from sections with this attribute into its output file. These sections |
| 1095 | | /// generally contain DWARF debugging info. |
| 1115 | // For the two types of symbol pointers sections and the symbol stubs section |
| 1116 | // they have indirect symbol table entries. For each of the entries in the |
| 1117 | // section the indirect symbol table entries, in corresponding order in the |
| 1118 | // indirect symbol table, start at the index stored in the reserved1 field |
| 1119 | // of the section structure. Since the indirect symbol table entries |
| 1120 | // correspond to the entries in the section the number of indirect symbol table |
| 1121 | // entries is inferred from the size of the section divided by the size of the |
| 1122 | // entries in the section. For symbol pointers sections the size of the entries |
| 1123 | // in the section is 4 bytes and for symbol stubs sections the byte size of the |
| 1124 | // stubs is stored in the reserved2 field of the section structure. |
| 1125 | |
| 1126 | /// section with only non-lazy symbol pointers |
| 1127 | pub const S_NON_LAZY_SYMBOL_POINTERS = 0x6; |
| 1128 | |
| 1129 | /// section with only lazy symbol pointers |
| 1130 | pub const S_LAZY_SYMBOL_POINTERS = 0x7; |
| 1131 | |
| 1132 | /// section with only symbol stubs, byte size of stub in the reserved2 field |
| 1133 | pub const S_SYMBOL_STUBS = 0x8; |
| 1134 | |
| 1135 | /// section with only function pointers for initialization |
| 1136 | pub const S_MOD_INIT_FUNC_POINTERS = 0x9; |
| 1137 | |
| 1138 | /// section with only function pointers for termination |
| 1139 | pub const S_MOD_TERM_FUNC_POINTERS = 0xa; |
| 1140 | |
| 1141 | /// section contains symbols that are to be coalesced |
| 1142 | pub const S_COALESCED = 0xb; |
| 1143 | |
| 1144 | /// zero fill on demand section (that can be larger than 4 gigabytes) |
| 1145 | pub const S_GB_ZEROFILL = 0xc; |
| 1146 | |
| 1147 | /// section with only pairs of function pointers for interposing |
| 1148 | pub const S_INTERPOSING = 0xd; |
| 1149 | |
| 1150 | /// section with only 16 byte literals |
| 1151 | pub const S_16BYTE_LITERALS = 0xe; |
| 1152 | |
| 1153 | /// section contains DTrace Object Format |
| 1154 | pub const S_DTRACE_DOF = 0xf; |
| 1155 | |
| 1156 | /// section with only lazy symbol pointers to lazy loaded dylibs |
| 1157 | pub const S_LAZY_DYLIB_SYMBOL_POINTERS = 0x10; |
| 1158 | |
| 1159 | // If a segment contains any sections marked with S_ATTR_DEBUG then all |
| 1160 | // sections in that segment must have this attribute. No section other than |
| 1161 | // a section marked with this attribute may reference the contents of this |
| 1162 | // section. A section with this attribute may contain no symbols and must have |
| 1163 | // a section type S_REGULAR. The static linker will not copy section contents |
| 1164 | // from sections with this attribute into its output file. These sections |
| 1165 | // generally contain DWARF debugging info. |
| 1166 | |
| 1096 | 1167 | /// a debug section |
| 1097 | 1168 | pub const S_ATTR_DEBUG = 0x02000000; |
| 1098 | 1169 | |
| ... | ... | @@ -1154,3 +1225,35 @@ pub const VM_PROT_WRITE: vm_prot_t = 0x2; |
| 1154 | 1225 | |
| 1155 | 1226 | /// VM execute permission |
| 1156 | 1227 | pub const VM_PROT_EXECUTE: vm_prot_t = 0x4; |
| 1228 | |
| 1229 | pub const reloc_type_x86_64 = packed enum(u4) { |
| 1230 | /// for absolute addresses |
| 1231 | X86_64_RELOC_UNSIGNED = 0, |
| 1232 | |
| 1233 | /// for signed 32-bit displacement |
| 1234 | X86_64_RELOC_SIGNED, |
| 1235 | |
| 1236 | /// a CALL/JMP instruction with 32-bit displacement |
| 1237 | X86_64_RELOC_BRANCH, |
| 1238 | |
| 1239 | /// a MOVQ load of a GOT entry |
| 1240 | X86_64_RELOC_GOT_LOAD, |
| 1241 | |
| 1242 | /// other GOT references |
| 1243 | X86_64_RELOC_GOT, |
| 1244 | |
| 1245 | /// must be followed by a X86_64_RELOC_UNSIGNED |
| 1246 | X86_64_RELOC_SUBTRACTOR, |
| 1247 | |
| 1248 | /// for signed 32-bit displacement with a -1 addend |
| 1249 | X86_64_RELOC_SIGNED_1, |
| 1250 | |
| 1251 | /// for signed 32-bit displacement with a -2 addend |
| 1252 | X86_64_RELOC_SIGNED_2, |
| 1253 | |
| 1254 | /// for signed 32-bit displacement with a -4 addend |
| 1255 | X86_64_RELOC_SIGNED_4, |
| 1256 | |
| 1257 | /// for thread local variables |
| 1258 | X86_64_RELOC_TLV, |
| 1259 | }; |