mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 23:17:03 +08:00
GP-6363 - Gnu Demangler - Updated the legacy GnuDemangler v2.24 to
handle qualifiers being used along with the 'F' character.
This commit is contained in:
@@ -37,6 +37,13 @@ method from cxxfilt.c and placed it, along with supporting methods, into cplus-d
|
|||||||
allows us to perform a simple build of the stand alone demangler, with less source files
|
allows us to perform a simple build of the stand alone demangler, with less source files
|
||||||
required.
|
required.
|
||||||
|
|
||||||
|
Update January 2026
|
||||||
|
|
||||||
|
Fixed a bug seen in older mangled symbols that use an 'F' character for functions. We added a
|
||||||
|
function to handle this case, isQualifiersAndFunc(). This function called from inside the
|
||||||
|
demangle_signature() function.
|
||||||
|
|
||||||
|
|
||||||
cp-demangle.c *
|
cp-demangle.c *
|
||||||
|
|
||||||
This file contains a small, two-line change to send a newline character ('\n') along with
|
This file contains a small, two-line change to send a newline character ('\n') along with
|
||||||
|
|||||||
@@ -819,6 +819,33 @@ cplus_demangle_name_to_style (const char *name)
|
|||||||
return unknown_demangling;
|
return unknown_demangling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Scans to see if mangled is a set of optional qualifiers and a function. */
|
||||||
|
static int /* bool */
|
||||||
|
isQualifiersAndFunc(const char *mangled)
|
||||||
|
{
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (mangled[i++])
|
||||||
|
{
|
||||||
|
case 'C':
|
||||||
|
case 'V':
|
||||||
|
case 'u':
|
||||||
|
/*qualifier*/
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
/* function */
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
/* anything else is not a qualifier or function */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* char *cplus_demangle (const char *mangled, int options)
|
/* char *cplus_demangle (const char *mangled, int options)
|
||||||
|
|
||||||
If MANGLED is a mangled function name produced by GNU C++, then
|
If MANGLED is a mangled function name produced by GNU C++, then
|
||||||
@@ -1485,8 +1512,10 @@ demangle_signature (struct work_stuff *work,
|
|||||||
{
|
{
|
||||||
/* EDG and others will have the "F", so we let the loop cycle
|
/* EDG and others will have the "F", so we let the loop cycle
|
||||||
if we are looking at one. */
|
if we are looking at one. */
|
||||||
if (**mangled != 'F')
|
// if (**mangled != 'F')
|
||||||
|
if (!isQualifiersAndFunc(*mangled)) {
|
||||||
expect_func = 1;
|
expect_func = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
oldmangled = NULL;
|
oldmangled = NULL;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+17
@@ -181,6 +181,23 @@ public class GnuDemanglerParserTest extends AbstractGenericTest {
|
|||||||
assertEquals("float", parameters.get(3).getType().getSignature());
|
assertEquals("float", parameters.get(3).getType().getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLegacy_DemangledFunctionCharacter() throws Exception {
|
||||||
|
|
||||||
|
// This is only supported in the older v24 demangler. The 'F' character was not being
|
||||||
|
// correctly demangled. The native demangler was updated to fix this.
|
||||||
|
String mangled = "foo__03FooCFUcT1";
|
||||||
|
process = GnuDemanglerNativeProcess
|
||||||
|
.getDemanglerNativeProcess(GnuDemanglerOptions.GNU_DEMANGLER_V2_24);
|
||||||
|
String demangled = process.demangle(mangled);
|
||||||
|
assertEquals("Foo::foo(unsigned char, unsigned char) const", demangled);
|
||||||
|
|
||||||
|
DemangledObject object = parser.parse(mangled, demangled);
|
||||||
|
assertType(object, DemangledFunction.class);
|
||||||
|
assertName(object, "foo", "Foo");
|
||||||
|
assertEquals("undefined Foo::foo(unsigned char,unsigned char)", object.getSignature());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemplates_TemplatedType() throws Exception {
|
public void testTemplates_TemplatedType() throws Exception {
|
||||||
String mangled =
|
String mangled =
|
||||||
|
|||||||
Reference in New Issue
Block a user