From 5d34088f4bd07ff1e91826ca981c10f54748e76f Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Wed, 23 Apr 2014 00:06:45 -0700 Subject: I now import functions using their linkage name This is required for C++ methods --- dwarf_prototypes.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dwarf_prototypes.c b/dwarf_prototypes.c index 0ab05b8..9f03384 100644 --- a/dwarf_prototypes.c +++ b/dwarf_prototypes.c @@ -700,7 +700,20 @@ static bool process_die_compileunit(struct protolib* plib, struct library* lib, while (1) { if (dwarf_tag(&die) == DW_TAG_subprogram) { - const char* function_name = dwarf_diename(&die); + + // I use the linkage function name if there is one, otherwise the + // plain name + const char* function_name = NULL; + Dwarf_Attribute attr; + if (dwarf_attr(&die, DW_AT_linkage_name, &attr) != NULL) + function_name = dwarf_formstring(&attr); + if (function_name == NULL) + function_name = dwarf_diename(&die); + if (function_name == NULL) { + complain(&die, "Function has no name. Not importing" ); + goto next_prototype; + } + complain(&die, "subroutine_type: 0x%02x; function '%s'", dwarf_tag(&die), function_name); -- cgit v1.2.3