mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Use correct namespace in LocalSymbolMap
This commit is contained in:
parent
0d9e25548a
commit
84e4b8c6fe
5 changed files with 27 additions and 24 deletions
|
@ -2479,7 +2479,7 @@ ProtoParameter *ProtoStoreSymbol::setInput(int4 i, const string &nm,const Parame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res->sym == (Symbol *)0) {
|
if (res->sym == (Symbol *)0) {
|
||||||
if (scope->discoverScope(pieces.addr,pieces.type->getSize(),usepoint) != scope)
|
if (scope->discoverScope(pieces.addr,pieces.type->getSize(),usepoint) == (Scope *)0)
|
||||||
usepoint = restricted_usepoint;
|
usepoint = restricted_usepoint;
|
||||||
res->sym = scope->addSymbol(nm,pieces.type,pieces.addr,usepoint)->getSymbol();
|
res->sym = scope->addSymbol(nm,pieces.type,pieces.addr,usepoint)->getSymbol();
|
||||||
scope->setCategory(res->sym,0,i);
|
scope->setCategory(res->sym,0,i);
|
||||||
|
|
|
@ -1326,6 +1326,7 @@ void Funcdata::mapGlobals(void)
|
||||||
vn = *iter++;
|
vn = *iter++;
|
||||||
if (vn->isFree()) continue;
|
if (vn->isFree()) continue;
|
||||||
if (!vn->isPersist()) continue; // Could be a code ref
|
if (!vn->isPersist()) continue; // Could be a code ref
|
||||||
|
if (vn->getSymbolEntry() != (SymbolEntry *)0) continue;
|
||||||
maxvn = vn;
|
maxvn = vn;
|
||||||
Address addr = vn->getAddr();
|
Address addr = vn->getAddr();
|
||||||
Address endaddr = addr + vn->getSize();
|
Address endaddr = addr + vn->getSize();
|
||||||
|
|
|
@ -436,11 +436,12 @@ public class HighFunction extends PcodeSyntaxTree {
|
||||||
* addresses near its entry point.
|
* addresses near its entry point.
|
||||||
*
|
*
|
||||||
* @param id is the id associated with the function symbol
|
* @param id is the id associated with the function symbol
|
||||||
|
* @param namespace is the namespace containing the function symbol
|
||||||
* @param entryPoint pass null to use the function entryPoint, pass an address to force an entry point
|
* @param entryPoint pass null to use the function entryPoint, pass an address to force an entry point
|
||||||
* @param size describes how many bytes the function occupies as code
|
* @param size describes how many bytes the function occupies as code
|
||||||
* @return the XML string
|
* @return the XML string
|
||||||
*/
|
*/
|
||||||
public String buildFunctionXML(long id, Address entryPoint, int size) {
|
public String buildFunctionXML(long id, Namespace namespace, Address entryPoint, int size) {
|
||||||
// Functions aren't necessarily contiguous with the smallest address being the entry point
|
// Functions aren't necessarily contiguous with the smallest address being the entry point
|
||||||
// So size needs to be smaller than size of the contiguous chunk containing the entry point
|
// So size needs to be smaller than size of the contiguous chunk containing the entry point
|
||||||
StringBuilder resBuf = new StringBuilder();
|
StringBuilder resBuf = new StringBuilder();
|
||||||
|
@ -463,7 +464,7 @@ public class HighFunction extends PcodeSyntaxTree {
|
||||||
else {
|
else {
|
||||||
resBuf.append(Varnode.buildXMLAddress(entryPoint)); // Address is forced on XML
|
resBuf.append(Varnode.buildXMLAddress(entryPoint)); // Address is forced on XML
|
||||||
}
|
}
|
||||||
resBuf.append(localSymbols.buildLocalDbXML());
|
localSymbols.buildLocalDbXML(resBuf, namespace);
|
||||||
proto.buildPrototypeXML(resBuf, getDataTypeManager());
|
proto.buildPrototypeXML(resBuf, getDataTypeManager());
|
||||||
if ((jumpTables != null) && (jumpTables.size() > 0)) {
|
if ((jumpTables != null) && (jumpTables.size() > 0)) {
|
||||||
resBuf.append("<jumptablelist>\n");
|
resBuf.append("<jumptablelist>\n");
|
||||||
|
|
|
@ -75,7 +75,8 @@ public class HighFunctionSymbol extends HighSymbol {
|
||||||
public void saveXML(StringBuilder buf) {
|
public void saveXML(StringBuilder buf) {
|
||||||
MappedEntry entry = (MappedEntry) getFirstWholeMap();
|
MappedEntry entry = (MappedEntry) getFirstWholeMap();
|
||||||
String funcString =
|
String funcString =
|
||||||
function.buildFunctionXML(getId(), entry.getStorage().getMinAddress(), entry.getSize());
|
function.buildFunctionXML(getId(), getNamespace(), entry.getStorage().getMinAddress(),
|
||||||
|
entry.getSize());
|
||||||
buf.append(funcString);
|
buf.append(funcString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,31 +325,31 @@ public class LocalSymbolMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return an XML document string representing this local variable map.
|
* Output an XML document representing this local variable map.
|
||||||
|
* @param resBuf is the buffer to write to
|
||||||
|
* @param namespace if the namespace of the function
|
||||||
*/
|
*/
|
||||||
public String buildLocalDbXML() { // Get memory mapped local variables
|
public void buildLocalDbXML(StringBuilder resBuf, Namespace namespace) { // Get memory mapped local variables
|
||||||
StringBuilder res = new StringBuilder();
|
resBuf.append("<localdb");
|
||||||
res.append("<localdb");
|
SpecXmlUtils.encodeBooleanAttribute(resBuf, "lock", false);
|
||||||
SpecXmlUtils.encodeBooleanAttribute(res, "lock", false);
|
SpecXmlUtils.encodeStringAttribute(resBuf, "main", spacename);
|
||||||
SpecXmlUtils.encodeStringAttribute(res, "main", spacename);
|
resBuf.append(">\n");
|
||||||
res.append(">\n");
|
resBuf.append("<scope");
|
||||||
res.append("<scope");
|
SpecXmlUtils.xmlEscapeAttribute(resBuf, "name", func.getFunction().getName());
|
||||||
SpecXmlUtils.xmlEscapeAttribute(res, "name", func.getFunction().getName());
|
resBuf.append(">\n");
|
||||||
res.append(">\n");
|
resBuf.append("<parent>\n");
|
||||||
res.append("<parent>\n");
|
HighFunction.createNamespaceTag(resBuf, namespace);
|
||||||
HighFunction.createNamespaceTag(res, func.getFunction().getParentNamespace());
|
resBuf.append("</parent>\n");
|
||||||
res.append("</parent>\n");
|
resBuf.append("<rangelist/>\n"); // Empty address range
|
||||||
res.append("<rangelist/>\n"); // Empty address range
|
resBuf.append("<symbollist>\n");
|
||||||
res.append("<symbollist>\n");
|
|
||||||
Iterator<HighSymbol> iter = symbolMap.values().iterator();
|
Iterator<HighSymbol> iter = symbolMap.values().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
HighSymbol sym = iter.next();
|
HighSymbol sym = iter.next();
|
||||||
HighSymbol.buildMapSymXML(res, sym);
|
HighSymbol.buildMapSymXML(resBuf, sym);
|
||||||
}
|
}
|
||||||
res.append("</symbollist>\n");
|
resBuf.append("</symbollist>\n");
|
||||||
res.append("</scope>\n");
|
resBuf.append("</scope>\n");
|
||||||
res.append("</localdb>\n");
|
resBuf.append("</localdb>\n");
|
||||||
return res.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue