Skip to content

Commit

Permalink
addr2info.c: Make it work with --enable-yjit
Browse files Browse the repository at this point in the history
Background: GCC 12 generates DWARF 5 with .debug_rnglists, while rustc
generates DWARF 4 with .debug_ranges.

The previous logic always used .debug_rnglists if there is the section.
However, we need to refer .debug_ranges for DWARF 4.

This change keeps DWARF version of the current compilation unit and use
a proper section depending on the version.
  • Loading branch information
mame committed Dec 22, 2022
1 parent c827d72 commit 78826ad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addr2line.c
Expand Up @@ -863,6 +863,7 @@ enum {
typedef struct {
obj_info_t *obj;
const char *file;
uint8_t current_version;
const char *current_cu;
uint64_t current_low_pc;
const char *debug_line_cu_end;
Expand Down Expand Up @@ -1472,7 +1473,7 @@ ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr)
const char *p;
uint64_t base = ptr->low_pc_set ? ptr->low_pc : reader->current_low_pc;
bool base_valid = true;
if (reader->obj->debug_rnglists.ptr) {
if (reader->current_version >= 5) {
p = reader->obj->debug_rnglists.ptr + ptr->ranges;
for (;;) {
uint8_t rle = read_uint8(&p);
Expand Down Expand Up @@ -1583,6 +1584,7 @@ di_read_cu(DebugInfoReader *reader)
}
reader->cu_end = reader->p + unit_length;
version = read_uint16(&reader->p);
reader->current_version = version;
if (version > 5) {
return -1;
}
Expand Down

0 comments on commit 78826ad

Please sign in to comment.