diff --git a/src/common/dwarf/elf_reader.cc b/src/common/dwarf/elf_reader.cc index 4f8b6030..5fd1cfb9 100644 --- a/src/common/dwarf/elf_reader.cc +++ b/src/common/dwarf/elf_reader.cc @@ -183,7 +183,7 @@ class Elf64 { template class ElfSectionReader { public: - ElfSectionReader(const char* name, const string& path, int fd, + ElfSectionReader(const char* cname, const string& path, int fd, const typename ElfArch::Shdr& section_header) : contents_aligned_(NULL), contents_(NULL), @@ -198,8 +198,8 @@ class ElfSectionReader { if (header_.sh_type == SHT_NOBITS || header_.sh_size == 0) return; // extra sh_type check for string table. - if ((std::strcmp(name, ".strtab") == 0 || - std::strcmp(name, ".shstrtab") == 0) && + std::string_view name{cname}; + if ((name == ".strtab" || name == ".shstrtab") && header_.sh_type != SHT_STRTAB) { fprintf(stderr, "Invalid sh_type for string table section: expected " @@ -215,7 +215,7 @@ class ElfSectionReader { (header_.sh_offset - offset_aligned); // Check for and handle any compressed contents. - //if (strncmp(name, ".zdebug_", strlen(".zdebug_")) == 0) + //if (name == ".zdebug_") // DecompressZlibContents(); // TODO(saugustine): Add support for proposed elf-section flag // "SHF_COMPRESS". diff --git a/src/common/linux/dump_symbols_unittest.cc b/src/common/linux/dump_symbols_unittest.cc index 4167ccc5..97d5827e 100644 --- a/src/common/linux/dump_symbols_unittest.cc +++ b/src/common/linux/dump_symbols_unittest.cc @@ -91,7 +91,7 @@ TYPED_TEST(DumpSymbols, Invalid) { Elf32_Ehdr header; memset(&header, 0, sizeof(header)); Module* module; - DumpOptions options(ALL_SYMBOL_DATA, true); + DumpOptions options(ALL_SYMBOL_DATA, true, false); EXPECT_FALSE(ReadSymbolDataInternal(reinterpret_cast(&header), "foo", "Linux", @@ -128,7 +128,7 @@ TYPED_TEST(DumpSymbols, SimplePublic) { this->GetElfContents(elf); Module* module; - DumpOptions options(ALL_SYMBOL_DATA, true); + DumpOptions options(ALL_SYMBOL_DATA, true, false); EXPECT_TRUE(ReadSymbolDataInternal(this->elfdata, "foo", "Linux", @@ -185,7 +185,7 @@ TYPED_TEST(DumpSymbols, SimpleBuildID) { this->GetElfContents(elf); Module* module; - DumpOptions options(ALL_SYMBOL_DATA, true); + DumpOptions options(ALL_SYMBOL_DATA, true, false); EXPECT_TRUE(ReadSymbolDataInternal(this->elfdata, "foo", "Linux",