Skip to content

Instantly share code, notes, and snippets.

@grantseltzer
Last active September 14, 2018 05:53
Show Gist options
  • Save grantseltzer/1ccd6cf37dd98c012a089b0f0f00babd to your computer and use it in GitHub Desktop.
Save grantseltzer/1ccd6cf37dd98c012a089b0f0f00babd to your computer and use it in GitHub Desktop.
// Open the ELF file
elfFile, err := elf.Open(path)
if err != nil {
log.Fatalf("error while opening ELF file %s: %+s", path, err.Error())
}
// Extract the symbol table
symbolTable, err := elfFile.Symbols()
if err != nil {
log.Fatalf("could not extract symbol table: %s", err.Error())
}
// Traverse through each symbol in the symbol table
for _, symbol := range symbolTable {
/*
symbol.Info lets us tell if this symbol is a function that we want to disassemble
symbol.Value gives us the offset from the start of the .text section
symbol.Size lets us calculate the full address range of this symbol in the .text section
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment