summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdw/ChangeLog11
-rw-r--r--libdw/dwarf_begin_elf.c1
-rw-r--r--libdw/dwarf_getmacros.c1
-rw-r--r--libdw/libdwP.h4
-rw-r--r--libdw/libdw_findcu.c5
5 files changed, 19 insertions, 3 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 62a96f36..cf9eed5a 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,14 @@
+2017-12-20 Mark Wielaard <[email protected]>
+
+ * libdwP.h (struct Dwarf_CU): Add sec_idx field.
+ (cu_sec_idx): Return cu->sec_idx.
+ * libdw_findcu.c (__libdw_intern_next_unit): Set cu sec_idx to
+ IDX_debug_info or IDX_debug_types.
+ * dwarf_begin_elf.c (valid_p): Set fake_loc_cu->sec_idx to
+ IDX_debug_loc.
+ * dwarf_getmacros.c (read_macros): Set fake_cu->sec_idx to
+ IDX_debug_macro or IDX_debug_macinfo.
+
2017-05-09 Ulf Hermann <[email protected]>
Mark Wielaard <[email protected]>
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index afa15cef..7c3fe103 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -201,6 +201,7 @@ valid_p (Dwarf *result)
}
else
{
+ result->fake_loc_cu->sec_idx = IDX_debug_loc;
result->fake_loc_cu->dbg = result;
result->fake_loc_cu->startp
= result->sectiondata[IDX_debug_loc]->d_buf;
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
index db6582b6..c456051c 100644
--- a/libdw/dwarf_getmacros.c
+++ b/libdw/dwarf_getmacros.c
@@ -360,6 +360,7 @@ read_macros (Dwarf *dbg, int sec_index,
Version 4 for the old GNU extension, version 5 for DWARF5. */
Dwarf_CU fake_cu = {
.dbg = dbg,
+ .sec_idx = sec_index,
.version = table->version,
.offset_size = table->is_64bit ? 8 : 4,
.startp = (void *) startp + offset,
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index a2fb0c8a..82b47d09 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -293,6 +293,8 @@ struct Dwarf_CU
uint8_t offset_size;
uint16_t version;
+ size_t sec_idx; /* Normally .debug_info, could be .debug_type or "fake". */
+
/* Zero if this is a normal CU. Nonzero if it is a type unit. */
size_t type_offset;
uint64_t type_sig8;
@@ -716,7 +718,7 @@ __libdw_read_offset (Dwarf *dbg, Dwarf *dbg_ret,
static inline size_t
cu_sec_idx (struct Dwarf_CU *cu)
{
- return cu->type_offset == 0 ? IDX_debug_info : IDX_debug_types;
+ return cu->sec_idx;
}
static inline bool
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index 082307b0..4e025e26 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -93,8 +93,8 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
}
/* Invalid or truncated debug section data? */
- Elf_Data *data = dbg->sectiondata[debug_types
- ? IDX_debug_types : IDX_debug_info];
+ size_t sec_idx = debug_types ? IDX_debug_types : IDX_debug_info;
+ Elf_Data *data = dbg->sectiondata[sec_idx];
if (unlikely (*offsetp > data->d_size))
*offsetp = data->d_size;
@@ -102,6 +102,7 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
struct Dwarf_CU *newp = libdw_typed_alloc (dbg, struct Dwarf_CU);
newp->dbg = dbg;
+ newp->sec_idx = sec_idx;
newp->start = oldoff;
newp->end = *offsetp;
newp->address_size = address_size;