From 6c94148e62076c52794dd43a529793bdc33e4b8d Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Sun, 3 Apr 2016 16:26:36 +1000 Subject: linkers: Demangle the C++ labels in the .ctors/.dtors sections. Show user friendly labels for the C++ constructors and destructors. --- linkers/rtems-exeinfo.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'linkers') diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp index dd04bd1..dc3e1ec 100644 --- a/linkers/rtems-exeinfo.cpp +++ b/linkers/rtems-exeinfo.cpp @@ -111,7 +111,7 @@ namespace rld */ struct image { - files::object exe; //< The object file that is the executable. + files::object exe; //< The object file that is the executable. symbols::table symbols; //< The synbols for a map. symbols::addrtab addresses; //< The symbols keyed by address. files::sections secs; //< The sections in the executable. @@ -214,10 +214,11 @@ namespace rld { if (fsec.name == names[n]) { - section sec (fsec); if (rld::verbose () >= RLD_VERBOSE_DETAILS) std::cout << "init:section-loader: " << fsec.name << " added" << std::endl; + + section sec (fsec); img.exe.seek (fsec.offset); sec.data.read (img.exe, fsec.size); secs.push_back (sec); @@ -342,13 +343,26 @@ namespace rld sym = addresses[address]; std::cout << " " << std::hex << std::setfill ('0') - << "0x" << std::setw (8) << address; + << "0x" << std::setw (8) << address + << std::dec << std::setfill ('0'); if (sym) - std::cout << " " << sym->name (); + { + /* + * C++ is adding '_GLOBAL__sub_I_' to the label. If present, strip + * and check the label. + */ + std::string label = sym->name (); + if (rld::starts_with (label, "_GLOBAL__sub_I_")) + label = rld::find_replace (label, "_GLOBAL__sub_I_", ""); + if (rld::symbols::is_cplusplus (label)) + rld::symbols::demangle_name (label, label); + std::cout << " " << label; + } else + { std::cout << " no symbol"; - std::cout << std::dec << std::setfill ('0') - << std::endl; + } + std::cout << std::endl; } } -- cgit v1.2.3