mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-24 13:11:47 +00:00
Merge remote-tracking branch 'origin/GP-3885_ryanmkurtz_demangle'
This commit is contained in:
commit
f07da62e79
@ -35,7 +35,7 @@ public class DemangledAddressTable extends DemangledObject {
|
||||
* @param mangled the source mangled string
|
||||
* @param originalDemangled the original demangled string
|
||||
* @param name the name of the address table
|
||||
* @param calculateLength true if the length of this address table should be calculdated at
|
||||
* @param calculateLength true if the length of this address table should be calculated at
|
||||
* analysis time
|
||||
*/
|
||||
public DemangledAddressTable(String mangled, String originalDemangled, String name,
|
||||
|
@ -41,8 +41,45 @@ public abstract class DemangledObject implements Demangled {
|
||||
protected static final String NAMESPACE_SEPARATOR = Namespace.DELIMITER;
|
||||
protected static final String EMPTY_STRING = "";
|
||||
|
||||
/*
|
||||
The following names probably need to be refactored. Until then, this is how the following
|
||||
fields are used.
|
||||
|
||||
mangled -
|
||||
Source: The original mangled string as seen in the program
|
||||
Usage: Can be used to see if a program symbol has already been demangled
|
||||
|
||||
originalDemangled -
|
||||
Source: The raw demangled string returned from the demangler
|
||||
Usage: for display
|
||||
|
||||
demangledName -
|
||||
Source: The name as created by the parser which may transform or even replace the
|
||||
string returned from the demangler
|
||||
Usage: for display
|
||||
|
||||
name -
|
||||
Source: This is derived from the 'demangledName' This is updated to be suitable
|
||||
for use as a symbol name. This may be null while building, but is
|
||||
expected to be non-null when applyTo() is called
|
||||
Usage: The name that will be applied when applyTo() is called.
|
||||
|
||||
|
||||
|
||||
Future: These variables should be refactored and renamed to be clearer and more cohesive,
|
||||
something like:
|
||||
|
||||
mangled
|
||||
rawDemangled
|
||||
escapedDemangled
|
||||
symbolName
|
||||
|
||||
*/
|
||||
protected final String mangled; // original mangled string
|
||||
protected final String originalDemangled;
|
||||
protected final String originalDemangled; // raw demangled string
|
||||
private String demangledName; // updated demangled string
|
||||
private String name; // version of demangled name suitable for symbols
|
||||
|
||||
protected String specialPrefix;
|
||||
protected Demangled namespace;
|
||||
protected String visibility;//public, protected, etc.
|
||||
@ -56,8 +93,7 @@ public abstract class DemangledObject implements Demangled {
|
||||
|
||||
//TODO: determine what type of keyword this is (not type qualifier or storage class).
|
||||
protected boolean isVirtual;
|
||||
private String demangledName;
|
||||
private String name;
|
||||
|
||||
private boolean isConst;
|
||||
private boolean isVolatile;
|
||||
private boolean isPointer64;
|
||||
|
@ -40,7 +40,7 @@ public class DemangledUnknown extends DemangledObject {
|
||||
public String getName() {
|
||||
//These items likely do not have names or data types, so return the signature.
|
||||
String myName = super.getName();
|
||||
if (!myName.isEmpty()) {
|
||||
if (myName != null && !myName.isEmpty()) {
|
||||
return myName;
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ public class DemangledVariable extends DemangledObject {
|
||||
@Override
|
||||
public String getName() {
|
||||
String myName = super.getName();
|
||||
if (!myName.isEmpty()) {
|
||||
if (myName != null && !myName.isEmpty()) {
|
||||
return myName;
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ public class GnuDemangler implements Demangler {
|
||||
if (isELF(executableFormat) || isMacho(executableFormat)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String compiler = program.getCompiler();
|
||||
if(compiler != null && compiler.contains("gcc")) {
|
||||
|
||||
String compiler = program.getCompiler();
|
||||
if (compiler != null && compiler.contains("gcc")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class GnuDemangler implements Demangler {
|
||||
}
|
||||
}
|
||||
else if (mangled.startsWith("__Z")) {
|
||||
mangled = mangled.substring(1);//removed first underscore....
|
||||
mangled = mangled.substring(1);
|
||||
}
|
||||
|
||||
boolean isDwarf = false;
|
||||
@ -112,7 +112,8 @@ public class GnuDemangler implements Demangler {
|
||||
}
|
||||
|
||||
boolean onlyKnownPatterns = options.demangleOnlyKnownPatterns();
|
||||
DemangledObject demangledObject = parse(mangled, process, demangled, onlyKnownPatterns);
|
||||
DemangledObject demangledObject =
|
||||
parse(originalMangled, process, demangled, onlyKnownPatterns);
|
||||
if (demangledObject == null) {
|
||||
return demangledObject;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ public class GnuDemanglerParser {
|
||||
// operator text. Since the 'special handlers' perform more specific checks, it is
|
||||
// safe to do those first.
|
||||
//
|
||||
DemangledObjectBuilder handler = getSpecialPrefixHandler(mangledSource, demangled);
|
||||
DemangledObjectBuilder handler = getSpecialPrefixHandler(demangled);
|
||||
if (handler != null) {
|
||||
return handler;
|
||||
}
|
||||
@ -394,7 +394,7 @@ public class GnuDemanglerParser {
|
||||
return null;
|
||||
}
|
||||
|
||||
private SpecialPrefixHandler getSpecialPrefixHandler(String mangled, String demangled) {
|
||||
private SpecialPrefixHandler getSpecialPrefixHandler(String demangled) {
|
||||
|
||||
Matcher matcher = DESCRIPTIVE_PREFIX_PATTERN.matcher(demangled);
|
||||
if (matcher.matches()) {
|
||||
|
Loading…
Reference in New Issue
Block a user