mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
GP-4976 Only send back <typeref>
This commit is contained in:
parent
cb5ab633de
commit
e80f52c22e
12 changed files with 84 additions and 29 deletions
|
@ -4825,6 +4825,7 @@ int4 ActionInternalStorage::apply(Funcdata &data)
|
||||||
void ActionInferTypes::propagationDebug(Architecture *glb,Varnode *vn,const Datatype *newtype,PcodeOp *op,int4 slot,Varnode *ptralias)
|
void ActionInferTypes::propagationDebug(Architecture *glb,Varnode *vn,const Datatype *newtype,PcodeOp *op,int4 slot,Varnode *ptralias)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
if (!TypeFactory::propagatedbg_on) return;
|
||||||
ostringstream s;
|
ostringstream s;
|
||||||
|
|
||||||
vn->printRaw(s);
|
vn->printRaw(s);
|
||||||
|
@ -5225,9 +5226,11 @@ int4 ActionInferTypes::apply(Funcdata &data)
|
||||||
VarnodeLocSet::const_iterator iter;
|
VarnodeLocSet::const_iterator iter;
|
||||||
|
|
||||||
#ifdef TYPEPROP_DEBUG
|
#ifdef TYPEPROP_DEBUG
|
||||||
|
if (TypeFactory::propagatedbg_on) {
|
||||||
ostringstream s;
|
ostringstream s;
|
||||||
s << "Type propagation pass - " << dec << localcount;
|
s << "Type propagation pass - " << dec << localcount;
|
||||||
data.getArch()->printDebug(s.str());
|
data.getArch()->printDebug(s.str());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (localcount >= 7) { // This constant arrived at empirically
|
if (localcount >= 7) { // This constant arrived at empirically
|
||||||
if (localcount == 7) {
|
if (localcount == 7) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ void CPoolRecord::encode(Encoder &encoder) const
|
||||||
encoder.writeString(ATTRIB_CONTENT, token);
|
encoder.writeString(ATTRIB_CONTENT, token);
|
||||||
encoder.closeElement(ELEM_TOKEN);
|
encoder.closeElement(ELEM_TOKEN);
|
||||||
}
|
}
|
||||||
type->encode(encoder);
|
type->encodeRef(encoder);
|
||||||
encoder.closeElement(ELEM_CPOOLREC);
|
encoder.closeElement(ELEM_CPOOLREC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,16 @@ void FileManage::directoryList(vector<string> &res,const string &dirname,bool al
|
||||||
if (dir == (DIR *)0) return;
|
if (dir == (DIR *)0) return;
|
||||||
entry = readdir(dir);
|
entry = readdir(dir);
|
||||||
while(entry != (struct dirent *)0) {
|
while(entry != (struct dirent *)0) {
|
||||||
if (entry->d_type == DT_DIR) {
|
bool isDirectory = false;
|
||||||
|
if (entry->d_type == DT_DIR)
|
||||||
|
isDirectory = true;
|
||||||
|
else if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) {
|
||||||
|
string path = dirfinal + entry->d_name;
|
||||||
|
struct stat stbuf;
|
||||||
|
stat(path.c_str(), &stbuf);
|
||||||
|
isDirectory = S_ISDIR(stbuf.st_mode);
|
||||||
|
}
|
||||||
|
if (isDirectory) {
|
||||||
string fullname(entry->d_name);
|
string fullname(entry->d_name);
|
||||||
if ((fullname!=".")&&(fullname!="..")) {
|
if ((fullname!=".")&&(fullname!="..")) {
|
||||||
if (allowdot || (fullname[0] != '.'))
|
if (allowdot || (fullname[0] != '.'))
|
||||||
|
|
|
@ -3378,7 +3378,7 @@ void ProtoStoreInternal::encode(Encoder &encoder) const
|
||||||
if (outparam->isTypeLocked())
|
if (outparam->isTypeLocked())
|
||||||
encoder.writeBool(ATTRIB_TYPELOCK,true);
|
encoder.writeBool(ATTRIB_TYPELOCK,true);
|
||||||
outparam->getAddress().encode(encoder);
|
outparam->getAddress().encode(encoder);
|
||||||
outparam->getType()->encode(encoder);
|
outparam->getType()->encodeRef(encoder);
|
||||||
encoder.closeElement(ELEM_RETPARAM);
|
encoder.closeElement(ELEM_RETPARAM);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3406,7 +3406,7 @@ void ProtoStoreInternal::encode(Encoder &encoder) const
|
||||||
if (param->isHiddenReturn())
|
if (param->isHiddenReturn())
|
||||||
encoder.writeBool(ATTRIB_HIDDENRETPARM, true);
|
encoder.writeBool(ATTRIB_HIDDENRETPARM, true);
|
||||||
param->getAddress().encode(encoder);
|
param->getAddress().encode(encoder);
|
||||||
param->getType()->encode(encoder);
|
param->getType()->encodeRef(encoder);
|
||||||
encoder.closeElement(ELEM_PARAM);
|
encoder.closeElement(ELEM_PARAM);
|
||||||
}
|
}
|
||||||
encoder.closeElement(ELEM_INTERNALLIST);
|
encoder.closeElement(ELEM_INTERNALLIST);
|
||||||
|
@ -3422,7 +3422,7 @@ void ProtoStoreInternal::decode(Decoder &decoder,ProtoModel *model)
|
||||||
proto.firstVarArgSlot = -1;
|
proto.firstVarArgSlot = -1;
|
||||||
bool addressesdetermined = true;
|
bool addressesdetermined = true;
|
||||||
|
|
||||||
pieces.push_back( ParameterPieces() ); // Push on placeholder for output pieces
|
pieces.emplace_back(); // Push on placeholder for output pieces
|
||||||
pieces.back().type = outparam->getType();
|
pieces.back().type = outparam->getType();
|
||||||
pieces.back().flags = 0;
|
pieces.back().flags = 0;
|
||||||
if (outparam->isTypeLocked())
|
if (outparam->isTypeLocked())
|
||||||
|
@ -4599,7 +4599,7 @@ void FuncProto::encode(Encoder &encoder) const
|
||||||
if (outparam->isTypeLocked())
|
if (outparam->isTypeLocked())
|
||||||
encoder.writeBool(ATTRIB_TYPELOCK, true);
|
encoder.writeBool(ATTRIB_TYPELOCK, true);
|
||||||
outparam->getAddress().encode(encoder,outparam->getSize());
|
outparam->getAddress().encode(encoder,outparam->getSize());
|
||||||
outparam->getType()->encode(encoder);
|
outparam->getType()->encodeRef(encoder);
|
||||||
encoder.closeElement(ELEM_RETURNSYM);
|
encoder.closeElement(ELEM_RETURNSYM);
|
||||||
encodeEffect(encoder);
|
encodeEffect(encoder);
|
||||||
encodeLikelyTrash(encoder);
|
encodeLikelyTrash(encoder);
|
||||||
|
|
|
@ -155,6 +155,10 @@ void IfaceDecompCapability::registerCommands(IfaceStatus *status)
|
||||||
status->registerCom(new IfcTraceList(),"trace","list");
|
status->registerCom(new IfcTraceList(),"trace","list");
|
||||||
status->registerCom(new IfcBreakjump(),"break","jumptable");
|
status->registerCom(new IfcBreakjump(),"break","jumptable");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TYPEPROP_DEBUG
|
||||||
|
status->registerCom(new IfcTracePropagation(),"trace","propagation");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs over every function in the scope, or any sub-scope , calling
|
/// Runs over every function in the scope, or any sub-scope , calling
|
||||||
|
@ -3586,6 +3590,24 @@ void IfcBreakjump::execute(istream &s)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TYPEPROP_DEBUG
|
||||||
|
|
||||||
|
void IfcTracePropagation::execute(istream &s)
|
||||||
|
|
||||||
|
{
|
||||||
|
string token;
|
||||||
|
s >> ws >> token;
|
||||||
|
if (token == "on")
|
||||||
|
TypeFactory::propagatedbg_on = true;
|
||||||
|
else if (token == "off")
|
||||||
|
TypeFactory::propagatedbg_on = false;
|
||||||
|
else
|
||||||
|
throw IfaceParseError("Must specific on/off");
|
||||||
|
*status->optr << "Data-type propagation trace set to: "<< token << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Execute one command and handle any exceptions.
|
/// Execute one command and handle any exceptions.
|
||||||
/// Error messages are printed to the console. For low-level errors,
|
/// Error messages are printed to the console. For low-level errors,
|
||||||
/// the current function is reset to null
|
/// the current function is reset to null
|
||||||
|
|
|
@ -668,5 +668,14 @@ public:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TYPEPROP_DEBUG
|
||||||
|
|
||||||
|
class IfcTracePropagation : public IfaceDecompCommand {
|
||||||
|
public:
|
||||||
|
virtual void execute(istream &s);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // End namespace ghidra
|
} // End namespace ghidra
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -165,7 +165,7 @@ void ParamMeasure::encode( Encoder &encoder,ElementId &tag,bool moredetail ) con
|
||||||
encoder.openElement(ELEM_ADDR);
|
encoder.openElement(ELEM_ADDR);
|
||||||
vndata.space->encodeAttributes( encoder, vndata.offset, vndata.size );
|
vndata.space->encodeAttributes( encoder, vndata.offset, vndata.size );
|
||||||
encoder.closeElement(ELEM_ADDR);
|
encoder.closeElement(ELEM_ADDR);
|
||||||
vntype->encode(encoder);
|
vntype->encodeRef(encoder);
|
||||||
if( moredetail ) {
|
if( moredetail ) {
|
||||||
encoder.openElement(ELEM_RANK);
|
encoder.openElement(ELEM_RANK);
|
||||||
encoder.writeSignedInteger(ATTRIB_VAL, rank);
|
encoder.writeSignedInteger(ATTRIB_VAL, rank);
|
||||||
|
|
|
@ -38,7 +38,10 @@ int UnitTest::run(set<string> &testNames)
|
||||||
t->func();
|
t->func();
|
||||||
++passed;
|
++passed;
|
||||||
cerr << " passed." << endl;
|
cerr << " passed." << endl;
|
||||||
|
} catch(LowlevelError &err) {
|
||||||
|
cerr << " fail: " << err.explain << endl;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
cerr << " fail" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cerr << "==============================" << endl;
|
cerr << "==============================" << endl;
|
||||||
|
|
|
@ -3026,6 +3026,10 @@ void TypeSpacebase::decode(Decoder &decoder,TypeFactory &typegrp)
|
||||||
// decoder.closeElement(elemId);
|
// decoder.closeElement(elemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TYPEPROP_DEBUG
|
||||||
|
bool TypeFactory::propagatedbg_on = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Initialize an empty container
|
/// Initialize an empty container
|
||||||
/// \param g is the owning Architecture
|
/// \param g is the owning Architecture
|
||||||
TypeFactory::TypeFactory(Architecture *g)
|
TypeFactory::TypeFactory(Architecture *g)
|
||||||
|
@ -4358,7 +4362,7 @@ Datatype *TypeFactory::decodeTypeNoRef(Decoder &decoder,bool forcecore)
|
||||||
break;
|
break;
|
||||||
case TYPE_SPACEBASE:
|
case TYPE_SPACEBASE:
|
||||||
{
|
{
|
||||||
TypeSpacebase tsb((AddrSpace *)0,Address(),glb);
|
TypeSpacebase tsb(glb);
|
||||||
tsb.decode(decoder,*this);
|
tsb.decode(decoder,*this);
|
||||||
if (forcecore)
|
if (forcecore)
|
||||||
tsb.flags |= Datatype::coretype;
|
tsb.flags |= Datatype::coretype;
|
||||||
|
|
|
@ -690,6 +690,8 @@ public:
|
||||||
TypeSpacebase(const TypeSpacebase &op) : Datatype(op) {
|
TypeSpacebase(const TypeSpacebase &op) : Datatype(op) {
|
||||||
spaceid = op.spaceid; localframe=op.localframe; glb=op.glb;
|
spaceid = op.spaceid; localframe=op.localframe; glb=op.glb;
|
||||||
}
|
}
|
||||||
|
/// Constructor for use with decode
|
||||||
|
TypeSpacebase(Architecture *g) : Datatype(0,1,TYPE_SPACEBASE) { spaceid = (AddrSpace *)0; glb = g; }
|
||||||
/// Construct given an address space, scope, and architecture
|
/// Construct given an address space, scope, and architecture
|
||||||
TypeSpacebase(AddrSpace *id,const Address &frame,Architecture *g)
|
TypeSpacebase(AddrSpace *id,const Address &frame,Architecture *g)
|
||||||
: Datatype(0,1,TYPE_SPACEBASE), localframe(frame) { spaceid = id; glb = g; }
|
: Datatype(0,1,TYPE_SPACEBASE), localframe(frame) { spaceid = id; glb = g; }
|
||||||
|
@ -820,6 +822,9 @@ public:
|
||||||
void cacheCoreTypes(void); ///< Cache common types
|
void cacheCoreTypes(void); ///< Cache common types
|
||||||
list<DatatypeWarning>::const_iterator beginWarnings(void) const { return warnings.begin(); } ///< Start of data-type warnings
|
list<DatatypeWarning>::const_iterator beginWarnings(void) const { return warnings.begin(); } ///< Start of data-type warnings
|
||||||
list<DatatypeWarning>::const_iterator endWarnings(void) const { return warnings.end(); } ///< End of data-type warnings
|
list<DatatypeWarning>::const_iterator endWarnings(void) const { return warnings.end(); } ///< End of data-type warnings
|
||||||
|
#ifdef TYPEPROP_DEBUG
|
||||||
|
static bool propagatedbg_on; ///< If \b true, display data-type propagation trace
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The display format for the data-type is changed based on the given format. A value of
|
/// The display format for the data-type is changed based on the given format. A value of
|
||||||
|
|
|
@ -88,8 +88,8 @@ CPUI_DEBUG -- This is the ONE debug switch that should be passed in
|
||||||
#ifdef CPUI_DEBUG
|
#ifdef CPUI_DEBUG
|
||||||
# define OPACTION_DEBUG
|
# define OPACTION_DEBUG
|
||||||
# define PRETTY_DEBUG
|
# define PRETTY_DEBUG
|
||||||
|
# define TYPEPROP_DEBUG
|
||||||
//# define __REMOTE_SOCKET__
|
//# define __REMOTE_SOCKET__
|
||||||
//# define TYPEPROP_DEBUG
|
|
||||||
//# define DFSVERIFY_DEBUG
|
//# define DFSVERIFY_DEBUG
|
||||||
//# define BLOCKCONSISTENT_DEBUG
|
//# define BLOCKCONSISTENT_DEBUG
|
||||||
//# define MERGEMULTI_DEBUG
|
//# define MERGEMULTI_DEBUG
|
||||||
|
|
|
@ -845,7 +845,7 @@ void HighVariable::encode(Encoder &encoder) const
|
||||||
if (symboloffset >= 0)
|
if (symboloffset >= 0)
|
||||||
encoder.writeSignedInteger(ATTRIB_OFFSET, symboloffset);
|
encoder.writeSignedInteger(ATTRIB_OFFSET, symboloffset);
|
||||||
}
|
}
|
||||||
getType()->encode(encoder);
|
getType()->encodeRef(encoder);
|
||||||
for(int4 j=0;j<inst.size();++j) {
|
for(int4 j=0;j<inst.size();++j) {
|
||||||
encoder.openElement(ELEM_ADDR);
|
encoder.openElement(ELEM_ADDR);
|
||||||
encoder.writeUnsignedInteger(ATTRIB_REF, inst[j]->getCreateIndex());
|
encoder.writeUnsignedInteger(ATTRIB_REF, inst[j]->getCreateIndex());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue