look for symbols in dynsym table (#990)

* look for symbols in dynsym table

* checking both symtab and dynsym

* Avoid symbol duplication in non stripped binaries

* clang-format

* Minor elf_utils.cpp updates

- use 'else if' instead of 'if'
- logging tweaks

* Update registration

- tweak logging

* Update testing

- strip the rocprofiler-sdk-c-tool library
- add test-c-tool-rocp-tool-lib-execute test which does NOT LD_PRELOAD the library (uses only ROCP_TOOL_LIBRARIES instead)

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>

[ROCm/rocprofiler-sdk commit: dc671497da]
Este commit está contenido en:
Gopesh Bhardwaj
2024-07-26 10:21:04 +05:30
cometido por GitHub
padre 185094eee1
commit 2393b2ee45
Se han modificado 5 ficheros con 78 adiciones y 22 borrados
@@ -89,6 +89,11 @@ ElfInfo::has_symbol(std::regex&& _re) const
{
if(!itr.name.empty() && std::regex_search(itr.name, _re)) return true;
}
// For stripped binaries
for(const auto& itr : dynamic_symbol_entries)
{
if(!itr.name.empty() && std::regex_search(itr.name, _re)) return true;
}
return false;
}
@@ -96,12 +101,13 @@ ElfInfo::has_symbol(std::regex&& _re) const
ElfInfo
read(const std::string& _inp)
{
auto _info = ElfInfo{_inp};
auto& reader = _info.reader;
auto& sections = _info.sections;
auto& symbol_entries = _info.symbol_entries;
auto& dynamic_entries = _info.dynamic_entries;
auto& reloc_entries = _info.reloc_entries;
auto _info = ElfInfo{_inp};
auto& reader = _info.reader;
auto& sections = _info.sections;
auto& symbol_entries = _info.symbol_entries;
auto& dynamic_symbol_entries = _info.dynamic_symbol_entries;
auto& dynamic_entries = _info.dynamic_entries;
auto& reloc_entries = _info.reloc_entries;
ROCP_TRACE << "\nReading " << _inp;
@@ -148,10 +154,17 @@ read(const std::string& _inp)
if(psec->get_type() == ELFIO::SHT_SYMTAB)
{
const ELFIO::symbol_section_accessor _symbols(reader, psec);
ROCP_TRACE << " Number of symbol_entries: " << _symbols.get_symbols_num();
ROCP_TRACE << " Number of symbol entries: " << _symbols.get_symbols_num();
for(ELFIO::Elf_Xword k = 0; k < _symbols.get_symbols_num(); ++k)
symbol_entries.emplace_back(k, _symbols);
}
else if(psec->get_type() == ELFIO::SHT_DYNSYM)
{
const ELFIO::symbol_section_accessor _symbols(reader, psec);
ROCP_TRACE << " Number of dynamic symbol entries: " << _symbols.get_symbols_num();
for(ELFIO::Elf_Xword k = 0; k < _symbols.get_symbols_num(); ++k)
dynamic_symbol_entries.emplace_back(k, _symbols);
}
else if(psec->get_type() == ELFIO::SHT_DYNAMIC)
{
const ELFIO::dynamic_section_accessor dynamic{reader, psec};
@@ -175,6 +188,13 @@ read(const std::string& _inp)
ROCP_TRACE << " [" << k << "] " << symbol_entries.at(k).name;
}
ROCP_TRACE << "Dynamic Symbols:";
for(size_t k = 0; k < dynamic_symbol_entries.size(); ++k)
{
if(!dynamic_symbol_entries.at(k).name.empty())
ROCP_TRACE << " [" << k << "] " << dynamic_symbol_entries.at(k).name;
}
ROCP_TRACE << "Dynamic entries:";
for(size_t k = 0; k < dynamic_entries.size(); ++k)
{