Use correct namespace in LocalSymbolMap

This commit is contained in:
caheckman 2020-06-19 16:41:04 -04:00
parent 0d9e25548a
commit 84e4b8c6fe
5 changed files with 27 additions and 24 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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");

View file

@ -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);
} }
} }

View file

@ -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();
} }
/** /**