File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,24 @@ Unit::strx(size_t idx) {
2121 throw Exception () << " no string offsets table, but have strx form" ;
2222 // Get the root die, and the string offset base.
2323 auto base = intmax_t (root ().attribute (DW_AT_str_offsets_base));
24- auto len = dwarfLen;
25- DWARFReader r (dwarf->debugStrOffsets .io (), base + len * idx);
26- return dwarf->debugStrings .io ()->readString (r.getuint (len));
24+ size_t seclen, entrysize;
25+ Elf::Off tableStart;
26+
27+ if (version >= 5 ) {
28+ DWARFReader r (dwarf->debugStrOffsets .io ());
29+ // Version 5 has a header
30+ std::tie ( seclen, entrysize ) = r.getlength ();
31+ [[maybe_unused]] auto version = r.getu16 ();
32+ [[maybe_unused]] auto padding = r.getu16 ();
33+ tableStart = r.getOffset ();
34+ } else {
35+ // Old versions of this table just had 4-byte string offsets, I think.
36+ seclen = std::numeric_limits<Elf::Off>::max ();
37+ entrysize = 4 ;
38+ tableStart = 0 ;
39+ }
40+ DWARFReader r (dwarf->debugStrOffsets .io (), tableStart + base + entrysize * idx);
41+ return dwarf->debugStrings .io ()->readString (r.getuint (entrysize));
2742}
2843
2944uintmax_t
You can’t perform that action at this time.
0 commit comments