From 9acaa082c824c65cc220e8fa1740d5b748000c60 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Mon, 12 Dec 2022 17:22:04 +0800 Subject: [PATCH] Fix build failures. - Fix a test build failure introduced by https://chromium.googlesource.com/breakpad/breakpad/+/cc7abac08b0c52e6581b9c9c4226816b17a4c26d. - Use strcmp from instead of std::strcmp from . Bug: google-breakpad:867 Change-Id: I8dcbc7d5ac8ea799b4d5287ddbbf5d6626992123 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4095054 Reviewed-by: Mike Frysinger --- src/common/dwarf/elf_reader.cc | 8 ++++---- src/common/linux/dump_symbols_unittest.cc | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) 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",