Skip to content

Commit 42a394d

Browse files
committed
stop relying on SHT_PROGBITS elsewhere
1 parent 3efdf26 commit 42a394d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

elf.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ Object::getInterpreter() const
401401
Elf::Object::sptr Object::debugData() const {
402402
if (debugData_ == nullptr) {
403403
#ifdef WITH_LZMA
404-
auto &gnu_debugdata = getSection(".gnu_debugdata", SHT_PROGBITS );
404+
auto &gnu_debugdata = getSection(".gnu_debugdata", SHT_NULL );
405405
if (gnu_debugdata) {
406406
auto reader = make_shared<const LzmaReader>(gnu_debugdata.io());
407407
debugData_ = make_shared<Object>(context, reader, true);
@@ -493,7 +493,7 @@ const Section &
493493
Object::getDebugSection(const string &name, Word type) const
494494
{
495495
const auto &local = getSection(name, type);
496-
if (local && local.shdr.sh_type != SHT_NOBITS)
496+
if (local)
497497
return local;
498498
const Object *debug = getDebug();
499499
if (debug != nullptr)
@@ -610,7 +610,7 @@ Object::getDebug() const
610610
// If that doesn't work, maybe the gnu_debuglink is valid?
611611
if (!debugObject) {
612612
// if we have a debug link, use that to attempt to find the debug file.
613-
const auto &hdr = getSection(".gnu_debuglink", SHT_PROGBITS);
613+
const auto &hdr = getSection(".gnu_debuglink", SHT_NULL);
614614
if (hdr) {
615615
auto link = hdr.io()->readString(0);
616616
auto dir = std::filesystem::path(stringify(*io)).parent_path();

libpstack/elf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class Section {
197197
Shdr shdr;
198198
const Elf::Object *elf;
199199
std::string name;
200-
explicit operator bool() const { return shdr.sh_type != SHT_NULL; }
200+
explicit operator bool() const { return shdr.sh_type != SHT_NULL && shdr.sh_type != SHT_NOBITS; }
201201
Section(const Object *, Off off);
202202
Section() : shdr{}, elf{}, name("null") { }
203203
Section(const Section &) = delete;

0 commit comments

Comments
 (0)