diff options
author | Peter Collingbourne <pcc@google.com> | 2017-05-26 09:19:37 -0700 |
---|---|---|
committer | Mark Mentovai <mark@chromium.org> | 2017-05-26 16:43:47 +0000 |
commit | 08bea455d44de8ca287ae0b10b2028fbd8c62619 (patch) | |
tree | b86b24d67c6be860f41fc823b192338797e53b9b /src/common/linux/file_id.cc | |
parent | Make the cross-compilation glue for dump_syms Mac handle x86_64h. (diff) | |
download | breakpad-08bea455d44de8ca287ae0b10b2028fbd8c62619.tar.xz |
Teach the ELF parser to handle multiple PT_NOTE phdrs.
It is legal for an ELF to contain multiple PT_NOTEs, and that is in
fact what lld's output looks like.
Testing: "make check" and breakpad_unittests when patched into
chromium.
Bug: chromium:716484
Change-Id: I01d3f8679961e2cb7e789d4007de8914c6af357d
Reviewed-on: https://chromium-review.googlesource.com/513512
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Reviewed-by: Ted Mielczarek <ted@mielczarek.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/common/linux/file_id.cc')
-rw-r--r-- | src/common/linux/file_id.cc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/common/linux/file_id.cc b/src/common/linux/file_id.cc index 728f0bc8..67921c45 100644 --- a/src/common/linux/file_id.cc +++ b/src/common/linux/file_id.cc @@ -95,18 +95,25 @@ static bool ElfClassBuildIDNoteIdentifier(const void *section, size_t length, // and copy it into |identifier|. static bool FindElfBuildIDNote(const void* elf_mapped_base, wasteful_vector<uint8_t>& identifier) { + PageAllocator allocator; + // lld normally creates 2 PT_NOTEs, gold normally creates 1. + auto_wasteful_vector<ElfSegment, 2> segs(&allocator); + if (FindElfSegments(elf_mapped_base, PT_NOTE, &segs)) { + for (ElfSegment& seg : segs) { + if (ElfClassBuildIDNoteIdentifier(seg.start, seg.size, identifier)) { + return true; + } + } + } + void* note_section; size_t note_size; - if ((!FindElfSegment(elf_mapped_base, PT_NOTE, - (const void**)¬e_section, ¬e_size) || - note_size == 0) && - (!FindElfSection(elf_mapped_base, ".note.gnu.build-id", SHT_NOTE, - (const void**)¬e_section, ¬e_size) || - note_size == 0)) { - return false; + if (FindElfSection(elf_mapped_base, ".note.gnu.build-id", SHT_NOTE, + (const void**)¬e_section, ¬e_size)) { + return ElfClassBuildIDNoteIdentifier(note_section, note_size, identifier); } - return ElfClassBuildIDNoteIdentifier(note_section, note_size, identifier); + return false; } // Attempt to locate the .text section of an ELF binary and generate |