mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 23:17:03 +08:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
+20
-7
@@ -57,19 +57,38 @@ public abstract class AbstractDemanglerAnalyzer extends AbstractAnalyzer {
|
|||||||
public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
|
public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
|
||||||
throws CancelledException {
|
throws CancelledException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
monitor.setIndeterminate(true);
|
||||||
|
return doAdded(program, set, monitor, log);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
monitor.setIndeterminate(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean doAdded(Program program, AddressSetView set, TaskMonitor monitor,
|
||||||
|
MessageLog log)
|
||||||
|
throws CancelledException {
|
||||||
|
|
||||||
DemanglerOptions options = getOptions();
|
DemanglerOptions options = getOptions();
|
||||||
if (!validateOptions(options, log)) {
|
if (!validateOptions(options, log)) {
|
||||||
log.appendMsg(getName(), "Invalid demangler options--cannot demangle");
|
log.appendMsg(getName(), "Invalid demangler options--cannot demangle");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.initialize(100);
|
int count = 0;
|
||||||
|
|
||||||
|
String defaultMessage = monitor.getMessage();
|
||||||
|
|
||||||
SymbolTable symbolTable = program.getSymbolTable();
|
SymbolTable symbolTable = program.getSymbolTable();
|
||||||
SymbolIterator it = symbolTable.getPrimarySymbolIterator(set, true);
|
SymbolIterator it = symbolTable.getPrimarySymbolIterator(set, true);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
monitor.checkCanceled();
|
monitor.checkCanceled();
|
||||||
|
|
||||||
|
if (++count % 100 == 0) {
|
||||||
|
monitor.setMessage(defaultMessage + " - " + count + " symbols");
|
||||||
|
}
|
||||||
|
|
||||||
Symbol symbol = it.next();
|
Symbol symbol = it.next();
|
||||||
if (skipSymbol(symbol)) {
|
if (skipSymbol(symbol)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -81,12 +100,6 @@ public abstract class AbstractDemanglerAnalyzer extends AbstractAnalyzer {
|
|||||||
if (demangled != null) {
|
if (demangled != null) {
|
||||||
apply(program, address, demangled, options, log, monitor);
|
apply(program, address, demangled, options, log, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Address min = set.getMinAddress();
|
|
||||||
Address max = set.getMaxAddress();
|
|
||||||
int distance = (int) (address.getOffset() - min.getOffset());
|
|
||||||
int percent = (int) ((distance / max.getOffset()) * 100);
|
|
||||||
monitor.setProgress(percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+4
-2
@@ -240,6 +240,8 @@ public class GnuDemanglerParser {
|
|||||||
*
|
*
|
||||||
* Parts:
|
* Parts:
|
||||||
* -required text (capture group 2)
|
* -required text (capture group 2)
|
||||||
|
* --note: this uses '++', a possessive quantifier, to help keep the
|
||||||
|
* backtracking to a minimum
|
||||||
* -a space
|
* -a space
|
||||||
* -'for' or 'to' (capture group 3)
|
* -'for' or 'to' (capture group 3)
|
||||||
* -a space
|
* -a space
|
||||||
@@ -258,7 +260,7 @@ public class GnuDemanglerParser {
|
|||||||
* non-virtual thunk to
|
* non-virtual thunk to
|
||||||
*/
|
*/
|
||||||
private static final Pattern DESCRIPTIVE_PREFIX_PATTERN =
|
private static final Pattern DESCRIPTIVE_PREFIX_PATTERN =
|
||||||
Pattern.compile("((.+ )+(for|to) )(.+)");
|
Pattern.compile("((.+ )(for|to) )(.+)");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The c 'decltype' keyword pattern
|
* The c 'decltype' keyword pattern
|
||||||
@@ -303,7 +305,7 @@ public class GnuDemanglerParser {
|
|||||||
// note: this capture group seems to fail with excessive templating
|
// note: this capture group seems to fail with excessive templating
|
||||||
String operatorTemplates = "(<.+>){0,1}";
|
String operatorTemplates = "(<.+>){0,1}";
|
||||||
String operatorPrefix =
|
String operatorPrefix =
|
||||||
".*(.*" + OPERATOR + "(" + alternated + ")\\s*" + operatorTemplates + ".*)\\s*";
|
"(.*" + OPERATOR + "(" + alternated + ")\\s*" + operatorTemplates + ")\\s*";
|
||||||
String parameters = "(\\(.*\\))";
|
String parameters = "(\\(.*\\))";
|
||||||
String trailing = "(.*)";
|
String trailing = "(.*)";
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class ClassPackage extends ClassLocation {
|
|||||||
pkg = packageName + "." + pkg;
|
pkg = packageName + "." + pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.setMessage("scanning package: " + pkg);
|
monitor.setMessage("Scanning package: " + pkg);
|
||||||
children.add(new ClassPackage(rootDir, pkg, monitor));
|
children.add(new ClassPackage(rootDir, pkg, monitor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -222,7 +222,7 @@ public final class LocalTreeNodeHandler
|
|||||||
|
|
||||||
GTreeNode copyNode = toCopy.get(i);
|
GTreeNode copyNode = toCopy.get(i);
|
||||||
monitor.setMessage(
|
monitor.setMessage(
|
||||||
"Processing file " + i + " of " + size + ": " + copyNode.getName());
|
"Processing file " + (i + 1) + " of " + size + ": " + copyNode.getName());
|
||||||
|
|
||||||
add(destination, copyNode, dropAction, subMonitors[i]);
|
add(destination, copyNode, dropAction, subMonitors[i]);
|
||||||
monitor.setProgress(i);
|
monitor.setProgress(i);
|
||||||
|
|||||||
+12
-2
@@ -155,15 +155,25 @@ public class PIC30_ElfRelocationHandler extends ElfRelocationHandler {
|
|||||||
if (elf.e_machine() == ElfConstants.EM_DSPIC30F) {
|
if (elf.e_machine() == ElfConstants.EM_DSPIC30F) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case R_PIC30_16: // 2
|
case R_PIC30_16: // 2
|
||||||
newValue = (symbolValue + addend + oldShortValue) & 0xffff;
|
case R_PIC30_FILE_REG_WORD: // 6
|
||||||
|
newValue = (symbolValue + addend + oldShortValue);
|
||||||
memory.setShort(relocationAddress, (short) newValue);
|
memory.setShort(relocationAddress, (short) newValue);
|
||||||
break;
|
break;
|
||||||
case R_PIC30_32: // 3
|
case R_PIC30_32: // 3
|
||||||
newValue = symbolValue + addend + oldValue;
|
newValue = symbolValue + addend + oldValue;
|
||||||
memory.setInt(relocationAddress, newValue);
|
memory.setInt(relocationAddress, newValue);
|
||||||
break;
|
break;
|
||||||
|
case R_PIC30_FILE_REG_BYTE: // 4 short
|
||||||
|
case R_PIC30_FILE_REG: // 5 short
|
||||||
|
int reloc = symbolValue;
|
||||||
|
reloc += addend;
|
||||||
|
reloc += oldShortValue;
|
||||||
|
reloc &= 0x1fff;
|
||||||
|
newValue = reloc | (oldShortValue & ~0x1fff);
|
||||||
|
memory.setShort(relocationAddress, (short) newValue);
|
||||||
|
break;
|
||||||
case R_PIC30_FILE_REG_WORD_WITH_DST: // 7
|
case R_PIC30_FILE_REG_WORD_WITH_DST: // 7
|
||||||
int reloc = symbolValue >> 1;
|
reloc = symbolValue >> 1;
|
||||||
reloc += addend;
|
reloc += addend;
|
||||||
reloc += oldValue >> 4;
|
reloc += oldValue >> 4;
|
||||||
reloc &= 0x7fff;
|
reloc &= 0x7fff;
|
||||||
|
|||||||
Reference in New Issue
Block a user