Add map to manager functions names and addresses

This commit is contained in:
Gaulthier Gain 2021-12-06 20:07:29 +01:00
parent 134f6eb566
commit 6e9f0f5dfe
2 changed files with 13 additions and 3 deletions

View file

@ -23,6 +23,7 @@ type ELF64File struct {
FunctionsTables []FunctionTables
Raw []byte
IndexSections map[string]int
MapFctAddrName map[uint64]string
Name string
Endianness binary.ByteOrder
TextSectionIndex []int // slice since we can have several

View file

@ -58,7 +58,15 @@ func (elfFile *ELF64File) detectSizeSymbol(symbolsTable []ELF64Function, index i
func (elfFile *ELF64File) inspectFunctions() error {
nbEntries := 0
for _, table := range elfFile.SymbolsTables {
nbEntries += table.nbEntries
}
elfFile.MapFctAddrName = make(map[uint64]string, nbEntries)
for _, table := range elfFile.SymbolsTables {
for _, s := range table.dataSymbols {
k := elfFile.getIndexFctTable(s.elf64sym.Shndx)
if k != -1 && s.elf64sym.Value > 0 {
@ -75,6 +83,7 @@ func (elfFile *ELF64File) inspectFunctions() error {
elfFile.FunctionsTables[k].Functions =
append(elfFile.FunctionsTables[k].Functions, function)
}
elfFile.MapFctAddrName[s.elf64sym.Value] = s.name
}
}