Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated with patches from antoyo and suggested changes from aclements. #79

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dwarf/cursor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ cursor::skip_initial_length()
}
}

void
cursor::skip_unit_type()
{
pos += sizeof(sbyte);
}

section_offset
cursor::offset()
{
Expand Down
19 changes: 15 additions & 4 deletions dwarf/dwarf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,23 @@ compilation_unit::compilation_unit(const dwarf &file, section_offset offset)
cursor sub(subsec);
sub.skip_initial_length();
uhalf version = sub.fixed<uhalf>();
if (version < 2 || version > 4)
(void)version;
if (version > 5)
throw format_error("unknown compilation unit version " + std::to_string(version));
// .debug_abbrev-relative offset of this unit's abbrevs
section_offset debug_abbrev_offset = sub.offset();
ubyte address_size = sub.fixed<ubyte>();
subsec->addr_size = address_size;
section_offset debug_abbrev_offset;
if(version >= 5)
{
sub.skip_unit_type();
ubyte address_size = sub.fixed<ubyte>();
subsec->addr_size = address_size;
debug_abbrev_offset = sub.offset();
}
else {
debug_abbrev_offset = sub.offset();
ubyte address_size = sub.fixed<ubyte>();
subsec->addr_size = address_size;
}

m = make_shared<impl>(file, offset, subsec, debug_abbrev_offset,
sub.get_section_offset());
Expand Down
1 change: 1 addition & 0 deletions dwarf/internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ struct cursor
}

void skip_initial_length();
void skip_unit_type();
void skip_form(DW_FORM form);

cursor &operator+=(section_offset offset)
Expand Down
2 changes: 1 addition & 1 deletion dwarf/line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ line_table::line_table(const shared_ptr<section> &sec, section_offset offset,
m->program_offset = cur.get_section_offset() + header_length;
m->minimum_instruction_length = cur.fixed<ubyte>();
m->maximum_operations_per_instruction = 1;
if (version == 4)
if (version >= 4)
m->maximum_operations_per_instruction = cur.fixed<ubyte>();
if (m->maximum_operations_per_instruction == 0)
throw format_error("maximum_operations_per_instruction cannot"
Expand Down
2 changes: 1 addition & 1 deletion elf/data.hh
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ struct Sym<Elf64, Order>
return (stb)(info >> 4);
}

void set_binding(stb v) const
void set_binding(stb v)
{
info = (info & 0xF) | ((unsigned char)v << 4);
}
Expand Down