Skip to content

Commit

Permalink
Bug 1593966 - Add minimal support for the DW_FORM_GNU_ref_alt and DW_…
Browse files Browse the repository at this point in the history
…FORM_GNU_strp_alt operand forms in dump_syms r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D51801

--HG--
extra : moz-landing-system : lando
  • Loading branch information
gabrielesvelto committed Nov 5, 2019
1 parent 167a3b6 commit 07eecc7
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# HG changeset patch
# User Gabriele Svelto <[email protected]>
# Date 1572953718 -3600
# Tue Nov 05 12:35:18 2019 +0100
# Node ID 229ab2882283fb1a080486bceda9db729525e78c
# Parent 53ebedebdb63ded40f5f3fef677ccc60fa6deeac
Bug 1593966 - Add minimal support for the DW_FORM_GNU_ref_alt and DW_FORM_GNU_strp_alt operand forms in dump_syms

diff --git a/src/common/dwarf/dwarf2enums.h b/src/common/dwarf/dwarf2enums.h
--- a/src/common/dwarf/dwarf2enums.h
+++ b/src/common/dwarf/dwarf2enums.h
@@ -147,17 +147,22 @@ enum DwarfForm {

// Added in DWARF 4:
DW_FORM_sec_offset = 0x17,
DW_FORM_exprloc = 0x18,
DW_FORM_flag_present = 0x19,
DW_FORM_ref_sig8 = 0x20,
// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
DW_FORM_GNU_addr_index = 0x1f01,
- DW_FORM_GNU_str_index = 0x1f02
+ DW_FORM_GNU_str_index = 0x1f02,
+
+ // Extensions introduced for the dwz compression tool. See
+ // https://fedoraproject.org/wiki/Features/DwarfCompressor
+ DW_FORM_GNU_ref_alt = 0x1f20,
+ DW_FORM_GNU_strp_alt = 0x1f21,
};

// Attribute names and codes
enum DwarfAttribute {
DW_AT_sibling = 0x01,
DW_AT_location = 0x02,
DW_AT_name = 0x03,
DW_AT_ordering = 0x09,
diff --git a/src/common/dwarf/dwarf2reader.cc b/src/common/dwarf/dwarf2reader.cc
--- a/src/common/dwarf/dwarf2reader.cc
+++ b/src/common/dwarf/dwarf2reader.cc
@@ -219,16 +219,21 @@ const uint8_t *CompilationUnit::SkipAttr
assert(header_.version >= 2);
if (header_.version == 2) {
return start + reader_->AddressSize();
} else if (header_.version >= 3) {
return start + reader_->OffsetSize();
}
break;

+ case DW_FORM_GNU_ref_alt:
+ case DW_FORM_GNU_strp_alt:
+ return start + reader_->OffsetSize();
+ break;
+
case DW_FORM_block1:
return start + 1 + reader_->ReadOneByte(start);
case DW_FORM_block2:
return start + 2 + reader_->ReadTwoBytes(start);
case DW_FORM_block4:
return start + 4 + reader_->ReadFourBytes(start);
case DW_FORM_block:
case DW_FORM_exprloc: {
@@ -515,16 +520,24 @@ const uint8_t *CompilationUnit::ProcessA
case DW_FORM_GNU_addr_index: {
uint64 addr_index = reader_->ReadUnsignedLEB128(start, &len);
const uint8_t* addr_ptr =
addr_buffer_ + addr_base_ + addr_index * reader_->AddressSize();
ProcessAttributeUnsigned(dieoffset, attr, form,
reader_->ReadAddress(addr_ptr));
return start + len;
}
+ case DW_FORM_GNU_ref_alt: {
+ // TODO: This effectively ignores attributes stored in alternate object
+ // files. We should process them properly instead.
+ return start + reader_->OffsetSize();
+ }
+ case DW_FORM_GNU_strp_alt: {
+ return start + reader_->OffsetSize();
+ }
}
fprintf(stderr, "Unhandled form type\n");
return NULL;
}

const uint8_t *CompilationUnit::ProcessDIE(uint64 dieoffset,
const uint8_t *start,
const Abbrev& abbrev) {
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ enum DwarfForm {
DW_FORM_ref_sig8 = 0x20,
// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
DW_FORM_GNU_addr_index = 0x1f01,
DW_FORM_GNU_str_index = 0x1f02
DW_FORM_GNU_str_index = 0x1f02,

// Extensions introduced for the dwz compression tool. See
// https://fedoraproject.org/wiki/Features/DwarfCompressor
DW_FORM_GNU_ref_alt = 0x1f20,
DW_FORM_GNU_strp_alt = 0x1f21,
};

// Attribute names and codes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start,
}
break;

case DW_FORM_GNU_ref_alt:
case DW_FORM_GNU_strp_alt:
return start + reader_->OffsetSize();
break;

case DW_FORM_block1:
return start + 1 + reader_->ReadOneByte(start);
case DW_FORM_block2:
Expand Down Expand Up @@ -520,6 +525,14 @@ const uint8_t *CompilationUnit::ProcessAttribute(
reader_->ReadAddress(addr_ptr));
return start + len;
}
case DW_FORM_GNU_ref_alt: {
// TODO: This effectively ignores attributes stored in alternate object
// files. We should process them properly instead.
return start + reader_->OffsetSize();
}
case DW_FORM_GNU_strp_alt: {
return start + reader_->OffsetSize();
}
}
fprintf(stderr, "Unhandled form type\n");
return NULL;
Expand Down

0 comments on commit 07eecc7

Please sign in to comment.