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 "snapshot/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 <utility> |
| 21 |
20 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
21 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
22 #include "util/mac/checked_mach_address_range.h" | 24 #include "util/mac/checked_mach_address_range.h" |
23 #include "util/mach/task_memory.h" | 25 #include "util/mach/task_memory.h" |
24 | 26 |
25 namespace crashpad { | 27 namespace crashpad { |
26 | 28 |
27 namespace internal { | 29 namespace internal { |
28 | 30 |
29 //! \brief The internal implementation for MachOImageSymbolTableReader. | 31 //! \brief The internal implementation for MachOImageSymbolTableReader. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return false; | 148 return false; |
147 } | 149 } |
148 | 150 |
149 if (symbol_type == N_SECT && symbol.n_sect == NO_SECT) { | 151 if (symbol_type == N_SECT && symbol.n_sect == NO_SECT) { |
150 LOG(WARNING) << base::StringPrintf( | 152 LOG(WARNING) << base::StringPrintf( |
151 "N_SECT symbol %s in section NO_SECT", | 153 "N_SECT symbol %s in section NO_SECT", |
152 name.c_str()) << symbol_info; | 154 name.c_str()) << symbol_info; |
153 return false; | 155 return false; |
154 } | 156 } |
155 | 157 |
156 if (external_defined_symbols->count(name)) { | |
157 LOG(WARNING) << "duplicate symbol " << name << symbol_info; | |
158 return false; | |
159 } | |
160 | |
161 MachOImageSymbolTableReader::SymbolInformation this_symbol_info; | 158 MachOImageSymbolTableReader::SymbolInformation this_symbol_info; |
162 this_symbol_info.value = symbol.n_value; | 159 this_symbol_info.value = symbol.n_value; |
163 this_symbol_info.section = symbol.n_sect; | 160 this_symbol_info.section = symbol.n_sect; |
164 (*external_defined_symbols)[name] = this_symbol_info; | 161 if (!external_defined_symbols->insert( |
| 162 std::make_pair(name, this_symbol_info)).second) { |
| 163 LOG(WARNING) << "duplicate symbol " << name << symbol_info; |
| 164 return false; |
| 165 } |
165 } else { | 166 } else { |
166 // External indirect symbols may be found in the portion of the symbol | 167 // External indirect symbols may be found in the portion of the symbol |
167 // table used for external symbols as opposed to indirect symbols when | 168 // table used for external symbols as opposed to indirect symbols when |
168 // the indirect symbols are also external. These can be produced by | 169 // the indirect symbols are also external. These can be produced by |
169 // Xcode 5.1 ld64-236.3/src/ld/LinkEditClassic.hpp | 170 // Xcode 5.1 ld64-236.3/src/ld/LinkEditClassic.hpp |
170 // ld::tool::SymbolTableAtom<>::addGlobal(). Indirect symbols are not | 171 // ld::tool::SymbolTableAtom<>::addGlobal(). Indirect symbols are not |
171 // currently supported by this symbol table reader, so ignore them | 172 // currently supported by this symbol table reader, so ignore them |
172 // without failing or logging a message when encountering them. See | 173 // without failing or logging a message when encountering them. See |
173 // https://groups.google.com/a/chromium.org/d/topic/crashpad-dev/k7QkL
wO71Zo | 174 // https://groups.google.com/a/chromium.org/d/topic/crashpad-dev/k7QkL
wO71Zo |
174 valid_symbol = symbol_type == N_INDR; | 175 valid_symbol = symbol_type == N_INDR; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 283 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
283 | 284 |
284 const auto& iterator = external_defined_symbols_.find(name); | 285 const auto& iterator = external_defined_symbols_.find(name); |
285 if (iterator == external_defined_symbols_.end()) { | 286 if (iterator == external_defined_symbols_.end()) { |
286 return nullptr; | 287 return nullptr; |
287 } | 288 } |
288 return &iterator->second; | 289 return &iterator->second; |
289 } | 290 } |
290 | 291 |
291 } // namespace crashpad | 292 } // namespace crashpad |
OLD | NEW |