Skip to content

Commit

Permalink
Add records for mangled names
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Feb 7, 2024
1 parent b50797d commit fb37008
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Inc/loadelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct symbolLineStore
struct symbolFunctionStore
{
char *funcname; /* What is the name of the function */
char *manglename; /* What is the manged name, if any */
unsigned int producer; /* What code/options produced it? */
unsigned int filename; /* What filename + path off the source root? */
unsigned int startline; /* Start line in source file of function */
Expand Down
15 changes: 12 additions & 3 deletions Src/loadelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ static void _processFunctionDie( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die di

{
char *name = NULL;
char *manglename = NULL;
Dwarf_Addr h = 0;
Dwarf_Addr l = 0;
enum Dwarf_Form_Class formclass = DW_FORM_CLASS_UNKNOWN;
Expand Down Expand Up @@ -387,9 +388,10 @@ static void _processFunctionDie( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die di
/* Get the possibly mangled linkage name if it exists */
if ( DW_DLV_OK == dwarf_attr( die, DW_AT_linkage_name, &attr_data, 0) )
{
dwarf_formstring( attr_data, &name, 0 );
dwarf_formstring( attr_data, &manglename, 0 );
}
else if ( DW_DLV_OK != dwarf_diename( die, &name, 0 ) )

if ( DW_DLV_OK != dwarf_diename( die, &name, 0 ) )
{
/* Name will be hidden in a specification reference */
attr_tag = DW_AT_specification;
Expand All @@ -414,6 +416,7 @@ static void _processFunctionDie( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die di
p->nfunc++;

newFunc->funcname = strdup( name );
newFunc->manglename= strdup( manglename );
newFunc->producer = producerN;
newFunc->filename = filenameN;
newFunc->lowaddr = l;
Expand Down Expand Up @@ -915,6 +918,12 @@ void symbolDelete( struct symbol *p )
free( f->funcname );
}

if ( f->manglename )
{
/* Remove the mangled name, assuming we have one */
free( f->manglename );
}

if ( f->line )
{
/* ...and any source code cross-references */
Expand Down Expand Up @@ -1185,7 +1194,7 @@ bool _listFunctions( struct symbol *p, bool includeLines )

while ( f = symbolFunctionIndex( p, iter++ ) )
{
fprintf( stderr, MEMADDRF "..." MEMADDRF " %s ( %s %d,%d )" EOL, f->lowaddr, f->highaddr, f->funcname, symbolGetFilename( p, f->filename ), f->startline, f->startcol );
fprintf( stderr, MEMADDRF "..." MEMADDRF " %s ( %s %d,%d ) %s" EOL, f->lowaddr, f->highaddr, f->funcname, symbolGetFilename( p, f->filename ), f->startline, f->startcol, f->manglename?f->manglename:"" );

if ( includeLines )
{
Expand Down

0 comments on commit fb37008

Please sign in to comment.