aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuliano Procida <gprocida@google.com>2023-11-15 16:32:25 +0000
committerGiuliano Procida <gprocida@google.com>2023-11-20 12:58:30 +0000
commit96a7438ed1c9dce83df05a5e05ec7b02d2af13c6 (patch)
tree8e9479a210f98668be8a7be289c6d8bfa5ec7b0b
parent259c0b7949ed5d5a1001abdb2860fbed14427867 (diff)
downloadstg-96a7438ed1c9dce83df05a5e05ec7b02d2af13c6.tar.gz
ELF reader: no longer emit debug output
This was all unused code. PiperOrigin-RevId: 582686896 Change-Id: I5abb7598f82a1bdfa7f42a769f5bd0f9638add73
-rw-r--r--elf_loader.cc15
-rw-r--r--elf_loader.h3
-rw-r--r--elf_reader.cc27
3 files changed, 7 insertions, 38 deletions
diff --git a/elf_loader.cc b/elf_loader.cc
index 6575b17..82d6b4a 100644
--- a/elf_loader.cc
+++ b/elf_loader.cc
@@ -28,7 +28,6 @@
#include <cstddef>
#include <cstring>
#include <functional>
-#include <iostream>
#include <limits>
#include <ostream>
#include <string>
@@ -254,17 +253,11 @@ std::string_view GetString(Elf* elf, uint32_t section, size_t offset) {
return name;
}
-Elf_Scn* GetSymbolTableSection(Elf* elf, bool is_linux_kernel_binary,
- bool verbose) {
+Elf_Scn* GetSymbolTableSection(Elf* elf, bool is_linux_kernel_binary) {
GElf_Ehdr elf_header;
Check(gelf_getehdr(elf, &elf_header) != nullptr)
<< "could not get ELF header";
- if (verbose) {
- std::cout << "ELF type: " << ElfHeaderTypeToString(elf_header.e_type)
- << '\n';
- }
-
Elf_Scn* symtab = MaybeGetSectionByType(elf, SHT_SYMTAB);
Elf_Scn* dynsym = MaybeGetSectionByType(elf, SHT_DYNSYM);
if (symtab != nullptr && dynsym != nullptr) {
@@ -429,8 +422,8 @@ std::ostream& operator<<(std::ostream& os,
}
}
-ElfLoader::ElfLoader(Elf* elf, bool verbose)
- : verbose_(verbose), elf_(elf) {
+ElfLoader::ElfLoader(Elf* elf)
+ : elf_(elf) {
Check(elf_ != nullptr) << "No ELF was provided";
InitializeElfInformation();
}
@@ -453,7 +446,7 @@ std::string_view ElfLoader::GetBtfRawData() const {
std::vector<SymbolTableEntry> ElfLoader::GetElfSymbols() const {
Elf_Scn* symbol_table_section =
- GetSymbolTableSection(elf_, is_linux_kernel_binary_, verbose_);
+ GetSymbolTableSection(elf_, is_linux_kernel_binary_);
Check(symbol_table_section != nullptr)
<< "failed to find symbol table section";
diff --git a/elf_loader.h b/elf_loader.h
index 2679155..39d9fff 100644
--- a/elf_loader.h
+++ b/elf_loader.h
@@ -75,7 +75,7 @@ std::string_view UnwrapCFISymbolName(std::string_view cfi_name);
class ElfLoader final {
public:
- explicit ElfLoader(Elf* elf, bool verbose = false);
+ explicit ElfLoader(Elf* elf);
std::string_view GetBtfRawData() const;
std::vector<SymbolTableEntry> GetElfSymbols() const;
@@ -89,7 +89,6 @@ class ElfLoader final {
private:
void InitializeElfInformation();
- const bool verbose_;
Elf* elf_;
bool is_linux_kernel_binary_;
bool is_relocatable_;
diff --git a/elf_reader.cc b/elf_reader.cc
index 404474f..b940c6b 100644
--- a/elf_reader.cc
+++ b/elf_reader.cc
@@ -21,9 +21,6 @@
#include <cstddef>
#include <functional>
-#include <iomanip>
-#include <ios>
-#include <iostream>
#include <map>
#include <memory>
#include <optional>
@@ -198,7 +195,7 @@ class Reader {
const std::unique_ptr<Filter>& file_filter, Metrics& metrics)
: graph_(graph),
dwarf_(path),
- elf_(dwarf_.GetElf(), options.Test(ReadOptions::INFO)),
+ elf_(dwarf_.GetElf()),
options_(options),
file_filter_(file_filter),
metrics_(metrics) {}
@@ -207,7 +204,7 @@ class Reader {
const std::unique_ptr<Filter>& file_filter, Metrics& metrics)
: graph_(graph),
dwarf_(data, size),
- elf_(dwarf_.GetElf(), options.Test(ReadOptions::INFO)),
+ elf_(dwarf_.GetElf()),
options_(options),
file_filter_(file_filter),
metrics_(metrics) {}
@@ -403,10 +400,6 @@ class Reader {
Id Reader::Read() {
const auto all_symbols = elf_.GetElfSymbols();
- if (options_.Test(ReadOptions::INFO)) {
- std::cout << "Parsed " << all_symbols.size() << " symbols\n";
- }
-
const bool is_linux_kernel = elf_.IsLinuxKernelBinary();
const SymbolNameList ksymtab_symbols =
is_linux_kernel ? GetKsymtabSymbols(all_symbols) : SymbolNameList();
@@ -419,16 +412,7 @@ Id Reader::Read() {
}
const auto cfi_address_map = GetCFIAddressMap(elf_.GetCFISymbols(), elf_);
- if (options_.Test(ReadOptions::INFO) && !cfi_address_map.empty()) {
- std::cout << "CFI symbols:\n";
- for (const auto& [name, address] : cfi_address_map) {
- std::cout << " " << name << " -> " << Hex(address) << '\n';
- }
- }
- if (options_.Test(ReadOptions::INFO)) {
- std::cout << "Public functions and variables:\n";
- }
std::vector<std::pair<ElfSymbol, size_t>> symbols;
symbols.reserve(all_symbols.size());
for (const auto& symbol : all_symbols) {
@@ -440,13 +424,6 @@ Id Reader::Read() {
: elf_.GetAbsoluteAddress(symbol);
symbols.emplace_back(
SymbolTableEntryToElfSymbol(crc_values, namespaces, symbol), address);
-
- if (options_.Test(ReadOptions::INFO)) {
- std::cout << " " << symbol.binding << ' ' << symbol.symbol_type << " '"
- << symbol.name << "'\n visibility=" << symbol.visibility
- << " size=" << symbol.size << " value=" << symbol.value << "["
- << symbol.value_type << "]\n";
- }
}
}
symbols.shrink_to_fit();