OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006, Google Inc. | |
2 // All rights reserved. | |
3 // | |
4 // Redistribution and use in source and binary forms, with or without | |
5 // modification, are permitted provided that the following conditions are | |
6 // met: | |
7 // | |
8 // * Redistributions of source code must retain the above copyright | |
9 // notice, this list of conditions and the following disclaimer. | |
10 // * Redistributions in binary form must reproduce the above | |
11 // copyright notice, this list of conditions and the following disclaimer | |
12 // in the documentation and/or other materials provided with the | |
13 // distribution. | |
14 // * Neither the name of Google Inc. nor the names of its | |
15 // contributors may be used to endorse or promote products derived from | |
16 // this software without specific prior written permission. | |
17 // | |
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | |
30 // macho_utilities.h: Utilities for dealing with mach-o files | |
31 // | |
32 // Author: Dave Camp | |
33 | |
34 #ifndef COMMON_MAC_MACHO_UTILITIES_H__ | |
35 #define COMMON_MAC_MACHO_UTILITIES_H__ | |
36 | |
37 #include <mach-o/loader.h> | |
38 #include <mach/thread_status.h> | |
39 | |
40 /* Some #defines and structs that aren't defined in older SDKs */ | |
41 #ifndef CPU_ARCH_ABI64 | |
42 # define CPU_ARCH_ABI64 0x01000000 | |
43 #endif | |
44 | |
45 #ifndef CPU_TYPE_X86 | |
46 # define CPU_TYPE_X86 CPU_TYPE_I386 | |
47 #endif | |
48 | |
49 #ifndef CPU_TYPE_POWERPC64 | |
50 # define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64) | |
51 #endif | |
52 | |
53 #ifndef LC_UUID | |
54 # define LC_UUID 0x1b /* the uuid */ | |
55 #endif | |
56 | |
57 #if TARGET_CPU_X86 | |
58 # define BREAKPAD_MACHINE_THREAD_STATE i386_THREAD_STATE | |
59 #else | |
60 # define BREAKPAD_MACHINE_THREAD_STATE MACHINE_THREAD_STATE | |
61 #endif | |
62 | |
63 // The uuid_command struct/swap routines were added during the 10.4 series. | |
64 // Their presence isn't guaranteed. | |
65 struct breakpad_uuid_command { | |
66 uint32_t cmd; /* LC_UUID */ | |
67 uint32_t cmdsize; /* sizeof(struct uuid_command) */ | |
68 uint8_t uuid[16]; /* the 128-bit uuid */ | |
69 }; | |
70 | |
71 void breakpad_swap_uuid_command(struct breakpad_uuid_command *uc, | |
72 enum NXByteOrder target_byte_order); | |
73 | |
74 // Older SDKs defines thread_state_data_t as an int[] instead | |
75 // of the natural_t[] it should be. | |
76 typedef natural_t breakpad_thread_state_data_t[THREAD_STATE_MAX]; | |
77 | |
78 // The 64-bit swap routines were added during the 10.4 series, their | |
79 // presence isn't guaranteed. | |
80 void breakpad_swap_segment_command_64(struct segment_command_64 *sg, | |
81 enum NXByteOrder target_byte_order); | |
82 | |
83 void breakpad_swap_mach_header_64(struct mach_header_64 *mh, | |
84 enum NXByteOrder target_byte_order); | |
85 | |
86 void breakpad_swap_section_64(struct section_64 *s, | |
87 uint32_t nsects, | |
88 enum NXByteOrder target_byte_order); | |
89 | |
90 #endif | |
OLD | NEW |