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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return §ions_[iterator->second]; | 187 return §ions_[iterator->second]; |
188 } | 188 } |
189 | 189 |
190 const process_types::section* MachOImageSegmentReader::GetSectionAtIndex( | 190 const process_types::section* MachOImageSegmentReader::GetSectionAtIndex( |
191 size_t index) const { | 191 size_t index) const { |
192 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 192 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
193 CHECK_LT(index, sections_.size()); | 193 CHECK_LT(index, sections_.size()); |
194 return §ions_[index]; | 194 return §ions_[index]; |
195 } | 195 } |
196 | 196 |
| 197 bool MachOImageSegmentReader::SegmentSlides() const { |
| 198 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 199 |
| 200 // These are the same rules that the kernel uses to identify __PAGEZERO. See |
| 201 // 10.9.4 xnu-2422.110.17/bsd/kern/mach_loader.c load_segment(). |
| 202 return !(segment_command_.vmaddr == 0 && segment_command_.filesize == 0 && |
| 203 segment_command_.vmsize != 0 && |
| 204 (segment_command_.initprot & VM_PROT_ALL) == VM_PROT_NONE && |
| 205 (segment_command_.maxprot & VM_PROT_ALL) == VM_PROT_NONE); |
| 206 } |
| 207 |
197 // static | 208 // static |
198 std::string MachOImageSegmentReader::SegmentNameString( | 209 std::string MachOImageSegmentReader::SegmentNameString( |
199 const char* segment_name_c) { | 210 const char* segment_name_c) { |
200 // This is used to interpret the segname field of both the segment_command and | 211 // This is used to interpret the segname field of both the segment_command and |
201 // section structures, so be sure that they’re identical. | 212 // section structures, so be sure that they’re identical. |
202 COMPILE_ASSERT(sizeof(process_types::segment_command::segname) == | 213 COMPILE_ASSERT(sizeof(process_types::segment_command::segname) == |
203 sizeof(process_types::section::segname), | 214 sizeof(process_types::section::segname), |
204 sizes_must_be_equal); | 215 sizes_must_be_equal); |
205 | 216 |
206 return SizeLimitedCString(segment_name_c, | 217 return SizeLimitedCString(segment_name_c, |
(...skipping 14 matching lines...) Expand all Loading... |
221 return base::StringPrintf("%s,%s", | 232 return base::StringPrintf("%s,%s", |
222 SegmentNameString(segment_name_c).c_str(), | 233 SegmentNameString(segment_name_c).c_str(), |
223 SectionNameString(section_name_c).c_str()); | 234 SectionNameString(section_name_c).c_str()); |
224 } | 235 } |
225 | 236 |
226 std::string MachOImageSegmentReader::NameInternal() const { | 237 std::string MachOImageSegmentReader::NameInternal() const { |
227 return SegmentNameString(segment_command_.segname); | 238 return SegmentNameString(segment_command_.segname); |
228 } | 239 } |
229 | 240 |
230 } // namespace crashpad | 241 } // namespace crashpad |
OLD | NEW |