| OLD | NEW |
| 1 // Copyright (c) 2010, Google Inc. | 1 // Copyright (c) 2010, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 static const int DT_ANDROID_REL = DT_LOOS + 2; | 63 static const int DT_ANDROID_REL = DT_LOOS + 2; |
| 64 #endif | 64 #endif |
| 65 #ifndef DT_ANDROID_RELA | 65 #ifndef DT_ANDROID_RELA |
| 66 static const int DT_ANDROID_RELA = DT_LOOS + 4; | 66 static const int DT_ANDROID_RELA = DT_LOOS + 4; |
| 67 #endif | 67 #endif |
| 68 | 68 |
| 69 #endif // __ANDROID __ | 69 #endif // __ANDROID __ |
| 70 | 70 |
| 71 static const char kMappedFileUnsafePrefix[] = "/dev/"; | 71 static const char kMappedFileUnsafePrefix[] = "/dev/"; |
| 72 static const char kDeletedSuffix[] = " (deleted)"; | 72 static const char kDeletedSuffix[] = " (deleted)"; |
| 73 static const char kReservedFlags[] = " ---p"; | |
| 74 | 73 |
| 75 inline static bool IsMappedFileOpenUnsafe( | 74 inline static bool IsMappedFileOpenUnsafe( |
| 76 const google_breakpad::MappingInfo& mapping) { | 75 const google_breakpad::MappingInfo& mapping) { |
| 77 // It is unsafe to attempt to open a mapped file that lives under /dev, | 76 // It is unsafe to attempt to open a mapped file that lives under /dev, |
| 78 // because the semantics of the open may be driver-specific so we'd risk | 77 // because the semantics of the open may be driver-specific so we'd risk |
| 79 // hanging the crash dumper. And a file in /dev/ almost certainly has no | 78 // hanging the crash dumper. And a file in /dev/ almost certainly has no |
| 80 // ELF file identifier anyways. | 79 // ELF file identifier anyways. |
| 81 return my_strncmp(mapping.name, | 80 return my_strncmp(mapping.name, |
| 82 kMappedFileUnsafePrefix, | 81 kMappedFileUnsafePrefix, |
| 83 sizeof(kMappedFileUnsafePrefix) - 1) == 0; | 82 sizeof(kMappedFileUnsafePrefix) - 1) == 0; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 MappingInfo* module = mappings_.back(); | 349 MappingInfo* module = mappings_.back(); |
| 351 if ((start_addr == module->start_addr + module->size) && | 350 if ((start_addr == module->start_addr + module->size) && |
| 352 (my_strlen(name) == my_strlen(module->name)) && | 351 (my_strlen(name) == my_strlen(module->name)) && |
| 353 (my_strncmp(name, module->name, my_strlen(name)) == 0) && | 352 (my_strncmp(name, module->name, my_strlen(name)) == 0) && |
| 354 (exec == module->exec)) { | 353 (exec == module->exec)) { |
| 355 module->size = end_addr - module->start_addr; | 354 module->size = end_addr - module->start_addr; |
| 356 line_reader->PopLine(line_len); | 355 line_reader->PopLine(line_len); |
| 357 continue; | 356 continue; |
| 358 } | 357 } |
| 359 } | 358 } |
| 360 // Also merge mappings that result from address ranges that the | |
| 361 // linker reserved but which a loaded library did not use. These | |
| 362 // appear as an anonymous private mapping with no access flags set | |
| 363 // and which directly follow an executable mapping. | |
| 364 if (!name && !mappings_.empty()) { | |
| 365 MappingInfo* module = mappings_.back(); | |
| 366 if ((start_addr == module->start_addr + module->size) && | |
| 367 module->exec && | |
| 368 module->name[0] == '/' && | |
| 369 offset == 0 && my_strncmp(i2, | |
| 370 kReservedFlags, | |
| 371 sizeof(kReservedFlags) - 1) == 0) { | |
| 372 module->size = end_addr - module->start_addr; | |
| 373 line_reader->PopLine(line_len); | |
| 374 continue; | |
| 375 } | |
| 376 } | |
| 377 MappingInfo* const module = new(allocator_) MappingInfo; | 359 MappingInfo* const module = new(allocator_) MappingInfo; |
| 378 my_memset(module, 0, sizeof(MappingInfo)); | 360 my_memset(module, 0, sizeof(MappingInfo)); |
| 379 module->start_addr = start_addr; | 361 module->start_addr = start_addr; |
| 380 module->size = end_addr - start_addr; | 362 module->size = end_addr - start_addr; |
| 381 module->offset = offset; | 363 module->offset = offset; |
| 382 module->exec = exec; | 364 module->exec = exec; |
| 383 if (name != NULL) { | 365 if (name != NULL) { |
| 384 const unsigned l = my_strlen(name); | 366 const unsigned l = my_strlen(name); |
| 385 if (l < sizeof(module->name)) | 367 if (l < sizeof(module->name)) |
| 386 my_memcpy(module->name, name, l); | 368 my_memcpy(module->name, name, l); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 exe_stat.st_dev == new_path_stat.st_dev && | 578 exe_stat.st_dev == new_path_stat.st_dev && |
| 597 exe_stat.st_ino == new_path_stat.st_ino) { | 579 exe_stat.st_ino == new_path_stat.st_ino) { |
| 598 return false; | 580 return false; |
| 599 } | 581 } |
| 600 | 582 |
| 601 my_memcpy(path, exe_link, NAME_MAX); | 583 my_memcpy(path, exe_link, NAME_MAX); |
| 602 return true; | 584 return true; |
| 603 } | 585 } |
| 604 | 586 |
| 605 } // namespace google_breakpad | 587 } // namespace google_breakpad |
| OLD | NEW |