OLD | NEW |
1 /* Mach-O support for BFD. | 1 /* Mach-O support for BFD. |
2 Copyright 2011 | 2 Copyright 2011, 2012 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of BFD, the Binary File Descriptor library. | 5 This file is part of BFD, the Binary File Descriptor library. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
11 | 11 |
12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 }; | 109 }; |
110 #define BFD_MACH_O_LC_SEGMENT_64_SIZE 72 /* Include the header. */ | 110 #define BFD_MACH_O_LC_SEGMENT_64_SIZE 72 /* Include the header. */ |
111 | 111 |
112 struct mach_o_reloc_info_external | 112 struct mach_o_reloc_info_external |
113 { | 113 { |
114 unsigned char r_address[4]; | 114 unsigned char r_address[4]; |
115 unsigned char r_symbolnum[4]; | 115 unsigned char r_symbolnum[4]; |
116 }; | 116 }; |
117 #define BFD_MACH_O_RELENT_SIZE 8 | 117 #define BFD_MACH_O_RELENT_SIZE 8 |
118 | 118 |
| 119 /* Relocations are based on 'address' being a section offset and an assumption |
| 120 that sections are never more than 2^24-1 bytes in size. Relocation data |
| 121 also carry information on type/size/PC-relative/extern and whether scattered |
| 122 or not [stored in the MSB of the r_address]. */ |
| 123 |
| 124 #define BFD_MACH_O_SR_SCATTERED 0x80000000 |
| 125 |
| 126 /* For a non-scattered reloc, the relocation info is found in r_symbolnum. |
| 127 Bytes 1 to 3 contain the symbol number (0xffffff, in a non-scattered PAIR). |
| 128 Byte 4 contains the relocation info - but with differing bit-positions |
| 129 dependent on target endian-ness - as below. */ |
| 130 |
| 131 #define BFD_MACH_O_LE_PCREL 0x01 |
| 132 #define BFD_MACH_O_LE_LENGTH_SHIFT 1 |
| 133 #define BFD_MACH_O_LE_EXTERN 0x08 |
| 134 #define BFD_MACH_O_LE_TYPE_SHIFT 4 |
| 135 |
| 136 #define BFD_MACH_O_BE_PCREL 0x80 |
| 137 #define BFD_MACH_O_BE_LENGTH_SHIFT 5 |
| 138 #define BFD_MACH_O_BE_EXTERN 0x10 |
| 139 #define BFD_MACH_O_BE_TYPE_SHIFT 0 |
| 140 |
| 141 /* The field sizes are the same for both BE and LE. */ |
| 142 #define BFD_MACH_O_LENGTH_MASK 0x03 |
| 143 #define BFD_MACH_O_TYPE_MASK 0x0f |
| 144 |
| 145 /* For a scattered reloc entry the info is contained in r_address. There |
| 146 is no need to discriminate on target endian-ness, since the design was |
| 147 arranged to produce the same layout on both. Scattered relocations are |
| 148 only used for local items, therefore there is no 'extern' field. */ |
| 149 |
| 150 #define BFD_MACH_O_SR_PCREL 0x40000000 |
| 151 #define BFD_MACH_O_GET_SR_LENGTH(s) (((s) >> 28) & 0x3) |
| 152 #define BFD_MACH_O_GET_SR_TYPE(s) (((s) >> 24) & 0x0f) |
| 153 #define BFD_MACH_O_GET_SR_ADDRESS(s) ((s) & 0x00ffffff) |
| 154 #define BFD_MACH_O_SET_SR_LENGTH(l) (((l) & 0x3) << 28) |
| 155 #define BFD_MACH_O_SET_SR_TYPE(t) (((t) & 0xf) << 24) |
| 156 #define BFD_MACH_O_SET_SR_ADDRESS(s) ((s) & 0x00ffffff) |
| 157 |
119 struct mach_o_symtab_command_external | 158 struct mach_o_symtab_command_external |
120 { | 159 { |
121 unsigned char symoff[4]; | 160 unsigned char symoff[4];» /* File offset of the symbol table. */ |
122 unsigned char nsyms[4]; | 161 unsigned char nsyms[4];» /* Number of symbols. */ |
123 unsigned char stroff[4]; | 162 unsigned char stroff[4];» /* File offset of the string table. */ |
124 unsigned char strsize[4]; | 163 unsigned char strsize[4];» /* String table size. */ |
125 }; | 164 }; |
126 | 165 |
127 struct mach_o_nlist_external | 166 struct mach_o_nlist_external |
128 { | 167 { |
129 unsigned char n_strx[4]; | 168 unsigned char n_strx[4]; |
130 unsigned char n_type[1]; | 169 unsigned char n_type[1]; |
131 unsigned char n_sect[1]; | 170 unsigned char n_sect[1]; |
132 unsigned char n_desc[2]; | 171 unsigned char n_desc[2]; |
133 unsigned char n_value[4]; | 172 unsigned char n_value[4]; |
134 }; | 173 }; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 unsigned char export_off[4]; | 287 unsigned char export_off[4]; |
249 unsigned char export_size[4]; | 288 unsigned char export_size[4]; |
250 }; | 289 }; |
251 | 290 |
252 struct mach_o_version_min_command_external | 291 struct mach_o_version_min_command_external |
253 { | 292 { |
254 unsigned char version[4]; | 293 unsigned char version[4]; |
255 unsigned char reserved[4]; | 294 unsigned char reserved[4]; |
256 }; | 295 }; |
257 | 296 |
| 297 struct mach_o_encryption_info_command_external |
| 298 { |
| 299 unsigned char cryptoff[4]; /* File offset of the encrypted area. */ |
| 300 unsigned char cryptsize[4]; /* Size of the encrypted area. */ |
| 301 unsigned char cryptid[4]; /* Encryption method. */ |
| 302 }; |
| 303 |
| 304 struct mach_o_fvmlib_command_external |
| 305 { |
| 306 unsigned char name[4]; /* Offset of the name. */ |
| 307 unsigned char minor_version[4]; |
| 308 unsigned char header_addr[4]; |
| 309 }; |
| 310 |
258 struct mach_o_fat_header_external | 311 struct mach_o_fat_header_external |
259 { | 312 { |
260 unsigned char magic[4]; | 313 unsigned char magic[4]; |
261 unsigned char nfat_arch[4]; /* Number of components. */ | 314 unsigned char nfat_arch[4]; /* Number of components. */ |
262 }; | 315 }; |
263 | 316 |
264 struct mach_o_fat_arch_external | 317 struct mach_o_fat_arch_external |
265 { | 318 { |
266 unsigned char cputype[4]; | 319 unsigned char cputype[4]; |
267 unsigned char cpusubtype[4]; | 320 unsigned char cpusubtype[4]; |
268 unsigned char offset[4]; /* File offset of the member. */ | 321 unsigned char offset[4]; /* File offset of the member. */ |
269 unsigned char size[4]; /* Size of the member. */ | 322 unsigned char size[4]; /* Size of the member. */ |
270 unsigned char align[4]; /* Power of 2. */ | 323 unsigned char align[4]; /* Power of 2. */ |
271 }; | 324 }; |
272 | 325 |
273 #endif /* _MACH_O_EXTERNAL_H */ | 326 #endif /* _MACH_O_EXTERNAL_H */ |
OLD | NEW |