mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
utils: add symbol range support for binfile and elfparser
This commit is contained in:
@ -519,7 +519,7 @@ bin_symbol_get_name (bin_file_t *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gulong
|
gulong
|
||||||
bin_symbol_get_address (bin_file_t *file,
|
bin_symbol_get_address (bin_file_t *file,
|
||||||
const bin_symbol_t *symbol)
|
const bin_symbol_t *symbol)
|
||||||
{
|
{
|
||||||
if (file->undefined_name == (char *)symbol)
|
if (file->undefined_name == (char *)symbol)
|
||||||
@ -536,3 +536,24 @@ bin_symbol_get_address (bin_file_t *file,
|
|||||||
return elf_parser_get_sym_address (elf, sym);
|
return elf_parser_get_sym_address (elf, sym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bin_symbol_get_address_range (bin_file_t *file,
|
||||||
|
const bin_symbol_t *symbol,
|
||||||
|
gulong *begin,
|
||||||
|
gulong *end)
|
||||||
|
{
|
||||||
|
if (file->undefined_name == (char *)symbol)
|
||||||
|
{
|
||||||
|
*begin = 0;
|
||||||
|
*end = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ElfParser *elf;
|
||||||
|
const ElfSym *sym;
|
||||||
|
|
||||||
|
sym = get_elf_sym (file, symbol, &elf);
|
||||||
|
elf_parser_get_sym_address_range (elf, sym, begin, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -32,15 +32,19 @@ typedef struct bin_symbol_t bin_symbol_t;
|
|||||||
|
|
||||||
/* Binary File */
|
/* Binary File */
|
||||||
|
|
||||||
bin_file_t *bin_file_new (const char *filename);
|
bin_file_t *bin_file_new (const char *filename);
|
||||||
void bin_file_free (bin_file_t *bin_file);
|
void bin_file_free (bin_file_t *bin_file);
|
||||||
const bin_symbol_t *bin_file_lookup_symbol (bin_file_t *bin_file,
|
const bin_symbol_t *bin_file_lookup_symbol (bin_file_t *bin_file,
|
||||||
gulong address);
|
gulong address);
|
||||||
gboolean bin_file_check_inode (bin_file_t *bin_file,
|
gboolean bin_file_check_inode (bin_file_t *bin_file,
|
||||||
ino_t inode);
|
ino_t inode);
|
||||||
const char *bin_symbol_get_name (bin_file_t *bin_file,
|
const char *bin_symbol_get_name (bin_file_t *bin_file,
|
||||||
const bin_symbol_t *symbol);
|
const bin_symbol_t *symbol);
|
||||||
gulong bin_symbol_get_address (bin_file_t *bin_file,
|
gulong bin_symbol_get_address (bin_file_t *bin_file,
|
||||||
const bin_symbol_t *symbol);
|
const bin_symbol_t *symbol);
|
||||||
|
void bin_symbol_get_address_range (bin_file_t *bin_file,
|
||||||
|
const bin_symbol_t *symbol,
|
||||||
|
gulong *begin,
|
||||||
|
gulong *end);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -805,12 +805,22 @@ elf_parser_owns_symbol (ElfParser *parser,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gulong
|
gulong
|
||||||
elf_parser_get_sym_address (ElfParser *parser,
|
elf_parser_get_sym_address (ElfParser *parser,
|
||||||
const ElfSym *sym)
|
const ElfSym *sym)
|
||||||
{
|
{
|
||||||
return sym->address - parser->text_section->load_address;
|
return sym->address - parser->text_section->load_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
elf_parser_get_sym_address_range (ElfParser *parser,
|
||||||
|
const ElfSym *sym,
|
||||||
|
gulong *begin,
|
||||||
|
gulong *end)
|
||||||
|
{
|
||||||
|
*begin = sym->address - parser->text_section->load_address;
|
||||||
|
*end = *begin + st_size (parser, sym->table, sym->offset);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility functions
|
* Utility functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -45,14 +45,18 @@ gulong elf_parser_get_text_offset (ElfParser *parser);
|
|||||||
* of the file would have been mapped, so a - (m - o) is the position
|
* of the file would have been mapped, so a - (m - o) is the position
|
||||||
* in the file of a.
|
* in the file of a.
|
||||||
*/
|
*/
|
||||||
const ElfSym *elf_parser_lookup_symbol (ElfParser *parser,
|
const ElfSym *elf_parser_lookup_symbol (ElfParser *parser,
|
||||||
gulong address);
|
gulong address);
|
||||||
guint32 elf_parser_get_crc32 (ElfParser *parser);
|
guint32 elf_parser_get_crc32 (ElfParser *parser);
|
||||||
const char *elf_parser_get_sym_name (ElfParser *parser,
|
const char *elf_parser_get_sym_name (ElfParser *parser,
|
||||||
const ElfSym *sym);
|
const ElfSym *sym);
|
||||||
gulong elf_parser_get_sym_address (ElfParser *parser,
|
gulong elf_parser_get_sym_address (ElfParser *parser,
|
||||||
const ElfSym *sym);
|
const ElfSym *sym);
|
||||||
gboolean elf_parser_owns_symbol (ElfParser *parser,
|
gboolean elf_parser_owns_symbol (ElfParser *parser,
|
||||||
const ElfSym *sym);
|
const ElfSym *sym);
|
||||||
char *elf_demangle (const char *name);
|
char *elf_demangle (const char *name);
|
||||||
|
void elf_parser_get_sym_address_range (ElfParser *parser,
|
||||||
|
const ElfSym *sym,
|
||||||
|
gulong *begin,
|
||||||
|
gulong *end);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user