Created
February 5, 2021 00:05
-
-
Save Artem-B/b7bc53d6f74a673d11570a9df6ba9b45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Search in terms of symbol name and section name */ | |
bool Elf::get_symbol(const std::string& name, const std::string& section_name, | |
Elf64_Addr& value, Elf_Xword& size, unsigned char& bind, | |
unsigned char& type, Elf_Half& section_index, | |
unsigned char& other) const { | |
bool ret = false; | |
symbol_section_accessor symbol_reader(_elfio, _elfio.sections[_symtab_ndx]); | |
// Opportunistic lookup, in case the name is unique. | |
if (symbol_reader.get_symbol(name, value, size, bind, type, section_index, | |
other)) { | |
if (section_name == _elfio.sections[section_index]->get_name()) | |
return true; | |
} | |
for (Elf_Xword i = 0; i < symbol_reader.get_symbols_num() && !ret; i++) { | |
std::string symbol_name; | |
if (symbol_reader.get_symbol(i, symbol_name, value, size, bind, type, | |
section_index, other)) { | |
if (symbol_name == name && | |
section_name == _elfio.sections[section_index]->get_name()) { | |
return true; | |
} | |
} | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment