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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "util/mac/mach_o_image_symbol_table_reader.h" | 15 #include "snapshot/mac/mach_o_image_symbol_table_reader.h" |
16 | 16 |
17 #include <mach-o/loader.h> | 17 #include <mach-o/loader.h> |
18 #include <mach-o/nlist.h> | 18 #include <mach-o/nlist.h> |
19 | 19 |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
22 #include "util/mac/checked_mach_address_range.h" | 22 #include "util/mac/checked_mach_address_range.h" |
23 #include "util/mach/task_memory.h" | 23 #include "util/mach/task_memory.h" |
24 | 24 |
25 namespace crashpad { | 25 namespace crashpad { |
(...skipping 10 matching lines...) Expand all Loading... |
36 class MachOImageSymbolTableReaderInitializer { | 36 class MachOImageSymbolTableReaderInitializer { |
37 public: | 37 public: |
38 MachOImageSymbolTableReaderInitializer( | 38 MachOImageSymbolTableReaderInitializer( |
39 ProcessReader* process_reader, | 39 ProcessReader* process_reader, |
40 const MachOImageSegmentReader* linkedit_segment, | 40 const MachOImageSegmentReader* linkedit_segment, |
41 const std::string& module_info) | 41 const std::string& module_info) |
42 : module_info_(module_info), | 42 : module_info_(module_info), |
43 linkedit_range_(), | 43 linkedit_range_(), |
44 process_reader_(process_reader), | 44 process_reader_(process_reader), |
45 linkedit_segment_(linkedit_segment) { | 45 linkedit_segment_(linkedit_segment) { |
46 linkedit_range_.SetRange( | 46 linkedit_range_.SetRange(process_reader_->Is64Bit(), |
47 process_reader_, linkedit_segment->Address(), linkedit_segment->Size()); | 47 linkedit_segment->Address(), |
| 48 linkedit_segment->Size()); |
48 DCHECK(linkedit_range_.IsValid()); | 49 DCHECK(linkedit_range_.IsValid()); |
49 } | 50 } |
50 | 51 |
51 ~MachOImageSymbolTableReaderInitializer() {} | 52 ~MachOImageSymbolTableReaderInitializer() {} |
52 | 53 |
53 //! \brief Reads the symbol table from another process. | 54 //! \brief Reads the symbol table from another process. |
54 //! | 55 //! |
55 //! \sa MachOImageSymbolTableReader::Initialize() | 56 //! \sa MachOImageSymbolTableReader::Initialize() |
56 bool Initialize(const process_types::symtab_command* symtab_command, | 57 bool Initialize(const process_types::symtab_command* symtab_command, |
57 const process_types::dysymtab_command* dysymtab_command, | 58 const process_types::dysymtab_command* dysymtab_command, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 //! \param[in] tag A string that identifies the range being checked. This is | 192 //! \param[in] tag A string that identifies the range being checked. This is |
192 //! used only for logging. | 193 //! used only for logging. |
193 //! | 194 //! |
194 //! \return `true` if the range identified by \a address + \a size lies | 195 //! \return `true` if the range identified by \a address + \a size lies |
195 //! entirely within the `__LINKEDIT` segment. `false` if that range is | 196 //! entirely within the `__LINKEDIT` segment. `false` if that range is |
196 //! invalid, or if that range is not contained by the `__LINKEDIT` | 197 //! invalid, or if that range is not contained by the `__LINKEDIT` |
197 //! segment, with an appropriate message logged. | 198 //! segment, with an appropriate message logged. |
198 bool IsInLinkEditSegment(mach_vm_address_t address, | 199 bool IsInLinkEditSegment(mach_vm_address_t address, |
199 mach_vm_size_t size, | 200 mach_vm_size_t size, |
200 const char* tag) const { | 201 const char* tag) const { |
201 CheckedMachAddressRange subrange(process_reader_, address, size); | 202 CheckedMachAddressRange subrange(process_reader_->Is64Bit(), address, size); |
202 if (!subrange.IsValid()) { | 203 if (!subrange.IsValid()) { |
203 LOG(WARNING) << base::StringPrintf("invalid %s range (0x%llx + 0x%llx)", | 204 LOG(WARNING) << base::StringPrintf("invalid %s range (0x%llx + 0x%llx)", |
204 tag, | 205 tag, |
205 address, | 206 address, |
206 size) << module_info_; | 207 size) << module_info_; |
207 return false; | 208 return false; |
208 } | 209 } |
209 | 210 |
210 if (!linkedit_range_.ContainsRange(subrange)) { | 211 if (!linkedit_range_.ContainsRange(subrange)) { |
211 LOG(WARNING) << base::StringPrintf( | 212 LOG(WARNING) << base::StringPrintf( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 266 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
266 | 267 |
267 const auto& iterator = external_defined_symbols_.find(name); | 268 const auto& iterator = external_defined_symbols_.find(name); |
268 if (iterator == external_defined_symbols_.end()) { | 269 if (iterator == external_defined_symbols_.end()) { |
269 return nullptr; | 270 return nullptr; |
270 } | 271 } |
271 return &iterator->second; | 272 return &iterator->second; |
272 } | 273 } |
273 | 274 |
274 } // namespace crashpad | 275 } // namespace crashpad |
OLD | NEW |