Skip to content

Commit

Permalink
Merge pull request #140 from niklaut/feature/linkage_name
Browse files Browse the repository at this point in the history
Fix symbolsAquire and add linkage name to get mangled C++ function names
  • Loading branch information
mubes authored Feb 6, 2024
2 parents 148b624 + 9cfdb3b commit b50797d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Inc/loadelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ char *symbolDisassembleLine( struct symbol *p, enum instructionClass *ic, symbol
void symbolDelete( struct symbol *p );

/* Collect symbol set with specified components */
struct symbol *symbolAquire( char *filename, bool loadmem, bool loadsource );
struct symbol *symbolAcquire( char *filename, bool loadmem, bool loadsource );

/* Check if current symbols are valid */
bool symbolSetValid( struct symbol *p );
Expand Down
17 changes: 9 additions & 8 deletions Src/loadelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static void _processFunctionDie( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die di
char *name = NULL;
Dwarf_Addr h = 0;
Dwarf_Addr l = 0;
enum Dwarf_Form_Class formclass;
enum Dwarf_Form_Class formclass = DW_FORM_CLASS_UNKNOWN;

Dwarf_Attribute attr_data;
Dwarf_Half attr_tag;
Expand Down Expand Up @@ -384,7 +384,12 @@ static void _processFunctionDie( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die di

specification_die = die;

if ( DW_DLV_OK != dwarf_diename( die, &name, 0 ) )
/* 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 );
}
else if ( DW_DLV_OK != dwarf_diename( die, &name, 0 ) )
{
/* Name will be hidden in a specification reference */
attr_tag = DW_AT_specification;
Expand Down Expand Up @@ -1102,7 +1107,7 @@ bool symbolSetValid( struct symbol *p )

// ====================================================================================================

struct symbol *symbolAquire( char *filename, bool loadmem, bool loadsource )
struct symbol *symbolAcquire( char *filename, bool loadmem, bool loadsource )

/* Collect symbol set with specified components */

Expand Down Expand Up @@ -1237,11 +1242,7 @@ void main( int argc, char *argv[] )

{
enum instructionClass ic;
<<<<<<< HEAD
struct symbol *p = symbolAcquire( argv[1], true, true, true );
=======
struct symbol *p = symbolAquire( argv[1], true, true );
>>>>>>> loadelf_fixup
struct symbol *p = symbolAcquire( argv[1], true, true );

if ( !p )
{
Expand Down
4 changes: 2 additions & 2 deletions Src/orbmortem.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ static bool _dumpBuffer( struct RunTime *r )
{
symbolDelete( r->s );

if ( !( r->s = symbolAquire( r->options->elffile, true, true ) ) )
if ( !( r->s = symbolAcquire( r->options->elffile, true, true ) ) )
{
genericsReport( V_ERROR, "Elf file or symbols in it not found" EOL );
return false;
Expand Down Expand Up @@ -1270,7 +1270,7 @@ int main( int argc, char *argv[] )
}

/* Check we've got _some_ symbols to start from */
_r.s = symbolAquire( _r.options->elffile, true, true );
_r.s = symbolAcquire( _r.options->elffile, true, true );

if ( !_r.s )
{
Expand Down

0 comments on commit b50797d

Please sign in to comment.