mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 10:45:28 +00:00
Port ElfSymbolParser to libtoolchain.
This commit is contained in:
parent
0c6efad603
commit
258173915c
|
@ -1,8 +1,9 @@
|
||||||
#include "ElfSymbolParser.h"
|
#include "ElfSymbolParser.h"
|
||||||
|
|
||||||
nstool::ElfSymbolParser::ElfSymbolParser()
|
nstool::ElfSymbolParser::ElfSymbolParser() :
|
||||||
|
mModuleName("nstool::ElfSymbolParser"),
|
||||||
|
mSymbolList()
|
||||||
{
|
{
|
||||||
mSymbolList.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nstool::ElfSymbolParser::operator=(const ElfSymbolParser& other)
|
void nstool::ElfSymbolParser::operator=(const ElfSymbolParser& other)
|
||||||
|
@ -22,7 +23,7 @@ bool nstool::ElfSymbolParser::operator!=(const ElfSymbolParser& other) const
|
||||||
|
|
||||||
void nstool::ElfSymbolParser::parseData(const byte_t *dyn_sym, size_t dyn_sym_size, const byte_t *dyn_str, size_t dyn_str_size, bool is64Bit)
|
void nstool::ElfSymbolParser::parseData(const byte_t *dyn_sym, size_t dyn_sym_size, const byte_t *dyn_str, size_t dyn_str_size, bool is64Bit)
|
||||||
{
|
{
|
||||||
size_t dynSymSize = is64Bit ? sizeof(fnd::Elf64_Sym) : sizeof(fnd::Elf32_Sym);
|
size_t dynSymSize = is64Bit ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym);
|
||||||
|
|
||||||
sElfSymbol symbol;
|
sElfSymbol symbol;
|
||||||
for (size_t i = 0; i < dyn_sym_size; i += dynSymSize)
|
for (size_t i = 0; i < dyn_sym_size; i += dynSymSize)
|
||||||
|
@ -31,22 +32,22 @@ void nstool::ElfSymbolParser::parseData(const byte_t *dyn_sym, size_t dyn_sym_si
|
||||||
|
|
||||||
if (is64Bit)
|
if (is64Bit)
|
||||||
{
|
{
|
||||||
name_pos = le_word(((fnd::Elf64_Sym*)(dyn_sym + i))->st_name);
|
name_pos = tc::bn::detail::__le_uint32(((Elf64_Sym*)(dyn_sym + i))->st_name);
|
||||||
symbol.shn_index = le_hword(((fnd::Elf64_Sym*)(dyn_sym + i))->st_shndx);
|
symbol.shn_index = tc::bn::detail::__le_uint16(((Elf64_Sym*)(dyn_sym + i))->st_shndx);
|
||||||
symbol.symbol_type = fnd::elf::get_elf_st_type(((fnd::Elf64_Sym*)(dyn_sym + i))->st_info);
|
symbol.symbol_type = elf::get_elf_st_type(((Elf64_Sym*)(dyn_sym + i))->st_info);
|
||||||
symbol.symbol_binding = fnd::elf::get_elf_st_bind(((fnd::Elf64_Sym*)(dyn_sym + i))->st_info);
|
symbol.symbol_binding = elf::get_elf_st_bind(((Elf64_Sym*)(dyn_sym + i))->st_info);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name_pos = le_word(((fnd::Elf32_Sym*)(dyn_sym + i))->st_name);
|
name_pos = tc::bn::detail::__le_uint32(((Elf32_Sym*)(dyn_sym + i))->st_name);
|
||||||
symbol.shn_index = le_hword(((fnd::Elf32_Sym*)(dyn_sym + i))->st_shndx);
|
symbol.shn_index = tc::bn::detail::__le_uint16(((Elf32_Sym*)(dyn_sym + i))->st_shndx);
|
||||||
symbol.symbol_type = fnd::elf::get_elf_st_type(((fnd::Elf32_Sym*)(dyn_sym + i))->st_info);
|
symbol.symbol_type = elf::get_elf_st_type(((Elf32_Sym*)(dyn_sym + i))->st_info);
|
||||||
symbol.symbol_binding = fnd::elf::get_elf_st_bind(((fnd::Elf32_Sym*)(dyn_sym + i))->st_info);
|
symbol.symbol_binding = elf::get_elf_st_bind(((Elf32_Sym*)(dyn_sym + i))->st_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name_pos >= dyn_str_size)
|
if (name_pos >= dyn_str_size)
|
||||||
{
|
{
|
||||||
throw tc::Exception(kModuleName, "Out of bounds symbol name offset");
|
throw tc::Exception(mModuleName, "Out of bounds symbol name offset");
|
||||||
}
|
}
|
||||||
|
|
||||||
//for (; dyn_str[name_pos] == 0x00 && name_pos < dyn_str_size; name_pos++);
|
//for (; dyn_str[name_pos] == 0x00 && name_pos < dyn_str_size; name_pos++);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
const std::vector<sElfSymbol>& getSymbolList() const;
|
const std::vector<sElfSymbol>& getSymbolList() const;
|
||||||
private:
|
private:
|
||||||
const std::string kModuleName = "ElfSymbolParser";
|
std::string mModuleName;
|
||||||
|
|
||||||
// data
|
// data
|
||||||
std::vector<sElfSymbol> mSymbolList;
|
std::vector<sElfSymbol> mSymbolList;
|
||||||
|
|
Loading…
Reference in a new issue