Add map to manager functions names and addresses
This commit is contained in:
parent
134f6eb566
commit
6e9f0f5dfe
2 changed files with 13 additions and 3 deletions
|
@ -23,6 +23,7 @@ type ELF64File struct {
|
||||||
FunctionsTables []FunctionTables
|
FunctionsTables []FunctionTables
|
||||||
Raw []byte
|
Raw []byte
|
||||||
IndexSections map[string]int
|
IndexSections map[string]int
|
||||||
|
MapFctAddrName map[uint64]string
|
||||||
Name string
|
Name string
|
||||||
Endianness binary.ByteOrder
|
Endianness binary.ByteOrder
|
||||||
TextSectionIndex []int // slice since we can have several
|
TextSectionIndex []int // slice since we can have several
|
||||||
|
|
|
@ -24,9 +24,9 @@ type FunctionTables struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ELF64Function struct {
|
type ELF64Function struct {
|
||||||
Name string
|
Name string
|
||||||
Addr uint64
|
Addr uint64
|
||||||
Size uint64
|
Size uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (elfFile *ELF64File) getIndexFctTable(ndx uint16) int {
|
func (elfFile *ELF64File) getIndexFctTable(ndx uint16) int {
|
||||||
|
@ -58,7 +58,15 @@ func (elfFile *ELF64File) detectSizeSymbol(symbolsTable []ELF64Function, index i
|
||||||
|
|
||||||
func (elfFile *ELF64File) inspectFunctions() error {
|
func (elfFile *ELF64File) inspectFunctions() error {
|
||||||
|
|
||||||
|
nbEntries := 0
|
||||||
for _, table := range elfFile.SymbolsTables {
|
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 {
|
for _, s := range table.dataSymbols {
|
||||||
k := elfFile.getIndexFctTable(s.elf64sym.Shndx)
|
k := elfFile.getIndexFctTable(s.elf64sym.Shndx)
|
||||||
if k != -1 && s.elf64sym.Value > 0 {
|
if k != -1 && s.elf64sym.Value > 0 {
|
||||||
|
@ -75,6 +83,7 @@ func (elfFile *ELF64File) inspectFunctions() error {
|
||||||
elfFile.FunctionsTables[k].Functions =
|
elfFile.FunctionsTables[k].Functions =
|
||||||
append(elfFile.FunctionsTables[k].Functions, function)
|
append(elfFile.FunctionsTables[k].Functions, function)
|
||||||
}
|
}
|
||||||
|
elfFile.MapFctAddrName[s.elf64sym.Value] = s.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue