aboutsummaryrefslogtreecommitdiff
path: root/src/common/dwarf/dwarf2reader.cc
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2020-03-09 23:59:12 +0000
committerMike Frysinger <vapier@chromium.org>2020-03-10 18:29:58 +0000
commitfea1913f297dda42d9f0901bb89f50c49608a5a4 (patch)
treeddebcf0ae8bb50cb2e763dd3020f6509b3c44e1e /src/common/dwarf/dwarf2reader.cc
parentdump_syms: Reintroduce warnings inadvertently removed by 47cd498384fd (diff)
downloadbreakpad-fea1913f297dda42d9f0901bb89f50c49608a5a4.tar.xz
Revert "Add dwarf5 compilation-unit header handling."
This reverts commit dbd454dbe47e584571388fc3533193416bdce67f. Reason for revert: The parent CL is causing breakage on CrOS due to unhandled enums. Before we can revert that, we need to revert this. Bug: google-breakpad:812 Change-Id: I7c2446f3cd8ed9f6411e90dbdd2434bc463b2f6c Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2095798 Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/common/dwarf/dwarf2reader.cc')
-rw-r--r--src/common/dwarf/dwarf2reader.cc84
1 files changed, 14 insertions, 70 deletions
diff --git a/src/common/dwarf/dwarf2reader.cc b/src/common/dwarf/dwarf2reader.cc
index 7b8e043d..3e6a3e89 100644
--- a/src/common/dwarf/dwarf2reader.cc
+++ b/src/common/dwarf/dwarf2reader.cc
@@ -243,51 +243,11 @@ const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start,
return NULL;
}
-// Read the abbreviation offset from a compilation unit header.
-int CompilationUnit::ReadAbbrevOffset(const uint8_t *headerptr) {
- assert(headerptr + reader_->OffsetSize() < buffer_ + buffer_length_);
- header_.abbrev_offset = reader_->ReadOffset(headerptr);
- return reader_->OffsetSize();
-}
-
-// Read the address size from a compilation unit header.
-int CompilationUnit::ReadAddressSize(const uint8_t *headerptr) {
- // Compare against less than or equal because this may be the last
- // section in the file.
- assert(headerptr + 1 <= buffer_ + buffer_length_);
- header_.address_size = reader_->ReadOneByte(headerptr);
- reader_->SetAddressSize(header_.address_size);
- return 1;
-}
-
-// Read the DWO id from a split or skeleton compilation unit header.
-int CompilationUnit::ReadDwoId(const uint8_t *headerptr) {
- assert(headerptr + 8 <= buffer_ + buffer_length_);
- dwo_id_ = reader_->ReadEightBytes(headerptr);
- return 8;
-}
-
-// Read the type signature from a type or split type compilation unit header.
-int CompilationUnit::ReadTypeSignature(const uint8_t *headerptr) {
- assert(headerptr + 8 <= buffer_ + buffer_length_);
- type_signature_ = reader_->ReadEightBytes(headerptr);
- return 8;
-}
-
-// Read the DWO id from a split or skeleton compilation unit header.
-int CompilationUnit::ReadTypeOffset(const uint8_t *headerptr) {
- assert(headerptr + reader_->OffsetSize() < buffer_ + buffer_length_);
- type_offset_ = reader_->ReadOffset(headerptr);
- return reader_->OffsetSize();
-}
-
-
-// Read a DWARF header.
-// The header is variable length in DWARF3 and DWARF4 (and DWARF2 as extended by
+// Read a DWARF2/3 header.
+// The header is variable length in DWARF3 (and DWARF2 as extended by
// most compilers), and consists of an length field, a version number,
// the offset in the .debug_abbrev section for our abbrevs, and an
-// address size. DWARF5 adds a unit_type to distinguish between
-// partial-, full-, skeleton-, split-, and type- compilation units.
+// address size.
void CompilationUnit::ReadHeader() {
const uint8_t *headerptr = buffer_;
size_t initial_length_size;
@@ -302,33 +262,17 @@ void CompilationUnit::ReadHeader() {
header_.version = reader_->ReadTwoBytes(headerptr);
headerptr += 2;
- if (header_.version <= 4) {
- // Older versions of dwarf have a relatively simple structure.
- headerptr += ReadAbbrevOffset(headerptr);
- headerptr += ReadAddressSize(headerptr);
- } else {
- // DWARF5 adds a unit_type field, and various fields based on unit_type.
- assert(headerptr + 1 < buffer_ + buffer_length_);
- int unit_type = reader_->ReadOneByte(headerptr);
- headerptr += 1;
- headerptr += ReadAddressSize(headerptr);
- headerptr += ReadAbbrevOffset(headerptr);
- switch (unit_type) {
- case DW_UT_compile:
- case DW_UT_partial:
- // nothing else to read
- break;
- case DW_UT_skeleton:
- case DW_UT_split_compile:
- headerptr += ReadDwoId(headerptr);;
- break;
- case DW_UT_type:
- case DW_UT_split_type:
- headerptr += ReadTypeSignature(headerptr);;
- headerptr += ReadTypeOffset(headerptr);;
- break;
- }
- }
+ assert(headerptr + reader_->OffsetSize() < buffer_ + buffer_length_);
+ header_.abbrev_offset = reader_->ReadOffset(headerptr);
+ headerptr += reader_->OffsetSize();
+
+ // Compare against less than or equal because this may be the last
+ // section in the file.
+ assert(headerptr + 1 <= buffer_ + buffer_length_);
+ header_.address_size = reader_->ReadOneByte(headerptr);
+ reader_->SetAddressSize(header_.address_size);
+ headerptr += 1;
+
after_header_ = headerptr;
// This check ensures that we don't have to do checking during the