Removal of old deprecated methods

This commit is contained in:
dragonmacher 2021-10-22 13:14:17 -04:00
parent 37e807ea3b
commit d05a57ae1a
16 changed files with 287 additions and 500 deletions

View file

@ -15,14 +15,14 @@
*/
// VxWorksSymTab_5_4 is a copy of VxWorksSymTab_6_1 with a different value for SYM_ENTRY_SIZE
// It was replaced at the request of a customer who tested that it worked with the slight modification
// VxWorksSymTab_6_1 is an adaptation of the vxWorksSymTab script. It was modified by a customer
// VxWorksSymTab_6_1 is an adaptation of the vxWorksSymTab script. It was modified by a customer
// to use a single loop, instead of two. It also added demangling of C++ symbol names - at least
// those that Ghidra knows how to demangle.
//
// Extracts all symbols in a VxWorks symbol table and disassembles
// the global functions. Any existing symbols in the Ghidra symbol table
// that collide with symbols defined in the VxWorks symbol table are deleted.
//
//
// The VxWorks symbol table is an array of symbol table entries [0..n-1]
// followed by a 32-bit value that is equal to n (number of sym tbl entries).
// Each entry in the array has the following structure:
@ -48,6 +48,7 @@
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.List;
import ghidra.app.cmd.label.DemanglerCmd;
import ghidra.app.script.GhidraScript;
@ -189,8 +190,11 @@ public class VxWorksSymTab_5_4 extends GhidraScript {
createLabel(symLocAddr, symName, true);
if (symDemangledName != null) {
new DemanglerCmd(symLocAddr, symName).applyTo(currentProgram, monitor);
ghidraSymTbl.removeSymbolSpecial(getSymbol(symName,
currentProgram.getGlobalNamespace()));
List<Symbol> symbols =
getSymbols(symName, currentProgram.getGlobalNamespace());
if (!symbols.isEmpty()) {
ghidraSymTbl.removeSymbolSpecial(symbols.get(0));
}
}
break;
case 4: // Local .text
@ -205,8 +209,11 @@ public class VxWorksSymTab_5_4 extends GhidraScript {
if (symDemangledName != null) {
new DemanglerCmd(symLocAddr, symName).applyTo(currentProgram,
monitor);
ghidraSymTbl.removeSymbolSpecial(getSymbol(symName,
currentProgram.getGlobalNamespace()));
List<Symbol> symbols =
getSymbols(symName, currentProgram.getGlobalNamespace());
if (!symbols.isEmpty()) {
ghidraSymTbl.removeSymbolSpecial(symbols.get(0));
}
}
}
else {
@ -216,8 +223,11 @@ public class VxWorksSymTab_5_4 extends GhidraScript {
if (symDemangledName != null) {
new DemanglerCmd(symLocAddr, symName).applyTo(currentProgram,
monitor);
ghidraSymTbl.removeSymbolSpecial(getSymbol(symName,
currentProgram.getGlobalNamespace()));
List<Symbol> symbols =
getSymbols(symName, currentProgram.getGlobalNamespace());
if (!symbols.isEmpty()) {
ghidraSymTbl.removeSymbolSpecial(symbols.get(0));
}
}
}
break;

View file

@ -46,6 +46,7 @@
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.List;
import ghidra.app.cmd.label.DemanglerCmd;
import ghidra.app.script.GhidraScript;
@ -185,8 +186,11 @@ public class VxWorksSymTab_6_1 extends GhidraScript {
createLabel(symLocAddr, symName, true);
if (symDemangledName != null) {
new DemanglerCmd(symLocAddr, symName).applyTo(currentProgram, monitor);
ghidraSymTbl.removeSymbolSpecial(
getSymbol(symName, currentProgram.getGlobalNamespace()));
List<Symbol> symbols =
getSymbols(symName, currentProgram.getGlobalNamespace());
if (!symbols.isEmpty()) {
ghidraSymTbl.removeSymbolSpecial(symbols.get(0));
}
}
break;
case 4: // Local .text
@ -201,8 +205,11 @@ public class VxWorksSymTab_6_1 extends GhidraScript {
if (symDemangledName != null) {
new DemanglerCmd(symLocAddr, symName).applyTo(currentProgram,
monitor);
ghidraSymTbl.removeSymbolSpecial(
getSymbol(symName, currentProgram.getGlobalNamespace()));
List<Symbol> symbols =
getSymbols(symName, currentProgram.getGlobalNamespace());
if (!symbols.isEmpty()) {
ghidraSymTbl.removeSymbolSpecial(symbols.get(0));
}
}
}
else {
@ -212,8 +219,11 @@ public class VxWorksSymTab_6_1 extends GhidraScript {
if (symDemangledName != null) {
new DemanglerCmd(symLocAddr, symName).applyTo(currentProgram,
monitor);
ghidraSymTbl.removeSymbolSpecial(
getSymbol(symName, currentProgram.getGlobalNamespace()));
List<Symbol> symbols =
getSymbols(symName, currentProgram.getGlobalNamespace());
if (!symbols.isEmpty()) {
ghidraSymTbl.removeSymbolSpecial(symbols.get(0));
}
}
}
break;

View file

@ -23,13 +23,13 @@
//
// Any existing Ghidra symbol table entries that collide with VxWorks symbol
// table entries are deleted. Mangled C++ symbol names are demangled.
//
//
// The VxWorks symbol table is an array [0..n-1] of (struct SYMBOL) entries.
// The table may be immediately followed or preceeded by an (int) vxSymTblLen
// value.
//
// Prerequisites:
//
//
// - Program memory block(s) is(are) aligned with actual load addresses
// (run something like MemAlignARM_LE.java)
//
@ -41,6 +41,8 @@
//
// @category VxWorks
import java.util.List;
import ghidra.app.cmd.disassemble.DisassembleCommand;
import ghidra.app.cmd.label.DemanglerCmd;
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
@ -593,7 +595,7 @@ public class VxWorksSymTab_Finder extends GhidraScript {
* @param symTbl
* @param vxSymbol
* @param tableLen
* @throws Exception
* @throws Exception
*/
private void markSymbolTableLen(Address symTbl, VxSymbol vxSymbol, int symTblLen)
throws Exception {
@ -651,9 +653,11 @@ public class VxWorksSymTab_Finder extends GhidraScript {
if (demangled != null) {
new DemanglerCmd(addr, mangled).applyTo(currentProgram, monitor);
currentProgram.getSymbolTable()
.removeSymbolSpecial(
getSymbol(mangled, currentProgram.getGlobalNamespace()));
List<Symbol> symbols =
getSymbols(mangled, currentProgram.getGlobalNamespace());
if (!symbols.isEmpty()) {
currentProgram.getSymbolTable().removeSymbolSpecial(symbols.get(0));
}
}
return;
@ -735,7 +739,7 @@ public class VxWorksSymTab_Finder extends GhidraScript {
return;
}
// Process VxWorks symbol table entries
// Process VxWorks symbol table entries
println("Processing symbol table entries.");
Address symEntry = symTbl;
for (int i = 0; (i < symTblLen) && !monitor.isCancelled(); i++, symEntry =