OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 using GetSectionDataType = | 66 using GetSectionDataType = |
67 uint8_t*(*)(const MachHeader*, const char*, const char*, unsigned long*); | 67 uint8_t*(*)(const MachHeader*, const char*, const char*, unsigned long*); |
68 using GetSegmentDataType = | 68 using GetSegmentDataType = |
69 uint8_t*(*)(const MachHeader*, const char*, unsigned long*); | 69 uint8_t*(*)(const MachHeader*, const char*, unsigned long*); |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 extern "C" { | 73 extern "C" { |
74 | 74 |
75 // These implementations look up their functions in libmacho at run time. If | 75 // These implementations look up their functions in libmacho at run time. If the |
76 // the system libmacho provides these functions as it normally does on Mac OS X | 76 // system libmacho provides these functions as it normally does on OS X 10.7 and |
77 // 10.7 and later, the system’s versions are used directly. Otherwise, the | 77 // later, the system’s versions are used directly. Otherwise, the versions in |
78 // versions in third_party/apple_cctools are used, which are actually just | 78 // third_party/apple_cctools are used, which are actually just copies of the |
79 // copies of the system’s functions. | 79 // system’s functions. |
80 | 80 |
81 uint8_t* getsectiondata(const MachHeader* mhp, | 81 uint8_t* getsectiondata(const MachHeader* mhp, |
82 const char* segname, | 82 const char* segname, |
83 const char* sectname, | 83 const char* sectname, |
84 unsigned long* size) { | 84 unsigned long* size) { |
85 static GetSectionDataType system_getsectiondata = | 85 static GetSectionDataType system_getsectiondata = |
86 reinterpret_cast<GetSectionDataType>( | 86 reinterpret_cast<GetSectionDataType>( |
87 LookUpSystemLibMachOSymbol("getsectiondata")); | 87 LookUpSystemLibMachOSymbol("getsectiondata")); |
88 if (system_getsectiondata) { | 88 if (system_getsectiondata) { |
89 return system_getsectiondata(mhp, segname, sectname, size); | 89 return system_getsectiondata(mhp, segname, sectname, size); |
90 } | 90 } |
91 return crashpad_getsectiondata(mhp, segname, sectname, size); | 91 return crashpad_getsectiondata(mhp, segname, sectname, size); |
92 } | 92 } |
93 | 93 |
94 uint8_t* getsegmentdata( | 94 uint8_t* getsegmentdata( |
95 const MachHeader* mhp, const char* segname, unsigned long* size) { | 95 const MachHeader* mhp, const char* segname, unsigned long* size) { |
96 static GetSegmentDataType system_getsegmentdata = | 96 static GetSegmentDataType system_getsegmentdata = |
97 reinterpret_cast<GetSegmentDataType>( | 97 reinterpret_cast<GetSegmentDataType>( |
98 LookUpSystemLibMachOSymbol("getsegmentdata")); | 98 LookUpSystemLibMachOSymbol("getsegmentdata")); |
99 if (system_getsegmentdata) { | 99 if (system_getsegmentdata) { |
100 return system_getsegmentdata(mhp, segname, size); | 100 return system_getsegmentdata(mhp, segname, size); |
101 } | 101 } |
102 return crashpad_getsegmentdata(mhp, segname, size); | 102 return crashpad_getsegmentdata(mhp, segname, size); |
103 } | 103 } |
104 | 104 |
105 } // extern "C" | 105 } // extern "C" |
106 | 106 |
107 #endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 | 107 #endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 |
OLD | NEW |