Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: snapshot/mac/mach_o_image_reader_test.cc

Issue 901463004: MachOImageSymbolTableReader: permit indirect symbols to exist among external defined symbols (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Be more positive Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | snapshot/mac/mach_o_image_symbol_table_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // Only external defined symbols are considered, other types of symbols are 386 // Only external defined symbols are considered, other types of symbols are
387 // excluded because LookUpExternalDefinedSymbol() only deals with external 387 // excluded because LookUpExternalDefinedSymbol() only deals with external
388 // defined symbols. 388 // defined symbols.
389 void ExpectSymbol(const Nlist* entry, 389 void ExpectSymbol(const Nlist* entry,
390 const char* name, 390 const char* name,
391 const MachOImageReader* actual_image) { 391 const MachOImageReader* actual_image) {
392 SCOPED_TRACE(name); 392 SCOPED_TRACE(name);
393 393
394 uint32_t entry_type = entry->n_type & N_TYPE; 394 uint32_t entry_type = entry->n_type & N_TYPE;
395 if ((entry->n_type & N_STAB) == 0 && (entry->n_type & N_PEXT) == 0 && 395 if ((entry->n_type & N_STAB) == 0 && (entry->n_type & N_PEXT) == 0 &&
396 entry_type != N_UNDF && entry_type != N_PBUD && 396 (entry_type == N_ABS || entry_type == N_SECT) &&
397 (entry->n_type & N_EXT) == 1) { 397 (entry->n_type & N_EXT) == 1) {
398 // Note that this catches more symbols than MachOImageSymbolTableReader
399 // does. This test looks for all external defined symbols, but the
400 // implementation excludes indirect (N_INDR) symbols. This is intentional,
401 // because indirect symbols are currently not seen in the wild, but if they
402 // begin to be used more widely, this test is expected to catch them so that
403 // a decision can be made regarding whether support ought to be implemented.
404 mach_vm_address_t actual_address; 398 mach_vm_address_t actual_address;
405 ASSERT_TRUE( 399 ASSERT_TRUE(
406 actual_image->LookUpExternalDefinedSymbol(name, &actual_address)); 400 actual_image->LookUpExternalDefinedSymbol(name, &actual_address));
407 401
408 // Since the nlist interface was used to read the symbol, use it to compute 402 // Since the nlist interface was used to read the symbol, use it to compute
409 // the symbol address too. This isn’t perfect, and it should be possible in 403 // the symbol address too. This isn’t perfect, and it should be possible in
410 // theory to use dlsym() to get the expected address of a symbol. In 404 // theory to use dlsym() to get the expected address of a symbol. In
411 // practice, dlsym() is difficult to use when only a MachHeader* is 405 // practice, dlsym() is difficult to use when only a MachHeader* is
412 // available as in this function, as opposed to a void* opaque handle. It is 406 // available as in this function, as opposed to a void* opaque handle. It is
413 // possible to get a void* handle by using dladdr() to find the file name 407 // possible to get a void* handle by using dladdr() to find the file name
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 image_reader.UUID(&actual_uuid); 625 image_reader.UUID(&actual_uuid);
632 EXPECT_EQ(expected_uuid, actual_uuid); 626 EXPECT_EQ(expected_uuid, actual_uuid);
633 } 627 }
634 } 628 }
635 #endif 629 #endif
636 } 630 }
637 631
638 } // namespace 632 } // namespace
639 } // namespace test 633 } // namespace test
640 } // namespace crashpad 634 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | snapshot/mac/mach_o_image_symbol_table_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698