You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(21) |
Aug
|
Sep
|
Oct
(15) |
Nov
|
Dec
|
2007 |
Jan
(22) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <wjh...@us...> - 2007-01-30 11:01:33
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv12635 Modified Files: desquirr.vcproj makefile.gnu Log Message: change to use boost_1_33_0 and ida500 Index: desquirr.vcproj =================================================================== RCS file: /cvsroot/desquirr/desquirr/desquirr.vcproj,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- desquirr.vcproj 30 Jan 2007 09:50:18 -0000 1.1 +++ desquirr.vcproj 30 Jan 2007 11:01:21 -0000 1.2 @@ -68,7 +68,7 @@ </Configuration> <Configuration Name="Release|Win32" - OutputDirectory="Release" + OutputDirectory="c:\local\ida500\plugins" IntermediateDirectory="Release" ConfigurationType="2" CharacterSet="2"> @@ -79,7 +79,7 @@ RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3" - Detect64BitPortabilityProblems="TRUE" + Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="3"/> <Tool Name="VCCustomBuildTool"/> @@ -87,7 +87,7 @@ Name="VCLinkerTool" AdditionalOptions="/export:PLUGIN" AdditionalDependencies="$(OutDir)\..\idasdk\libvc.w32\ida.lib" - OutputFile="$(OutDir)/desquirr.dll" + OutputFile="$(OutDir)/desquirr.plw" LinkIncremental="1" GenerateDebugInformation="TRUE" SubSystem="2" Index: makefile.gnu =================================================================== RCS file: /cvsroot/desquirr/desquirr/makefile.gnu,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- makefile.gnu 30 Jan 2007 09:50:26 -0000 1.1 +++ makefile.gnu 30 Jan 2007 11:01:21 -0000 1.2 @@ -1,15 +1,18 @@ # author: Willem Hengeveld <it...@xs...> # web: http://www.xs4all.nl/~itsme/projects/disassemblers/ida/idp-Makefile # -# makefile for gnu/cygwin make, using msvc compiler, +# makefile for gnu/cygwin make, using msvc compiler, or the gnu c compiler # needs environment setup with 'vcvars32.bat' ( from vstudio ) # # also: -# expects IDA to be installed in c:\local\ida490 -# expects the boost library to be installed in c:\local\boost\boost_1_32_0 +# expects IDA to be installed in c:\local\ida500 +# expects the boost library to be installed in c:\local\boost\boost_1_33_0 # and having the cygwin tools installed # -# NOTE: on ida 4.8 has a problem in libgcc.w32/ida.a +# NOTE: +# about using gcc: it does not work. +# +# on ida 4.8 has a problem in libgcc.w32/ida.a # where the compiler wants a '_qsnprintf' in the .objs # but the datarescue supplied ida.a lib contains '_qsnprintf@0' # @@ -35,6 +38,9 @@ # # BUG: the gcc compile crashes somewhere with a stack corruption. # +# +# the microsoft C compiler works fine. +# USEMSC=1 ifdef USEMSC @@ -44,6 +50,7 @@ endif idasdk=c:\local\ida500\idasdk +boost=c:/local/boost/boost_1_33_0 .SUFFIXES: .SUFFIXES: .cpp .obj .plw @@ -63,7 +70,7 @@ NOWARN=-wd4619 -wd4514 -wd4710 -wd4244 -wd4242 -wd4127 -wd4668 -wd4146 -wd4820 -wd4217 CDEFS=-DWIN32 -D_USRDLL -D__NT__ -D__IDP__ -DMAXSTR=1024 -CINCS=-I $(idasdk)\include -I c:/local/boost/boost_1_33_0 -I $(idasdk)\module +CINCS=-I $(idasdk)\include -I $(boost) -I $(idasdk)\module COPTS=-GX -GR -Gz -nologo -Zi LDLIBS=/libpath:$(idasdk)\LIBVC.W32 $(idasdk)\LIBVC.W32\ida.lib |
From: <wjh...@us...> - 2007-01-30 10:56:51
|
Update of /cvsroot/desquirr/desquirr/docs In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv10795 Added Files: ChangeLog Log Message: history of changes --- NEW FILE: ChangeLog --- Tue Jan 30 11:42:30 WEST 2007 - fixed truncated ida message display output - improved expression readability, by writing brackets only when needed according to the operator precendence rules - arm decompiler now assumes r0 .. r3 are the parameters. - improved handling of arm shift operators - arm: now ignoring constant pools embedded in code - added support for several missing arm opcodes: ldrpc, addsp, condition codes - fixed some nullptr ref bugs - added msvc8 project files - added gnumake makefile to build with msvc8 - improved global variable / label naming Mon Oct 17 13:02:05 WEDT 2005 - fixed arm 'S' handling: changed && to & Sun Oct 16 08:17:34 WEDT 2005 - made ida 4.9 compatible - fixed bug where push #imm was counted with x86 func prolog. - added support for arm:MOVL macro instruction - improved EscapeAsciiString - added flag to process all functions in a file. - made to compile ( but not yet run ) with gcc: * added virtual destructors * split declaration / init of PLUGIN. * added some ifndef GCC around watcom specific stuff. - renamed 'Call' to 'CallExpression' - renamed 'Global' to 'GlobalVariable' - added dump functions for nodes, instructions, expressions. - changed several const char* to std::string - added some warnings of unexpected conditions - GlobalVariable::GetName now generates name when name not found. - added several 'const' modifiers. - changed several std::string (byval) params, into const std::string&. (byref) Fri Jul 23 WEDT 2005 - split off x86 stuff into 'ida-x86.cpp' - renamed LowLevelAnalysis to X86Analysis - changed deprecated #include <strstream> to #include <sstream> - removed 'using namespace std;' directives, .. added 'std::' where needed. - added idaapi to the public functions, for ida4.80 compatibility - type inconsistancy in 'CreateFrom', GetString, GetName in expression.hpp / expression.cpp, changed Addr to ea_t - moved *StackVar* function decls to idapro.hpp - removed use of strcpy from RegisterName, and ConditionOp - use same register numbering scheme as arm processor module - use named constants for register index. - fixed crash, when isStkVar(flags, 1) and isStkVar(flags, 2) are both true. while only operand==2 is actually the right one. - changed snprintf into qsnprintf - changed GetStackVariableName to early-exit style - more return code checking - fixed call to get_ti to be ida4.80 compatible - added 'const' and &reference to several BoolArray methods, so it compiles with gcc too. - changed constructor initializer order to reflect real init order. in Location() - changed 'const char* const RegisterName()' to 'std::string RegisterName() const' Fri Jul 22 21:20:28 WEDT 2005 - no compiles both for ida470 and ida480 - MLA now decompiles correctly - added several warnings for incorrectly handled cases TODO: - register index is now a mix of int, unsigned short, short. - INVALID_ADDR should be of type Addr - include stl headers before ida's. ... otherwise strcpy will be redefined and compile fails under gcc. - a situation like this is not handled properly: l1: push #1 jmp L3 l2: push #2 l3: call fn - change (reg<<16)>>16 to typecast: (WORD)reg - add code to simplify expressions. - def/use chains should also view local vars + globals. - TODO: i think i should make a CallExpression object, instead of an assignment(reg, call(params)) and handle exprs+return regs. later - TODO: remark all default params from the .hpp in the .cpp files. - TODO: review all "" and NULL ... change to something sensible ... like throw exception - TODO; change most 'return false' to throw exception. - TODO: 'xyz_type' and 'switch' should not be used. ... everything should be solved virtually. - TODO: check if it is better to return const& than return value? - TODO: * make Register, Location, StringLiteral subclass of Variable * change char register to type Location * change BoolArray, reg2addr_map to VariableSet, Variable2addr_map Instruction::Uses(Variable var) returns true if ins uses var. ( etc. also for Defines, etc. ) - change static_cast's to dynamic_cast's - shared_from_this * only on the leaf nodes of the class hierarchy. * not in destructor/constructor * base classes need to be abstract - get rid of Frontend::Get construction - what is the 'erasepool' good for? - need some kind of way to note that a change to AL, also changes AX, and EAX. but not AH. - Instruction::Return should not fix the return register. ... it should be derived from du-analysis of entir func. - investigate o_mem decoding in IdaArm - arm: add Rx, BP, #imm should be reference to stackver. - arm: sub Rx, BP, #imm should be reference to stackver. - seemingly unused procedure params now get deleted, - seemingly unused array members now get deleted. - in several cases the condition code is not checked. - add support for structs. FIXED: - arm: add Rx, SP, #imm now translates to reference to stackvar. - array index is now calculated properly for stackvars. |
From: <wjh...@us...> - 2007-01-30 10:56:39
|
Update of /cvsroot/desquirr/desquirr/docs In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv10785 Added Files: BUILD-INSTRUCTIONS.txt Log Message: build instructions --- NEW FILE: BUILD-INSTRUCTIONS.txt --- Build instructions for desquirr PREREQUISITES: * expects IDA to be installed in c:\local\ida500 * expects the http://www.boost.org library to be installed in c:\local\boost\boost_1_33_0 * the http://www.cygwin.com tools are installed * the microsoft compiler. I have not tried building desquirr with the watcom or borland compilers PATCH SDK * in the IDASDK, in 'include/intel.hpp', change the line line: #include "../idaidp.hpp" into: #include "idaidp.hpp" BUILDING: with makefile.gnu * run 'vcvars32.bat' to setup the environment variables for the msvc compiler * run 'make -f makefile.gnu' to build the plugin * run 'make -f makefile.gnu install' to install the plugin in the ida plugins directory. with visualstudio * load desquirr.sln in visualstudio 2003 * build solution TROUBLESHOOTING: * link gives an error message: LINK: extra operand `/export:PLUGIN' -> this means you did not run the vcvars32.bat file, and the gnu link was found instead of microsoft's link |
From: <wjh...@us...> - 2007-01-30 10:55:58
|
Update of /cvsroot/desquirr/desquirr/docs In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv10414/docs Log Message: Directory /cvsroot/desquirr/desquirr/docs added to the repository |
From: <wjh...@us...> - 2007-01-30 09:50:30
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv18292 Added Files: makefile.gnu Log Message: msvc8 + gnu make makefile --- NEW FILE: makefile.gnu --- # author: Willem Hengeveld <it...@xs...> # web: http://www.xs4all.nl/~itsme/projects/disassemblers/ida/idp-Makefile # # makefile for gnu/cygwin make, using msvc compiler, # needs environment setup with 'vcvars32.bat' ( from vstudio ) # # also: # expects IDA to be installed in c:\local\ida490 # expects the boost library to be installed in c:\local\boost\boost_1_32_0 # and having the cygwin tools installed # # NOTE: on ida 4.8 has a problem in libgcc.w32/ida.a # where the compiler wants a '_qsnprintf' in the .objs # but the datarescue supplied ida.a lib contains '_qsnprintf@0' # # with ida 4.9 everything compiles and builds just fine # .. but still has an unsolved stackcorruption bug. # # in order for the gcc compile to succeed, in # /usr/lib/gcc/i686-pc-mingw32/3.4.4/include/c++/bits/locale_classes.h # you need to change line 579: # std::strcpy(_M_tmp_names[__i], "*"); # into: # _M_tmp_names[__i][0]= '*'; # _M_tmp_names[__i][1]= 0; # # and /usr/lib/gcc/i686-pc-mingw32/3.4.4/include/c++/i686-pc-mingw32/bits/time_members.h # in line 59: # std::strcpy(__tmp, __s); # into: # for (int i=std::strlen(__s) ; i>=0 ; i--) # __tmp[i]= __s[i]; # this avoids the use of strcpy which is redefined to dont_use_strcpy by the idasdk/include/pro.h file. # # BUG: the gcc compile crashes somewhere with a stack corruption. # USEMSC=1 ifdef USEMSC objdir=buildmsc else objdir=buildgcc endif idasdk=c:\local\ida500\idasdk .SUFFIXES: .SUFFIXES: .cpp .obj .plw # microsoft's headers are loaded with warnings: #C4514: 'uint128::uint128' : unreferenced inline function has been removed #C4710: function 'int __stdcall getreg(unsigned long,int)' not inlined #C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data #C4242: '=' : conversion from 'int' to 'ushort', possible loss of data #C4127: conditional expression is constant #C4146: unary minus operator applied to unsigned type, result still unsigned #C4820: '__stat64' : '4' bytes padding added after member '__stat64::st_rdev' #C4217: member template functions cannot be used for copy-assignment or copy-construction #C4668: '_MT' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' #C4619: #pragma warning : there is no warning number '4284' # disabling them all, to get a more readable compiler output. NOWARN=-wd4619 -wd4514 -wd4710 -wd4244 -wd4242 -wd4127 -wd4668 -wd4146 -wd4820 -wd4217 CDEFS=-DWIN32 -D_USRDLL -D__NT__ -D__IDP__ -DMAXSTR=1024 CINCS=-I $(idasdk)\include -I c:/local/boost/boost_1_33_0 -I $(idasdk)\module COPTS=-GX -GR -Gz -nologo -Zi LDLIBS=/libpath:$(idasdk)\LIBVC.W32 $(idasdk)\LIBVC.W32\ida.lib LDFLAGS=/nologo /dll /export:PLUGIN /debug # msvc 12.00 does not support -Wall yet -> use -W4. # msvc 13.10 does support it. # $(objdir)/%.obj: %.cpp ifdef USEMSC @CL -c -W3 $(NOWARN) $(COPTS) $(CINCS) $(CDEFS) -Fo$@ $< else @g++ -c -Wall $(CINCS) $(CDEFS) -mrtd -mno-cygwin -o $@ $< endif all: $(objdir) $(objdir)/desquirr.plw $(objdir): mkdir -p $(objdir) $(objdir)/desquirr.plw: $(objdir)/desquirr.obj $(objdir)/instruction.obj $(objdir)/dataflow.obj $(objdir)/node.obj $(objdir)/expression.obj $(objdir)/idapro.obj $(objdir)/codegen.obj $(objdir)/usedefine.obj $(objdir)/function.obj $(objdir)/frontend.obj $(objdir)/ida-arm.obj $(objdir)/ida-x86.obj ifdef USEMSC @LINK $(LDFLAGS) $(LDLIBS) $^ /out:$@ /map:desquirr.map else echo "EXPORTS" >$(objdir)/desquirr.def echo " _PLUGIN @1" >>$(objdir)/desquirr.def @g++ -Wl,--dll -shared -mno-cygwin $^ $(idasdk)/libgcc.w32/ida.a -o $@ --def $(objdir)/desquirr.def endif clean: -rm -rf buildgcc buildmsc Debug Release install: $(objdir)/desquirr.plw cp $(objdir)/desquirr.plw $(idasdk)/../plugins test: install $(idasdk)/../idag.exe testcode\example-block-structure.idb |
From: <wjh...@us...> - 2007-01-30 09:50:21
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv18257 Added Files: desquirr.sln desquirr.vcproj Log Message: visualstudio 2003 project files --- NEW FILE: desquirr.sln --- Microsoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "desquirr", "desquirr.vcproj", "{06B14F62-203A-4012-8A03-DE797560AC0C}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {06B14F62-203A-4012-8A03-DE797560AC0C}.Debug.ActiveCfg = Debug|Win32 {06B14F62-203A-4012-8A03-DE797560AC0C}.Debug.Build.0 = Debug|Win32 {06B14F62-203A-4012-8A03-DE797560AC0C}.Release.ActiveCfg = Release|Win32 {06B14F62-203A-4012-8A03-DE797560AC0C}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal --- NEW FILE: desquirr.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.10" Name="desquirr" ProjectGUID="{06B14F62-203A-4012-8A03-DE797560AC0C}" Keyword="Win32Proj"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="c:\local\ida500\plugins" IntermediateDirectory="Debug" ConfigurationType="2" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" InlineFunctionExpansion="1" AdditionalIncludeDirectories="$(OutDir)\..\idasdk\include;c:/local/boost/boost_1_33_0;$(OutDir)\..\idasdk\module" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;__IDP__;__NT__;MAXSTR=1024" MinimalRebuild="TRUE" BasicRuntimeChecks="3" SmallerTypeCheck="TRUE" RuntimeLibrary="5" BufferSecurityCheck="TRUE" RuntimeTypeInfo="FALSE" UsePrecompiledHeader="0" WarningLevel="4" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="3"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalOptions="/export:PLUGIN" AdditionalDependencies="$(OutDir)\..\idasdk\libvc.w32\ida.lib" OutputFile="$(OutDir)/desquirr.plw" LinkIncremental="2" GenerateDebugInformation="TRUE" ProgramDatabaseFile="$(OutDir)/desquirr.pdb" SubSystem="2" ImportLibrary="$(OutDir)/desquirr.lib" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="2" CharacterSet="2"> <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="$(OutDir)\..\idasdk\include;c:/local/boost/boost_1_33_0;$(OutDir)\..\idasdk\module" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;__IDP__;__NT__;MAXSTR=1024" RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" DebugInformationFormat="3"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalOptions="/export:PLUGIN" AdditionalDependencies="$(OutDir)\..\idasdk\libvc.w32\ida.lib" OutputFile="$(OutDir)/desquirr.dll" LinkIncremental="1" GenerateDebugInformation="TRUE" SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" ImportLibrary="$(OutDir)/desquirr.lib" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> <File RelativePath=".\codegen.cpp"> </File> <File RelativePath=".\dataflow.cpp"> </File> <File RelativePath=".\desquirr.cpp"> </File> <File RelativePath=".\expression.cpp"> </File> <File RelativePath=".\frontend.cpp"> </File> <File RelativePath=".\function.cpp"> </File> <File RelativePath=".\ida-arm.cpp"> </File> <File RelativePath=".\ida-x86.cpp"> </File> <File RelativePath=".\idapro.cpp"> </File> <File RelativePath=".\instruction.cpp"> </File> <File RelativePath=".\node.cpp"> </File> <File RelativePath=".\usedefine.cpp"> </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> <File RelativePath=".\analysis.hpp"> </File> <File RelativePath=".\codegen.hpp"> </File> <File RelativePath=".\dataflow.hpp"> </File> <File RelativePath=".\desquirr.hpp"> </File> <File RelativePath=".\expression.hpp"> </File> <File RelativePath=".\frontend.hpp"> </File> <File RelativePath=".\function.hpp"> </File> <File RelativePath=".\ida-arm.hpp"> </File> <File RelativePath=".\ida-arm2.hpp"> </File> <File RelativePath=".\ida-x86.hpp"> </File> <File RelativePath=".\idainternal.hpp"> </File> <File RelativePath=".\idapro.hpp"> </File> <File RelativePath=".\instruction.hpp"> </File> <File RelativePath=".\node.hpp"> </File> <File RelativePath=".\usedefine.hpp"> </File> <File RelativePath=".\VariableSet.hpp"> </File> <File RelativePath=".\x86.hpp"> </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> </Filter> </Files> <Globals> </Globals> </VisualStudioProject> |
From: <wjh...@us...> - 2007-01-30 09:50:03
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17865 Modified Files: makefile Log Message: removed clean target, since it is already in plugin.mak Index: makefile =================================================================== RCS file: /cvsroot/desquirr/desquirr/makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- makefile 23 Jul 2005 09:51:29 -0000 1.4 +++ makefile 30 Jan 2007 09:49:59 -0000 1.5 @@ -1,3 +1,4 @@ +__CFLAGS=-Ic:\local\boost\boost_1_33_0 PROC=desquirr SRC1=instruction SRC2=dataflow @@ -59,9 +60,3 @@ install: $(BINARY) -copy $(BINARY) c:\ida\idapro\plugins\ -clean: - -del $(F)*$(O) - -del $(BINARY) - -del $(PROC).mpb - - |
From: <wjh...@us...> - 2007-01-30 09:49:54
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17849 Modified Files: usedefine.cpp Log Message: for arm use R0-R3 as function parameters Index: usedefine.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/usedefine.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- usedefine.cpp 15 Oct 2005 23:56:03 -0000 1.2 +++ usedefine.cpp 30 Jan 2007 09:49:50 -0000 1.3 @@ -22,6 +22,7 @@ // $Id$ #include "usedefine.hpp" #include "node.hpp" +#include "idapro.hpp" #include "instruction.hpp" #include "expression.hpp" @@ -108,7 +109,23 @@ Define(instruction, 0); } - Use(instruction, 1); + if (instruction.Operand(1)->IsType(Expression::CALL)) { + if (!static_cast<IdaPro&>(Frontend::Get()).ParametersOnStack()) { + CallExpression* call= static_cast<CallExpression*>(instruction.Operand(1).get()); + if (call->ParameterCount()==CallExpression::UNKNOWN_PARAMETER_COUNT) + call->ParameterCount(4); + int i= 0; + while (i < 4 && i < call->ParameterCount()) { + call->AddParameter( Register::Create(i) ); + i++; + } + } + Use(instruction, 1); + Define(instruction, 1); + } + else { + Use(instruction, 1); + } EndInstruction(instruction); } |
From: <wjh...@us...> - 2007-01-30 09:49:45
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17837 Modified Files: node.hpp Log Message: fixed some NULL ptr ref bugs in node dumping Index: node.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/node.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- node.hpp 15 Oct 2005 23:56:10 -0000 1.6 +++ node.hpp 30 Jan 2007 09:49:41 -0000 1.7 @@ -103,7 +103,7 @@ { os << boost::format("node %08lx-%08lx #insn=%d") % Address() - % (Instructions().back()->Address()) + % (Instructions().size() ? Instructions().back()->Address() : 0) % Instructions().size(); os << " use=" << Uses(); os << " def=" << Definitions(); @@ -332,7 +332,7 @@ { Node::print(os); os << boost::format("JUMP target=%08lx\n") - % Successor(0).get(); + % SuccessorAddress(0); } static Node_ptr CreateFrom(Instruction_ptr i, @@ -353,8 +353,8 @@ { Node::print(os); os << boost::format("CONDJUMP target=%08lx follow=%08lx\n") - % Successor(0).get() - % Successor(1).get(); + % SuccessorAddress(0) + % SuccessorAddress(1); } @@ -377,7 +377,7 @@ { Node::print(os); os << boost::format("FALLTHROUGH follow=%08lx\n") - % Successor(0).get(); + % SuccessorAddress(0); } @@ -413,8 +413,8 @@ { Node::print(os); os << boost::format("CALL target=%08lx follow=%08lx\n") - % Successor(0).get() - % Successor(1).get(); + % SuccessorAddress(0) + % SuccessorAddress(1); } }; |
From: <wjh...@us...> - 2007-01-30 09:49:34
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17823 Modified Files: instruction.cpp instruction.hpp Log Message: added operator<< to write duchain Index: instruction.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/instruction.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- instruction.cpp 23 Jul 2005 09:23:08 -0000 1.7 +++ instruction.cpp 30 Jan 2007 09:49:30 -0000 1.8 @@ -157,4 +157,33 @@ }/*}}}*/ +// outputs: +// { var:[addr, addr], var:[addr, addr] } +std::ostream& operator<< (std::ostream& os, const RegisterToAddress_map& vs) +{ + unsigned short reg= 0xffff; + bool bFirstAddr= true; + os << "{ "; + for (RegisterToAddress_map::const_iterator i=vs.begin() ; i!=vs.end() ; ++i) + { + if (reg!=0xffff && reg!=(*i).first) + os << "], "; + if (reg==0xffff || reg!=(*i).first) { + reg = (*i).first; + os << "R" << reg; + os << "["; + bFirstAddr= true; + } + + if (!bFirstAddr) + os << ", "; + os << boost::format("%08lx") % (*i).second; + bFirstAddr= false; + } + if (!bFirstAddr) + os << "] "; + os << "}"; + + return os; +} Index: instruction.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/instruction.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- instruction.hpp 15 Oct 2005 23:55:56 -0000 1.8 +++ instruction.hpp 30 Jan 2007 09:49:30 -0000 1.9 @@ -52,6 +52,8 @@ typedef std::list<Expression*> ExpressionList; +std::ostream& operator<< (std::ostream& os, const RegisterToAddress_map& vs); + //typedef std::list<op_t> OperandList; /** @@ -349,6 +351,7 @@ os << " def=" << Definitions(); os << " last=" << LastDefinitions(); os << " flag=" << FlagDefinitions(); + os << " chain=" << DuChain(); } protected: Instruction(InstructionType type, Addr ea) @@ -559,6 +562,7 @@ } Operand( Dummy::Create() ); + Definitions().Clear(reg); return false; @@ -869,6 +873,5 @@ } };/*}}}*/ - #endif // _INSTRUCTION_HPP |
From: <wjh...@us...> - 2007-01-30 09:49:27
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17806 Modified Files: idapro.hpp Log Message: added 'parametersOnStack' calling convention flag to cpu Index: idapro.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/idapro.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- idapro.hpp 15 Oct 2005 23:55:49 -0000 1.5 +++ idapro.hpp 30 Jan 2007 09:49:20 -0000 1.6 @@ -48,6 +48,7 @@ virtual void FillList(func_t* function, Instruction_list& instructions) = 0; void DumpInsn(Addr address); + virtual bool ParametersOnStack() = 0; virtual void DumpInsn(insn_t& insn) = 0; static void LoadCallTypeInformation(CallExpression* call); @@ -58,6 +59,14 @@ extern std::string GetStackVariableName(ea_t ea, int operand, int *pIndex); extern Expression_ptr CreateStackVariable(insn_t &insn, int operand); +// used in expression.cpp GlobalVariable::CreateFrom +extern Expression_ptr CreateGlobalVariable(const insn_t &insn, int operand); +extern Expression_ptr CreateVariable(const insn_t &insn, int operand); +// used in ida-*.cpp CreateLabel / MakeLowLevelList +extern std::string GetLocalCodeLabel(ea_t ea, int *pIndex); +extern Expression_ptr CreateLocalCodeReference(ea_t ea); +extern Instruction_ptr CreateLocalCodeLabel(ea_t ea); +extern Expression_ptr CreateGlobalCodeLabel(ea_t ea); #endif |
From: <wjh...@us...> - 2007-01-30 09:49:16
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17791 Modified Files: idapro.cpp Log Message: variable-index now is offset to last named item. added structure resolving for global variables. added more label naming functions Index: idapro.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/idapro.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- idapro.cpp 15 Oct 2005 23:55:42 -0000 1.11 +++ idapro.cpp 30 Jan 2007 09:49:12 -0000 1.12 @@ -47,37 +47,14 @@ return get_ti(ea, buf, fnames); } #endif - -std::string GetStackVariableName(ea_t ea, int operand, int* pIndex)/*{{{*/ +std::string get_struct_path(struc_t *struc, int offset, int *pIndex) { + member_t* member = NULL; /* must live here, not inside while */ std::ostringstream buffer; bool first = true; - if (pIndex) - *pIndex = 0; - - func_t* func = get_func(ea); - if (func==NULL) - { - msg("ERROR - get_func(%08lx)\n", ea); - return ""; - } - - - ulong offset = calc_stkvar_struc_offset(func, ea, operand); - if (offset==BADADDR) { - msg("ERROR in calc_stkvar_struc_offset(%08lx, %08lx, %d)\n", func->startEA, ea, operand); - return ""; - } - - struc_t* struc = get_frame(func); - if (struc==NULL) { - msg("ERROR: function has no frame\n"); - return ""; - } - - member_t* member = NULL; /* must live here, not inside while */ - + // todo: this is not working as intended. needs fixing. + int totalsoff= 0; while (struc) { member = get_member(struc, offset); @@ -94,6 +71,7 @@ else buffer << "NO_NAME"; + totalsoff = offset - member->soff; struc = get_sptr(member); } else @@ -102,43 +80,250 @@ } } - if (member && (offset - member->soff) != 0) + //if (member && (offset - member->soff) != 0) + if (totalsoff) { - //msg("%p Stack variable: offset=%i, member->soff=%i\n", ea, offset, member->soff); + //message("%p Stack variable: offset=%i, member->soff=%i\n", ea, offset, member->soff); if (pIndex) - *pIndex = offset - member->soff; + *pIndex = totalsoff; // offset - member->soff; } return buffer.str(); }/*}}}*/ +// used from CreateStackVariable +std::string GetStackVariableName(const insn_t &insn, int operand, int* pIndex)/*{{{*/ +{ + if (pIndex) + *pIndex = 0; + + ea_t ea= insn.ea; + func_t* func = get_func(ea); + if (func==NULL) + { + message("ERROR - get_func(%08lx)\n", ea); + return ""; + } + + + ulong offset = calc_stkvar_struc_offset(func, ea, operand); + if (offset==BADADDR) { + message("ERROR in calc_stkvar_struc_offset(%08lx, %08lx, %d)\n", func->startEA, ea, operand); + return ""; + } + + struc_t* struc = get_frame(func); + if (struc==NULL) { + message("ERROR: function has no frame\n"); + return ""; + } + return get_struct_path(struc, offset, pIndex); +} + + +// returns name such that get_func_name(ea) == name and get_func(ea).startEA+*pIndex == ea +// used by GetGlobalVariableName +std::string GetGlobalCodeLabel(ea_t ea, int *pIndex)/*{{{*/ +{ + // return funcname + offset + char name[MAXSTR]; + + func_t *func= get_func(ea); + if (func==NULL) { + message("%p Warning: referenced code offset not in a function\n", ea); + return ""; + } + if (get_func_name(ea, name, MAXSTR)) { + *pIndex= ea - func->startEA; + return std::string(name); + } + else { + message("%p Warning: referenced code offset not in a function\n", ea); + return ""; + } +} + +// returns name such that get_name_ea(ea - *pIndex) == name +std::string GetLocalCodeLabel(ea_t ea, int *pIndex)/*{{{*/ +{ + char name[MAXSTR]; + + func_t* pfn= get_func(ea); + func_item_iterator_t fii; + for ( bool ok=fii.set(pfn, ea); ok; ok=fii.prev_addr() ) { + ea_t lea = fii.current(); + + if (get_name(ea, lea, name, sizeof(name))) { + *pIndex= ea-lea; + if (*pIndex) + message("Unexpected locallabel with name=%s index=%d\n", name, *pIndex); + return std::string(name); + } + else { + break; + // message("%p %p -- fii next\n", ea, lea); + } + } + + message("%p Warning: label without name\n", ea); + return ""; +}/*}}}*/ + +Instruction_ptr CreateLocalCodeLabel(ea_t ea) +{ + int index; + std::string name= GetLocalCodeLabel(ea, &index); + if (index || name.empty()) { + name.resize(32); + name.resize(qsnprintf(&name[0], name.size(), "loc_%X", ea)); + message("NOTE: created new label %s\n", name.c_str()); + } + Instruction_ptr instr; + // todo: think of a better way to represent local function labels. + instr.reset(new Label(ea, name.c_str())); + return instr; +} + +Expression_ptr CreateLocalCodeReference(ea_t ea) +{ + int index; + std::string name= GetLocalCodeLabel(ea, &index); + if (index || name.empty()) { + name.resize(32); + name.resize(qsnprintf(&name[0], name.size(), "loc_%X", ea)); + message("NOTE: created new label %s\n", name.c_str()); + } + Expression_ptr expr; + // todo: think of a better way to represent local function labels. + expr.reset(new GlobalVariable(name, 0, ea)); + return expr; +} +Expression_ptr CreateGlobalCodeLabel(ea_t ea) +{ + int index; + std::string name= GetGlobalCodeLabel(ea, &index); + if (name.empty()) { + name.resize(32); + name.resize(qsnprintf(&name[0], name.size(), "proc_%X", ea)); + message("NOTE: created new function name %s\n", name.c_str()); + } + else if (index!=0) { + name.resize(name.size()+16); + name.resize(qsnprintf(&name[0], name.size(), "%s+0x%X", name.c_str(), index)); + message("NOTE: using func+offs name: %s\n", name.c_str()); + } + Expression_ptr expr; + expr.reset(new GlobalVariable(name, 0, ea)); + return expr; +} + +// todo: figure out how to get the structure type of the data at a specific offset. +std::string GetGlobalVariableName(ea_t ea, int* pIndex)/*{{{*/ +{ + std::ostringstream buffer; + + if (pIndex) + *pIndex = 0; + + flags_t flags= ::getFlags(ea); + + if (isCode(flags)) { + return GetGlobalCodeLabel(ea, pIndex); + } +/* + else if (!isData(flags)) { + message("%p Warning: referencing unknown item flags=%08lx\n", ea, flags); + } + else if (isStruct(flags)) { + tid_t tid= + struc_t* struc = get_struc(tid); + // get_stroff_path(ea_t ea, int n, tid_t *path, adiff_t *delta) + } +*/ + else { + char name[MAXSTR]; + if (get_name(BADADDR, ea, name, sizeof(name))) { + return name; + } + else { + ea_t head= prev_head(ea, 0); + + std::string headname; headname.resize(MAXSTR); + if (!get_name(BADADDR, head, &headname[0], headname.size())) { + headname.resize(qsnprintf(&headname[0], headname.size(), "gvar_%X", head)); + } + else { + headname.resize(strlen(&headname[0])); + } + tid_t tid= get_strid(head); + struc_t *struc= get_struc(tid); + return headname + "." + get_struct_path(struc, ea-head, pIndex); + } + } +}/*}}}*/ +bool is_local_to_function(ea_t funcea, ea_t ea) +{ + func_t *func= get_func(funcea); + return func_contains(func, ea); +} +Expression_ptr CreateVariable(const insn_t &insn, int operand) +{ + ea_t ea= insn.Operands[operand].addr; + + if (is_local_to_function(insn.ea, ea)) + return CreateLocalCodeReference(ea); + else + return CreateGlobalVariable(insn, operand); +} +Expression_ptr CreateGlobalVariable(const insn_t &insn, int operand) +{ + Expression_ptr expr; + + ea_t ea= insn.Operands[operand].addr; + + int index; + std::string name= GetGlobalVariableName(ea, &index); + + if (name.empty()) { + name.resize(32); + name.resize(qsnprintf(&name[0], name.size(), "gvar_%X", ea)); + message("NOTE: created new globalvar %s\n", name.c_str()); + } + + expr.reset(new GlobalVariable(name, index, ea)); + + return expr; +} + + + Expression_ptr CreateStackVariable(insn_t& insn, int operand)/*{{{*/ { Expression_ptr result; int index; - std::string name = GetStackVariableName(insn.ea, operand, &index); + std::string name = GetStackVariableName(insn, operand, &index); if (name.empty()) { // Try to add a stack variable and try again! -// msg("%p Warning: trying to create stack variable\n", insn.ea); +// message("%p Warning: trying to create stack variable\n", insn.ea); if (!add_stkvar(insn.Operands[operand], insn.Operands[operand].addr)) { - msg("error in add_stkvar(%08lx, %08lx)\n", insn.Operands[operand].dtyp, insn.Operands[operand].addr); + message("error in add_stkvar(%08lx, %08lx)\n", insn.Operands[operand].dtyp, insn.Operands[operand].addr); return Expression_ptr(); } if (!op_stkvar(insn.ea, operand)) { - msg("error in op_stkvar(%08lx, %08lx)\n", insn.ea, operand); + message("error in op_stkvar(%08lx, %08lx)\n", insn.ea, operand); return Expression_ptr(); } - name = GetStackVariableName(insn.ea, operand, &index); + name = GetStackVariableName(insn, operand, &index); } if (!name.empty()) { result.reset(new StackVariable(name, index)); } else { - msg("ERROR: could not allocate stack var (%08lx, %d)\n", insn.ea, operand); + message("ERROR: could not allocate stack var (%08lx, %d)\n", insn.ea, operand); } return result; |
From: <wjh...@us...> - 2007-01-30 09:49:04
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17441 Modified Files: ida-x86.hpp Log Message: added cpu flag 'ParametersOnStack=true' Index: ida-x86.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/ida-x86.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ida-x86.hpp 23 Jul 2005 09:19:25 -0000 1.1 +++ ida-x86.hpp 30 Jan 2007 09:48:59 -0000 1.2 @@ -38,6 +38,7 @@ virtual std::string RegisterName(RegisterIndex index) const; virtual void FillList(func_t* function, Instruction_list& instructions); virtual void DumpInsn(insn_t& insn); + virtual bool ParametersOnStack() { return true; } /** Look for Borland C++ throw instruction */ static void TryBorlandThrow(DataFlowAnalysis* analysis, |
From: <wjh...@us...> - 2007-01-30 09:49:01
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17424 Modified Files: ida-x86.cpp Log Message: fixed 16bit address handling. removed 'invertedoperation' parameter Index: ida-x86.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/ida-x86.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ida-x86.cpp 15 Oct 2005 23:55:35 -0000 1.3 +++ ida-x86.cpp 30 Jan 2007 09:48:51 -0000 1.4 @@ -242,7 +242,7 @@ else { // XXX: maybe use & operator for result? - result = GlobalVariable::CreateFrom(address, insn.ea); + result = CreateGlobalVariable(insn, operand); if (result.get()) break; } @@ -260,7 +260,11 @@ case o_mem: case o_far: - result = GlobalVariable::CreateFrom(op.addr, insn.ea); + { + insn_t insxx= insn; + insxx.Operands[operand].addr = op.addr; + result = CreateVariable(insxx, operand); + } if (result.get()) { if (NN_lea == insn.itype) @@ -563,8 +567,9 @@ if (hasRef(flags) /*|| has_any_name(flags)*/) { - std::string name = GlobalVariable::GetName(address, address); - if (name.empty()) + int index; + std::string name = GetLocalCodeLabel(address, &index); + if (name.empty() || index) { msg("%p Warning: referenced offset without name\n", address); } @@ -765,41 +770,41 @@ break; case NN_ja: // above -> unsigned - OnConditionalJump(insn, ">", "<=", UNSIGNED_INT); + OnConditionalJump(insn, ">", UNSIGNED_INT); break; case NN_jg: // greater -> signed - OnConditionalJump(insn, ">", "<=", SIGNED_INT); + OnConditionalJump(insn, ">", SIGNED_INT); break; case NN_jb: // below -> unsigned - OnConditionalJump(insn, "<", ">=", UNSIGNED_INT); + OnConditionalJump(insn, "<", UNSIGNED_INT); break; case NN_jbe: // below -> unsigned - OnConditionalJump(insn, "<=", ">", UNSIGNED_INT); + OnConditionalJump(insn, "<=", UNSIGNED_INT); break; case NN_jnb: - OnConditionalJump(insn, ">=", "<", UNSIGNED_INT); + OnConditionalJump(insn, ">=", UNSIGNED_INT); break; case NN_jge: - OnConditionalJump(insn, ">=", "<", SIGNED_INT); + OnConditionalJump(insn, ">=", SIGNED_INT); break; case NN_jl: - OnConditionalJump(insn, "<", ">=", SIGNED_INT); + OnConditionalJump(insn, "<", SIGNED_INT); break; case NN_jle: - OnConditionalJump(insn, "<=", ">", SIGNED_INT); + OnConditionalJump(insn, "<=", SIGNED_INT); break; case NN_jz: - OnConditionalJump(insn, "==", "!="); + OnConditionalJump(insn, "=="); break; case NN_jnz: - OnConditionalJump(insn, "!=", "=="); + OnConditionalJump(insn, "!="); break; case NN_js: // < 0 - OnConditionalJump(insn, "<", ">=", SIGNED_INT); + OnConditionalJump(insn, "<", SIGNED_INT); break; case NN_jns: // >= 0 - OnConditionalJump(insn, ">=", "<", SIGNED_INT); + OnConditionalJump(insn, ">=", SIGNED_INT); break; case NN_jmp: @@ -857,13 +862,13 @@ break; case NN_setz: - OnSet(insn, "==", "!="); + OnSet(insn, "=="); break; case NN_setnz: - OnSet(insn, "!=", "=="); + OnSet(insn, "!="); break; case NN_setnb: - OnSet(insn, ">=", "<"); + OnSet(insn, ">="); break; case NN_shl: @@ -1543,7 +1548,7 @@ if (BADADDR != callee) { - e = GlobalVariable::CreateFrom(callee); + e = CreateGlobalCodeLabel(callee); } #endif @@ -1697,8 +1702,8 @@ if (TryProlog(insn)) return; - if (TryPushPop(insn)) - return; + if (TryPushPop(insn)) + return; Replace( new Push(insn.ea, FromOperand(insn, 0)) ); }/*}}}*/ @@ -1725,7 +1730,7 @@ }/*}}}*/ void OnConditionalJump(insn_t& insn, const char* operation, /*{{{*/ - const char* invertedOperation, Signness signness = UNKNOWN_SIGN) + Signness signness = UNKNOWN_SIGN) { switch (mFlagUpdate.itype) { @@ -1833,7 +1838,7 @@ } }/*}}}*/ - void OnSet(insn_t& insn, const char* operation, const char* invertedOperation)/*{{{*/ + void OnSet(insn_t& insn, const char* operation)/*{{{*/ { switch (mFlagUpdate.itype) { @@ -2083,14 +2088,14 @@ { if (index >= 0) { - if (mIs32Bit && (index < (sizeof(mName_x86_32bit)/sizeof(char*)))) + if (mIs32Bit && (index < (sizeof(mName_x86_32bit)/sizeof(char*)) )) return mName_x86_32bit[index]; else if (index < (sizeof(mName_x86_16bit)/sizeof(char*))) return mName_x86_16bit[index]; } std::ostringstream os; - os << "REGISTER_" << std::hex << index; + os << boost::format("REGISTER_%d") % index; return os.str(); }/*}}}*/ |
From: <wjh...@us...> - 2007-01-30 09:48:48
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17413 Modified Files: ida-arm2.hpp Log Message: added shift operand enum Index: ida-arm2.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/ida-arm2.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ida-arm2.hpp 10 May 2004 15:11:58 -0000 1.3 +++ ida-arm2.hpp 30 Jan 2007 09:48:43 -0000 1.4 @@ -1,174 +1,184 @@ -// -// The contents of this file comes from IDA Pro. -// -// Copyright (c) 1990-99 by Ilfak Guilfanov, <ig...@da...> -// -// $Id$ -#ifndef _IDA_ARM2_HPP -#define _IDA_ARM2_HPP - -#define REG_SP 13 // stack pointer -#define REG_LR 14 // link register = return address -#define REG_PC 15 // program counter - -//#define AUX_PRE_INDEX 0x10 -//#define AUX_WRITE_BACK 0x40 -//#define AUX_UP 0x80 - -//--------------------------------- -// ARM cmd.auxpref bits -#define aux_cond 0x0001 // set condition codes (S postfix is required) -#define aux_byte 0x0002 // byte transfer (B postfix is required) -#define aux_npriv 0x0004 // non-privileged transfer (T postfix is required) -#define aux_regsh 0x0008 // shift count is held in a register (see o_shreg) -#define aux_negoff 0x0010 // memory offset is negated in LDR,STR -#define aux_wback 0x0020 // write back (! postfix is required) -#define aux_wbackldm 0x0040 // write back for LDM/STM (! postfix is required) -#define aux_postidx 0x0080 // post-indexed mode in LDR,STR -#define aux_ltrans 0x0100 // long transfer in LDC/STC (L postfix is required) -#define aux_badbit 0x0200 // The instruction has some illegal bits -#define aux_sb 0x0400 // signed byte (SB postfix) -#define aux_sh 0x0800 // signed halfword (SH postfix) -#define aux_h 0x1000 // halfword (H postfix) -#define aux_p 0x2000 // priviledged (P postfix) - -enum cond_t -{ - cEQ, // 0000 Z Equal - cNE, // 0001 !Z Not equal - cCS, // 0010 C Unsigned higher or same - cCC, // 0011 !C Unsigned lower - cMI, // 0100 N Negative - cPL, // 0101 !N Positive or Zero - cVS, // 0110 V Overflow - cVC, // 0111 !V No overflow - cHI, // 1000 C & !Z Unsigned higher - cLS, // 1001 !C & Z Unsigned lower or same - cGE, // 1010 (N & V) | (!N & !V) Greater or equal - cLT, // 1011 (N & !V) | (!N & V) Less than - cGT, // 1100 !Z & ((N & V)|(!N & !V)) Greater than - cLE, // 1101 Z | (N & !V) | (!N & V) Less than or equal - cAL, // 1110 Always - cNV, // 1111 Never -}; -enum nameNum { - -ARM_null = 0, // Unknown Operation -ARM_ret, // Return from Subroutine -ARM_nop, // No Operation -ARM_b, // Branch -ARM_bl, // Branch with Link -ARM_asr, // Arithmetic Shift Right -ARM_lsl, // Logical Shift Left -ARM_lsr, // Logical Shift Right -ARM_ror, // Rotate Right -ARM_neg, // Negate -ARM_and, // 0 Rd = Op1 & Op2 -ARM_eor, // 1 Rd = Op1 ^ Op2 -ARM_sub, // 2 Rd = Op1 - Op2 -ARM_rsb, // 3 Rd = Op2 - Op1 -ARM_add, // 4 Rd = Op1 + Op2 -ARM_adc, // 5 Rd = Op1 + Op2 + C -ARM_sbc, // 6 Rd = Op1 - Op2 + C - 1 -ARM_rsc, // 7 Rd = Op2 - Op1 + C - 1 -ARM_tst, // 8 Set cond. codes on Op1 & Op2 -ARM_teq, // 9 Set cond. codes on Op1 ^ Op2 -ARM_cmp, // A Set cond. codes on Op1 - Op2 -ARM_cmn, // B Set cond. codes on Op1 + Op2 -ARM_orr, // C Rd = Op2 | Op1 -ARM_mov, // D Rd = Op2 -ARM_bic, // E Rd = Op1 & ~Op2 -ARM_mvn, // F Rd = ~Op2 -ARM_mrs, // Transfer PSR to Register -ARM_msr, // Transfer Register to PSR -ARM_mul, // Multiply -ARM_mla, // Multiply-Accumulate -ARM_ldr, // Load from Memory -ARM_ldrpc, // Indirect Jump -ARM_str, // Store to Memory -ARM_ldm, // Load Block from Memory -ARM_stm, // Store Block to Memory -ARM_swp, // Single Data Swap -ARM_swi, // Software interrupt - -// Version 4 - -ARM_smull, // Signed Multiply long -ARM_smlal, // Signed Multiply-Accumulate long -ARM_umull, // Unsigned Multiply long -ARM_umlal, // Unsigned Multiply-Accumulate long -ARM_bx, // Branch to/from Thumb mode -ARM_pop, // Pop registers -ARM_push, // Push registers -ARM_adr, // Load address - -// Version 5 - -ARM_bkpt, // Breakpoint -ARM_blx1, // Branch with Link and Exchange (immediate address) -ARM_blx2, // Branch with Link and Exchange (register indirect) -ARM_clz, // Count Leading Zeros - -// Version 5E - -ARM_ldrd, // Load pair of registers -ARM_pld, // Prepare to load -ARM_qadd, // Saturated addition -ARM_qdadd, // Saturated addition with doubling -ARM_qdsub, // Saturated subtraction with doubling -ARM_qsub, // Saturated subtraction -ARM_smlabb, // Signed multiply-accumulate (bottom*bottom) -ARM_smlatb, // Signed multiply-accumulate (top*bottom) -ARM_smlabt, // Signed multiply-accumulate (bottom*top) -ARM_smlatt, // Signed multiply-accumulate (top*top) -ARM_smlalbb, // Long signed multiply-accumulate (bottom*bottom) -ARM_smlaltb, // Long signed multiply-accumulate (top*bottom) -ARM_smlalbt, // Long signed multiply-accumulate (bottom*top) -ARM_smlaltt, // Long signed multiply-accumulate (top*top) -ARM_smlawb, // Wide signed multiply-accumulate (bottom) -ARM_smulwb, // Wide signed multiply (bottom) -ARM_smlawt, // Wide signed multiply-accumulate (top) -ARM_smulwt, // Wide signed multiply (top) -ARM_smulbb, // Signed multiply (bottom*bottom) -ARM_smultb, // Signed multiply (top*bottom) -ARM_smulbt, // Signed multiply (bottom*top) -ARM_smultt, // Signed multiply (top*top) -ARM_strd, // Store pair of registers - -// Intel xScale coprocessor instructions - -xScale_mia, // Multiply-Internal Accumulate -xScale_miaph, // Multiply-Internal Accumulate Packed HalfWords -xScale_miabb, // Multiply-Internal Accumulate Bottom-Bottom Halves -xScale_miabt, // Multiply-Internal Accumulate Bottom-Top Halves -xScale_miatb, // Multiply-Internal Accumulate Top-Bottom Halves -xScale_miatt, // Multiply-Internal Accumulate Top-Top Halves -xScale_mar, // Move To Internal Accumulator -xScale_mra, // Move From Internal Accumulator - -// Macro instructions - -ARM_movl, // Move immediate to register - -// Coprocessor instructions (should be last in the list) - -ARM_cdp, // Coprocessor Data Processing -ARM_cdp2, // Coprocessor Data Processing -ARM_ldc, // Load Coprocessor Register -ARM_ldc2, // Load Coprocessor Register -ARM_stc, // Store Coprocessor Register -ARM_stc2, // Store Coprocessor Register -ARM_mrc, // Move from Coprocessor to ARM Register -ARM_mrc2, // Move from Coprocessor to ARM Register -ARM_mcr, // Move from ARM to Coprocessor Register -ARM_mcr2, // Move from ARM to Coprocessor Register -ARM_mcrr, // Copy pair of registers to coprocessor (5E) -ARM_mrrc, // Copy pair of registers from coprocessor (5E) - -ARM_last - - }; - -#endif // _IDA_ARM2_HPP - - +// +// The contents of this file comes from IDA Pro. +// +// Copyright (c) 1990-99 by Ilfak Guilfanov, <ig...@da...> +// +// $Id$ +#ifndef _IDA_ARM2_HPP +#define _IDA_ARM2_HPP + +#define REG_SP 13 // stack pointer +#define REG_LR 14 // link register = return address +#define REG_PC 15 // program counter + +//#define AUX_PRE_INDEX 0x10 +//#define AUX_WRITE_BACK 0x40 +//#define AUX_UP 0x80 + +//--------------------------------- +// ARM cmd.auxpref bits +#define aux_cond 0x0001 // set condition codes (S postfix is required) +#define aux_byte 0x0002 // byte transfer (B postfix is required) +#define aux_npriv 0x0004 // non-privileged transfer (T postfix is required) +#define aux_regsh 0x0008 // shift count is held in a register (see o_shreg) +#define aux_negoff 0x0010 // memory offset is negated in LDR,STR +#define aux_wback 0x0020 // write back (! postfix is required) +#define aux_wbackldm 0x0040 // write back for LDM/STM (! postfix is required) +#define aux_postidx 0x0080 // post-indexed mode in LDR,STR +#define aux_ltrans 0x0100 // long transfer in LDC/STC (L postfix is required) +#define aux_badbit 0x0200 // The instruction has some illegal bits +#define aux_sb 0x0400 // signed byte (SB postfix) +#define aux_sh 0x0800 // signed halfword (SH postfix) +#define aux_h 0x1000 // halfword (H postfix) +#define aux_p 0x2000 // priviledged (P postfix) + +enum cond_t +{ + cEQ, // 0000 Z Equal + cNE, // 0001 !Z Not equal + cCS, // 0010 C Unsigned higher or same + cCC, // 0011 !C Unsigned lower + cMI, // 0100 N Negative + cPL, // 0101 !N Positive or Zero + cVS, // 0110 V Overflow + cVC, // 0111 !V No overflow + cHI, // 1000 C & !Z Unsigned higher + cLS, // 1001 !C & Z Unsigned lower or same + cGE, // 1010 (N & V) | (!N & !V) Greater or equal + cLT, // 1011 (N & !V) | (!N & V) Less than + cGT, // 1100 !Z & ((N & V)|(!N & !V)) Greater than + cLE, // 1101 Z | (N & !V) | (!N & V) Less than or equal + cAL, // 1110 Always + cNV, // 1111 Never +}; + +// for op.type==o_idpspec0 -> specflag2 is shift_t +enum shift_t +{ + LSL, // logical left LSL #0 - don't shift + LSR, // logical right LSR #0 means LSR #32 + ASR, // arithmetic right ASR #0 means ASR #32 + ROR, // rotate right ROR #0 means RRX + RRX, // extended rotate right +}; +enum nameNum { + +ARM_null = 0, // Unknown Operation +ARM_ret, // Return from Subroutine +ARM_nop, // No Operation +ARM_b, // Branch +ARM_bl, // Branch with Link +ARM_asr, // Arithmetic Shift Right +ARM_lsl, // Logical Shift Left +ARM_lsr, // Logical Shift Right +ARM_ror, // Rotate Right +ARM_neg, // Negate +ARM_and, // 0 Rd = Op1 & Op2 +ARM_eor, // 1 Rd = Op1 ^ Op2 +ARM_sub, // 2 Rd = Op1 - Op2 +ARM_rsb, // 3 Rd = Op2 - Op1 +ARM_add, // 4 Rd = Op1 + Op2 +ARM_adc, // 5 Rd = Op1 + Op2 + C +ARM_sbc, // 6 Rd = Op1 - Op2 + C - 1 +ARM_rsc, // 7 Rd = Op2 - Op1 + C - 1 +ARM_tst, // 8 Set cond. codes on Op1 & Op2 +ARM_teq, // 9 Set cond. codes on Op1 ^ Op2 +ARM_cmp, // A Set cond. codes on Op1 - Op2 +ARM_cmn, // B Set cond. codes on Op1 + Op2 +ARM_orr, // C Rd = Op2 | Op1 +ARM_mov, // D Rd = Op2 +ARM_bic, // E Rd = Op1 & ~Op2 +ARM_mvn, // F Rd = ~Op2 +ARM_mrs, // Transfer PSR to Register +ARM_msr, // Transfer Register to PSR +ARM_mul, // Multiply +ARM_mla, // Multiply-Accumulate +ARM_ldr, // Load from Memory +ARM_ldrpc, // Indirect Jump +ARM_str, // Store to Memory +ARM_ldm, // Load Block from Memory +ARM_stm, // Store Block to Memory +ARM_swp, // Single Data Swap +ARM_swi, // Software interrupt + +// Version 4 + +ARM_smull, // Signed Multiply long +ARM_smlal, // Signed Multiply-Accumulate long +ARM_umull, // Unsigned Multiply long +ARM_umlal, // Unsigned Multiply-Accumulate long +ARM_bx, // Branch to/from Thumb mode +ARM_pop, // Pop registers +ARM_push, // Push registers +ARM_adr, // Load address + +// Version 5 + +ARM_bkpt, // Breakpoint +ARM_blx1, // Branch with Link and Exchange (immediate address) +ARM_blx2, // Branch with Link and Exchange (register indirect) +ARM_clz, // Count Leading Zeros + +// Version 5E + +ARM_ldrd, // Load pair of registers +ARM_pld, // Prepare to load +ARM_qadd, // Saturated addition +ARM_qdadd, // Saturated addition with doubling +ARM_qdsub, // Saturated subtraction with doubling +ARM_qsub, // Saturated subtraction +ARM_smlabb, // Signed multiply-accumulate (bottom*bottom) +ARM_smlatb, // Signed multiply-accumulate (top*bottom) +ARM_smlabt, // Signed multiply-accumulate (bottom*top) +ARM_smlatt, // Signed multiply-accumulate (top*top) +ARM_smlalbb, // Long signed multiply-accumulate (bottom*bottom) +ARM_smlaltb, // Long signed multiply-accumulate (top*bottom) +ARM_smlalbt, // Long signed multiply-accumulate (bottom*top) +ARM_smlaltt, // Long signed multiply-accumulate (top*top) +ARM_smlawb, // Wide signed multiply-accumulate (bottom) +ARM_smulwb, // Wide signed multiply (bottom) +ARM_smlawt, // Wide signed multiply-accumulate (top) +ARM_smulwt, // Wide signed multiply (top) +ARM_smulbb, // Signed multiply (bottom*bottom) +ARM_smultb, // Signed multiply (top*bottom) +ARM_smulbt, // Signed multiply (bottom*top) +ARM_smultt, // Signed multiply (top*top) +ARM_strd, // Store pair of registers + +// Intel xScale coprocessor instructions + +xScale_mia, // Multiply-Internal Accumulate +xScale_miaph, // Multiply-Internal Accumulate Packed HalfWords +xScale_miabb, // Multiply-Internal Accumulate Bottom-Bottom Halves +xScale_miabt, // Multiply-Internal Accumulate Bottom-Top Halves +xScale_miatb, // Multiply-Internal Accumulate Top-Bottom Halves +xScale_miatt, // Multiply-Internal Accumulate Top-Top Halves +xScale_mar, // Move To Internal Accumulator +xScale_mra, // Move From Internal Accumulator + +// Macro instructions + +ARM_movl, // Move immediate to register + +// Coprocessor instructions (should be last in the list) + +ARM_cdp, // Coprocessor Data Processing +ARM_cdp2, // Coprocessor Data Processing +ARM_ldc, // Load Coprocessor Register +ARM_ldc2, // Load Coprocessor Register +ARM_stc, // Store Coprocessor Register +ARM_stc2, // Store Coprocessor Register +ARM_mrc, // Move from Coprocessor to ARM Register +ARM_mrc2, // Move from Coprocessor to ARM Register +ARM_mcr, // Move from ARM to Coprocessor Register +ARM_mcr2, // Move from ARM to Coprocessor Register +ARM_mcrr, // Copy pair of registers to coprocessor (5E) +ARM_mrrc, // Copy pair of registers from coprocessor (5E) + +ARM_last + + }; + +#endif // _IDA_ARM2_HPP + + |
From: <wjh...@us...> - 2007-01-30 09:48:42
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17402 Modified Files: ida-arm.hpp Log Message: changed ConditionOp to a static method. added ParametersOnStack property, which is false for ARM, and true for X86 Index: ida-arm.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/ida-arm.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ida-arm.hpp 23 Jul 2005 09:22:14 -0000 1.3 +++ ida-arm.hpp 30 Jan 2007 09:48:35 -0000 1.4 @@ -31,9 +31,10 @@ { public: virtual std::string RegisterName(RegisterIndex index) const; - virtual const char* const ConditionOp(int condition); + static const char* const ConditionOp(int condition); virtual void FillList(func_t* function, Instruction_list& instructions); virtual void DumpInsn(insn_t& insn); + virtual bool ParametersOnStack() { return false; } enum ArmRegNo { |
From: <wjh...@us...> - 2007-01-30 09:48:31
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17389 Modified Files: ida-arm.cpp Log Message: improved shift operand handling. improved global variable handling. ignoring data items embedded in function area. added ldrpc opcode added several missing cases of conditioncode processing. now recognising ldr pc, [sp],#4 / str lr,[sp,#-4] as return / push now recognising add r, sp, #imm now as reference to stackvariable. note currently unhandled cases Index: ida-arm.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/ida-arm.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ida-arm.cpp 15 Oct 2005 23:55:28 -0000 1.5 +++ ida-arm.cpp 30 Jan 2007 09:48:28 -0000 1.6 @@ -30,9 +30,9 @@ char buffer[16]; switch (index) { - case IdaArm::SP : return "SP"; - case IdaArm::LR : return "LR"; - case IdaArm::PC : return "PC"; + case IdaArm::SP : return "SP"; + case IdaArm::LR : return "LR"; + case IdaArm::PC : return "PC"; case IdaArm::CPSR : return "CPSR"; case IdaArm::CPSR_flg: return "CPSR_flg"; case IdaArm::SPSR: return "SPSR"; @@ -74,7 +74,7 @@ case cAL: // 1110 Always case cNV: // 1111 Never default: - msg("ERROR: unexpected condition call\n"); + msg("ERROR: unexpected condition call\n"); return "ERROR"; } }/*}}}*/ @@ -116,7 +116,7 @@ first=false; else msg(","); - msg(RegisterName(i).c_str()); + msg("%s", RegisterName(i).c_str()); } msg("}"); } @@ -159,18 +159,25 @@ // specflag2 - shift type // specflag1 - shift register // value - shift counter - msg("%p: idpspec0 detected!\n",insn.ea); + //msg("%p: idpspec0 detected!\n",insn.ea); - // todo: handle shift type - if (op.value) { - result.reset( new BinaryExpression( - Expression_ptr( new Register(op.reg)), - (op.specflag2?">>":"<<"), - Expression_ptr( new NumericLiteral(op.value)) - )); - } else { + if (op.specflag2==LSL && op.value==0) + { result.reset( new Register(op.reg) ); } + else { + // LSL : PSR.C= high bit, << + // LSR : PSR.C= low bit, >> + // ASR : PSR.C= low bit, >>, highbit=oldhighbit ( signed ) + // ROR : PSR.C= low bit, >>, highbit=oldlowbit + // RRX : PSR.C= low bit, >>, highbit= old PSR.C + result.reset( new BinaryExpression( + Expression_ptr( new Register(op.reg)), + op.specflag2==LSL ? "<<" : ">>", + Expression_ptr( new NumericLiteral( + op.specflag2==RRX ? 1 : op.value)) + )); + } break; case o_displ: @@ -193,50 +200,57 @@ case o_mem: { - msg("entering o_mem decoding: %d/%d\n", has_ti0(insn.ea), has_ti1(insn.ea)); + //msg("entering o_mem decoding: %d/%d\n", has_ti0(insn.ea), has_ti1(insn.ea)); ea_t arg = insn.Operands[operand].addr; flags_t flags = getFlags(arg); - msg("addr flags: %0lx\n",flags); + //msg("addr flags: %0lx\n",flags); if (isOff0(flags)) { ea_t ptr = get_long(arg); flags = getFlags(ptr); - msg("flags of ptr: %0lx\n", flags); + //msg("flags of ptr: %0lx\n", flags); if (isASCII(flags)) { result = StringLiteral::CreateFrom(ptr); } else { + insn_t insxx= insn; + insxx.Operands[operand].addr= ptr; // XXX: maybe use & operator for result? - result = GlobalVariable::CreateFrom(ptr, insn.ea); + result = CreateGlobalVariable(insxx, operand); if ( !result.get() ) { - msg("%p no name found for for operand %i \n", insn.ea, operand); + msg("%p no name found for for o_mem operand %i\n", insn.ea, operand); } } } else { long value = get_long(arg); - msg("not offset\n"); + //msg("not offset\n"); result.reset(new NumericLiteral(value)); } } break; case o_near: - result = GlobalVariable::CreateFrom(op.addr, insn.ea); + result = CreateVariable(insn, operand); if (!result.get()) { - msg("%p no name found for for operand %i \n", + msg("%p no name found for for o_near operand %i\n", insn.ea, operand); } break; case o_idpspec2: // ARM module specific: o_reglist // reglist is in op.specval + // specflag1 = PSR & force user bit + // LDMxx R, {list}^ ... ld/st usermode regs. msg("%p type o_idpspec2 for operand %i should not be handled in FromOperand()\n", insn.ea, operand); break; case o_phrase: + // second register in specflag1 + // shifttype in specflag2 + // shiftcount in shcnt result.reset( new BinaryExpression( Expression_ptr( new Register(op.reg)), "+", @@ -306,21 +320,6 @@ { flags_t flags = getFlags(address); - if (hasRef(flags) /*|| has_any_name(flags)*/) - { - std::string name = GlobalVariable::GetName(address, address); - if (name.empty()) - { - msg("%p Warning: referenced offset without name\n", address); - } - else - { - //msg("%p Name=%s\n", address, name.c_str()); - Instruction_ptr label(new Label(address, name.c_str())); - Instructions().push_back(label); - } - } - if (!isCode(flags)) { if (isUnknown(flags)) @@ -337,6 +336,9 @@ break; } } + else if (isData(flags)) { + continue; + } else { msg("Warning, skipping byte with flags %p at offset %p\n", @@ -347,6 +349,22 @@ } } + if (hasRef(flags) /*|| has_any_name(flags)*/) + { + int index; + std::string name= GetLocalCodeLabel(address, &index); + if (name.empty() || index) + { + msg("%p Warning: referenced offset without name\n", address); + } + else + { + //msg("%p Name=%s\n", address, name.c_str()); + Instruction_ptr label(new Label(address, name.c_str())); + Instructions().push_back(label); + } + } + Instructions().push_back( Instruction_ptr( new LowLevel( GetLowLevelInstruction(address) ) )); @@ -358,11 +376,6 @@ static_cast<IdaPro&>(Frontend::Get()).DumpInsn(insn); } - const char* const ConditionOp(int condition) - { - return static_cast<IdaArm&>(Frontend::Get()).ConditionOp(condition); - } - const char* const NotConditionOp(int condition)/*{{{*/ { switch (condition) @@ -414,27 +427,21 @@ case cNV: // 1111 Never condition = cAL; } - return ConditionOp(condition); + return IdaArm::ConditionOp(condition); } void InsertLabel(insn_t& insn) { - std::string name = GlobalVariable::GetName(get_item_end(insn.ea), insn.ea); - if (name.empty()) - { - char label[MAXSTR]; - ea_t ea = get_item_end(insn.ea); - - qsnprintf(label, sizeof(label), "loc_%08lx", ea); - msg("inserting label %s\n", label); - Insert(new Label(ea, label)); - } else msg("found label %s\n",name.c_str()); + ea_t ea = get_item_end(insn.ea); + Instruction_ptr label= CreateLocalCodeLabel(ea); + if (label.get()) + Insert(label); } void InsertConditional(insn_t& insn) { int op1, op2; - std::string name("Cond"); + std::string name("Cond"); op_t op = mFlagUpdate.Operands[2]; @@ -444,7 +451,7 @@ op1 = 1; op2 = 2; } - msg("using conditional: %d \n",insn.segpref); + msg("%p - using conditional: %d \n", insn.ea, insn.segpref); Insert(new ConditionalJump( insn.ea, Expression_ptr(new BinaryExpression( @@ -457,7 +464,7 @@ NotConditionOp(insn.segpref), NumericLiteral::Create(0) )), - GlobalVariable::CreateFrom(get_item_end(insn.ea), insn.ea) + CreateLocalCodeReference(get_item_end(insn.ea)) )); } @@ -470,7 +477,7 @@ { insn_t insn = static_cast<LowLevel*>(lowLevel)->Insn(); - // insn.segpref contains the condition code in the arm module. + // insn.segpref contains the condition code in the arm module. if (cNV == insn.segpref) { msg("%p Warning! Will never execute instruction:\n"); @@ -478,10 +485,10 @@ return; } - if (cAL != insn.segpref) - { - msg("%p Condition code= %x:\n", insn.ea, insn.segpref); - } +// if (cAL != insn.segpref) +// { +// msg("%p Condition code= %x:\n", insn.ea, insn.segpref); +// } switch (insn.itype) { @@ -494,6 +501,8 @@ case ARM_sub: OnOperator(insn, "-", 1, 2); break; case ARM_rsb: OnOperator(insn, "-", 2, 1); break; case ARM_add: + if (TryAddSp(insn)) + break; if (TryAddMov(insn)) break; OnOperator(insn, "+", 1, 2); @@ -509,7 +518,7 @@ if (TryMovBx(insn)) break; OnMov(insn); - break; + break; case ARM_mvn: OnMvn(insn); break; case ARM_teq: OnTestOperator(insn, "^"); break; @@ -517,6 +526,7 @@ case ARM_cmp: OnTestOperator(insn, "-"); break; case ARM_cmn: OnTestOperator(insn, "+"); break; + case ARM_ldrpc: // both handled by OnLdr case ARM_ldr: OnLdr(insn); break; case ARM_str: OnStr(insn); break; @@ -551,7 +561,7 @@ case ARM_lsr: OnOperator(insn, ">>", 1, 2); break; case ARM_lsl: if (TryAnd(insn)) - break; + break; OnOperator(insn, "<<", 1, 2); break; case ARM_ror: OnOperator(insn, ">>", 1, 2); break; @@ -567,8 +577,8 @@ case ARM_ret: OnRet(insn);break; default: + msg("%p Unhandled instruction\n", insn.ea); DumpInsn(insn); - msg("%p Unhandled instruction: %p\n", insn.ea, insn.itype); break; } }/*}}}*/ @@ -581,9 +591,8 @@ operand1 = 0; operand2 = 1; } - if (insn.auxpref && aux_cond) { - std::string name("Cond"); - msg("setting conditional\n"); + if ((insn.auxpref & aux_cond)!=0) { + msg("%p setting conditional for operator\n", insn.ea); mFlagUpdate = insn; mFlagUpdateOp = operation; mFlagUpdateItem = Instructions().end(); @@ -616,6 +625,8 @@ void OnTestOperator(insn_t& insn, const char* operation)/*{{{*/ { + if (insn.segpref != cAL) + InsertConditional(insn); // EraseInstructions(1); mFlagUpdate = insn; mFlagUpdateOp = operation; @@ -638,6 +649,8 @@ )) )); } + if (insn.segpref != cAL) + InsertLabel(insn); }/*}}}*/ void OnBic(insn_t& insn)/*{{{*/ @@ -661,10 +674,27 @@ InsertLabel(insn); }/*}}}*/ + void OnAddSp(insn_t& insn)/*{{{*/ + { + if (insn.segpref != cAL) + InsertConditional(insn); + + Replace(new Assignment( + insn.ea, + ::FromOperand(insn, 0), + Expression_ptr(new UnaryExpression( + "&", + FromOperand(insn, 2))) + )); + + if (insn.segpref != cAL) + InsertLabel(insn); + }/*}}}*/ + void OnMov(insn_t& insn)/*{{{*/ { - if (insn.auxpref && aux_cond) { - msg("setting conditional\n"); + if ((insn.auxpref & aux_cond)!=0) { + msg("%p setting conditional for MOVS\n", insn.ea); mFlagUpdate = insn; mFlagUpdateItem = Instructions().end(); Insert( new Assignment( @@ -707,6 +737,9 @@ "~", FromOperand(insn, 1))) )); + + if (insn.segpref != cAL) + InsertLabel(insn); }/*}}}*/ void OnMla(insn_t& insn)/*{{{*/ @@ -779,7 +812,7 @@ // FromOperand(mFlagUpdate, op2) // )), Expression_ptr(new Register(IdaArm::Cond)), - ConditionOp(insn.segpref), + IdaArm::ConditionOp(insn.segpref), NumericLiteral::Create(0) )), ::FromOperand(insn, 0) @@ -794,17 +827,21 @@ // // Branch with link (function call) // + if (insn.segpref != cAL) + InsertConditional(insn); // Result in R0? - // todo: some functions - like idiv, have result in R0, R1 - // todo: parametercount does not depend on stack with ARM. - // convention: R0, R1, R2, R3, [SP], [SP+4], [SP+8], ... + // todo: some functions - like idiv, have result in R0, R1 + // todo: parametercount does not depend on stack with ARM. + // convention: R0, R1, R2, R3, [SP], [SP+4], [SP+8], ... Replace(new Assignment( insn.ea, Expression_ptr(new Register(0)), Expression_ptr(new CallExpression(::FromOperand(insn, 0))) )); + if (insn.segpref != cAL) + InsertLabel(insn); }/*}}}*/ @@ -815,6 +852,8 @@ // change ARM <-> THUMB // + if (insn.segpref != cAL) + InsertConditional(insn); // BX LR is return if (REG_LR == insn.Operands[0].reg) { @@ -829,6 +868,8 @@ Expression_ptr(new CallExpression(::FromOperand(insn, 0))) )); } + if (insn.segpref != cAL) + InsertLabel(insn); }/*}}}*/ void OnLdr(insn_t& insn)/*{{{*/ @@ -836,11 +877,32 @@ if (insn.segpref != cAL) InsertConditional(insn); - Replace(new Assignment( - insn.ea, - ::FromOperand(insn, 0), - ::FromOperand(insn, 1) - )); + if (insn.Operands[1].type == o_displ + && insn.Operands[1].reg == REG_SP + && insn.Operands[1].addr == 4 + && (insn.auxpref & (aux_postidx))==aux_postidx) { + // LDR PC, [SP],#4 + int regnr= insn.Operands[0].reg; + if (regnr == REG_PC) { + // Return + Replace( new Return(insn.ea, Expression_ptr(new Register(0))) ); + } + else { + Replace(new Pop( insn.ea, ::FromOperand(insn, 0) )); + } + } + else if (insn.Operands[0].reg==REG_PC) { + // jumptable + message("ERROR - jumptable not yet implemented\n"); + DumpInsn(insn); + } + else { + Replace(new Assignment( + insn.ea, + ::FromOperand(insn, 0), + ::FromOperand(insn, 1) + )); + } if (insn.segpref != cAL) InsertLabel(insn); @@ -856,7 +918,7 @@ return; } - if ( (insn.auxpref & 0x80) && // means that the W and U bits are set, I hope + if ( (insn.auxpref & aux_postidx)!=0 && // means that the W and U bits are set, I hope REG_SP == insn.Operands[0].reg) { // @@ -884,6 +946,13 @@ Erase(Iterator()); } + else if ( (insn.auxpref & (aux_postidx|aux_negoff))==aux_negoff + && 11 == insn.Operands[0].reg + && insn.Operands[1].type == o_idpspec2 // reglist + && (insn.Operands[1].specval&(1<<13)) // restores SP + ) { + msg("%p ignoring end of function LDM R11, {..SP..}\n", insn.ea); + } else { msg("%p Unexpected block store\n", insn.ea); @@ -893,15 +962,23 @@ void OnStr(insn_t& insn)/*{{{*/ { - if (insn.segpref != cAL) InsertConditional(insn); - Replace(new Assignment( - insn.ea, - ::FromOperand(insn, 1), - ::FromOperand(insn, 0) - )); + if (insn.Operands[1].type == o_displ + && insn.Operands[1].reg == REG_SP + && insn.Operands[1].addr == -4 + && (insn.auxpref & (aux_postidx|aux_wback))==aux_wback) { + // STR LR, [SP,#-4]! + Replace(new Push( insn.ea, ::FromOperand(insn, 0) )); + } + else { + Replace(new Assignment( + insn.ea, + ::FromOperand(insn, 1), + ::FromOperand(insn, 0) + )); + } if (insn.segpref != cAL) InsertLabel(insn); @@ -917,7 +994,7 @@ return; } - if (0x50 == insn.auxpref && // means that the W and P bits are set, I hope + if ((aux_wbackldm|aux_negoff)== insn.auxpref && // means that the W and P bits are set, I hope REG_SP == insn.Operands[0].reg) { // @@ -947,9 +1024,13 @@ void OnRet(insn_t& insn) { + if (insn.segpref != cAL) + InsertConditional(insn); Replace( new Return(insn.ea, Register::Create(0)) ); + if (insn.segpref != cAL) + InsertLabel(insn); } void OnPush(insn_t &insn) @@ -1107,7 +1188,15 @@ } return false; } - + bool TryAddSp(insn_t& insn)/*{{{*/ + { + if (OperandIsRegister(insn, 1) && insn.Operands[1].reg == REG_SP + && insn.Operands[2].type == o_imm) { + OnAddSp(insn); + return true; + } + return false; + } // Idiom for function call: // Mov subroutine address to R? // MOV LR, PC @@ -1137,11 +1226,11 @@ return false; } -// AnalysisResult OnInstruction() -// { -// msg("%p: Analysis: Instruction Type %d\n",Instr()->Address(), Instr()->Type()); -// return CONTINUE; -// } + AnalysisResult OnInstruction() + { + msg("%p: Analysis: Instruction Type %d\n",Instr()->Address(), Instr()->Type()); + return CONTINUE; + } insn_t mFlagUpdate; const char *mFlagUpdateOp; |
From: <wjh...@us...> - 2007-01-30 09:48:23
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17368 Modified Files: dataflow.cpp Log Message: checking ParametersOnStack Index: dataflow.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/dataflow.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- dataflow.cpp 15 Oct 2005 23:54:44 -0000 1.5 +++ dataflow.cpp 30 Jan 2007 09:48:19 -0000 1.6 @@ -142,32 +142,34 @@ if (call->IsFinishedAddingParameters()) return; // already collected parameters for this call - int parameters_left = call->ParameterCount(); + if (static_cast<IdaPro&>(Frontend::Get()).ParametersOnStack()) { + int parameters_left = call->ParameterCount(); - if (CallExpression::UNKNOWN_PARAMETER_COUNT == parameters_left) - { - parameters_left = Stack().size(); - message("%p I guess this function call takes %i parameters.\n", - Instr()->Address(), parameters_left); - call->ParameterCountFromStack(parameters_left); - } + if (CallExpression::UNKNOWN_PARAMETER_COUNT == parameters_left) + { + parameters_left = Stack().size(); + message("%p I guess this function call takes %i parameters.\n", + Instr()->Address(), parameters_left); + call->ParameterCountFromStack(parameters_left); + } - while (!Stack().empty() && parameters_left > 0) - { - Push* push = static_cast<Push*>(Stack().top()->get()); - call->AddParameter( push->Operand() ); - Erase(Stack().top()); - Stack().pop(); - parameters_left--; - } + while (!Stack().empty() && parameters_left > 0) + { + Push* push = static_cast<Push*>(Stack().top()->get()); + call->AddParameter( push->Operand() ); + Erase(Stack().top()); + Stack().pop(); + parameters_left--; + } - call->SetFinishedAddingParameters(); + call->SetFinishedAddingParameters(); - if (parameters_left != 0) - { - message("%p Unexpected number of parameters left: %i. Wanted %i parameters.\n", - Instr()->Address(), parameters_left, call->ParameterCount()); - } + if (parameters_left != 0) + { + message("%p Unexpected number of parameters left: %i. Wanted %i parameters.\n", + Instr()->Address(), parameters_left, call->ParameterCount()); + } + } #if 0 call->SetDataTypes(); |
From: <wjh...@us...> - 2007-01-30 09:48:15
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17342 Modified Files: expression.hpp Log Message: added operator precedence map added precedence method to all expression classes. 'level' parameter to GenerateCode is obsoleted by precedencemap Index: expression.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/expression.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- expression.hpp 15 Oct 2005 23:55:21 -0000 1.8 +++ expression.hpp 30 Jan 2007 09:48:11 -0000 1.9 @@ -198,6 +198,68 @@ class TernaryExpression; class UnaryExpression; +class BinaryOpPrecedences: public std::map<std::string, int> { + int lowest_; + int highest_; +public: + BinaryOpPrecedences() + : lowest_(0), highest_(0) + { + int prec= lowest_; + // ternary -1 + insert(value_type("||", prec)); + insert(value_type("&&", ++prec)); + insert(value_type("|", ++prec)); + insert(value_type("^", ++prec)); + insert(value_type("&", ++prec)); + + insert(value_type("==", ++prec)); + insert(value_type("!=", prec)); + + insert(value_type(">=", ++prec)); + insert(value_type("<=", prec)); + insert(value_type(">", prec)); + insert(value_type("<", prec)); + + insert(value_type("<<", ++prec)); + insert(value_type(">>", prec)); + + insert(value_type("+", ++prec)); + insert(value_type("-", prec)); + + insert(value_type("*", ++prec)); + insert(value_type("/", prec)); + insert(value_type("%", prec)); + + // unary ops + + highest_= prec; + } + int binaryprecedence(const std::string& op) + { + iterator i= find(op); + if (i==end()) { + message("ERROR: unknown binary operator used: %s\n", op.c_str()); + return -1; + } + return (*i).second; + } + int ternaryprecedence() { + return lowest_-1; + } + int unaryprecedence() { + return highest_+1; + } + int callprecedence() { + return highest_+2; + } + int atomprecedence() { + return highest_+2; + } + +}; +extern BinaryOpPrecedences precedencemap; + /** * Abstract base class for expression visitors */ @@ -251,6 +313,7 @@ } // TypeInformation& DataType() { return mDataType; } + virtual int Precedence() const = 0; virtual int SubExpressionCount() { return 0; @@ -266,7 +329,7 @@ { } - virtual void GenerateCode(std::ostream& os, int level = 0) + virtual void GenerateCode(std::ostream& os) { os << "NYI"; } @@ -315,6 +378,11 @@ visitor.Visit(*this); } + virtual int Precedence() const + { + return precedencemap.unaryprecedence(); + } + virtual int SubExpressionCount() { return 1; @@ -343,14 +411,15 @@ } #endif - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { - if (level > 0) - os << '('; + bool bUseParentheses= mOperand->Precedence() < Precedence(); os << mOperation << ' '; - mOperand->GenerateCode(os, level+1); - if (level > 0) - os << ')'; + if (bUseParentheses) + os << '('; + mOperand->GenerateCode(os); + if (bUseParentheses) + os << ')'; } private: @@ -376,6 +445,10 @@ visitor.Visit(*this); } + virtual int Precedence() const { + return precedencemap.binaryprecedence(mOperation); + } + virtual int SubExpressionCount() { return 2; @@ -414,15 +487,20 @@ } #endif - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { - if (level > 0) - os << '('; - mFirst->GenerateCode(os, level+1); + bool bUseParentheses; + bUseParentheses= mFirst->Precedence() < Precedence(); + if (bUseParentheses) os << '('; + mFirst->GenerateCode(os); + if (bUseParentheses) os << ')'; + os << ' ' << mOperation << ' '; - mSecond->GenerateCode(os, level+1); - if (level > 0) - os << ')'; + + bUseParentheses= mSecond->Precedence() < Precedence(); + if (bUseParentheses) os << '('; + mSecond->GenerateCode(os); + if (bUseParentheses) os << ')'; } private: @@ -454,6 +532,10 @@ visitor.Visit(*this); } + virtual int Precedence() const { + return precedencemap.ternaryprecedence(); + } + virtual int SubExpressionCount() { return 3; @@ -469,17 +551,13 @@ mOperands[index] = e; } - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { - if (level > 0) - os << '('; - mOperands[0]->GenerateCode(os, level+1); + mOperands[0]->GenerateCode(os); os << " ? "; - mOperands[1]->GenerateCode(os, level+1); + mOperands[1]->GenerateCode(os); os << " : "; - mOperands[2]->GenerateCode(os, level+1); - if (level > 0) - os << ')'; + mOperands[2]->GenerateCode(os); } static Expression_ptr Create(Expression_ptr a, Expression_ptr b, Expression_ptr c) @@ -508,7 +586,7 @@ else mOs << ", "; - e->GenerateCode(mOs, 0); + e->GenerateCode(mOs); } std::ostream& mOs; @@ -538,6 +616,10 @@ visitor.Visit(*this); } + virtual int Precedence() const { + return precedencemap.callprecedence(); + } + virtual int SubExpressionCount() { return mSubExpressions.size(); @@ -664,7 +746,7 @@ Accept(visitor); } - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { #if DUMP_DATA_TYPES os << '('; @@ -672,7 +754,7 @@ os << ')'; #endif - Function()->GenerateCode(os, level+1); + Function()->GenerateCode(os); os << '('; std::for_each(mSubExpressions.begin()+1, mSubExpressions.end(), GenerateCodeHelper(os)); @@ -720,7 +802,7 @@ unsigned long Value() { return mValue; } - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { #if DUMP_DATA_TYPES os << '('; @@ -733,10 +815,9 @@ else { if (mValue < 0x10) - os << std::dec; + os << boost::format("%d") % mValue; else - os << std::hex << "0x"; - os << mValue; + os << boost::format("0x%x") % mValue; } } @@ -745,6 +826,10 @@ return Expression_ptr(new NumericLiteral(value)); } + virtual int Precedence() const { + return precedencemap.atomprecedence(); + } + private: unsigned long mValue; };/*}}}*/ @@ -771,7 +856,7 @@ visitor.Visit(*this); } - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { #if DUMP_DATA_TYPES os << '('; @@ -794,7 +879,10 @@ static std::string GetString(ea_t address, ulong type); static std::string EscapeAsciiString(const std::string& str); - static std::string EscapeAsciiString(const char* str); + + virtual int Precedence() const { + return precedencemap.atomprecedence(); + } private: std::string mValue; @@ -827,7 +915,7 @@ return (unsigned short)(mRegister & 31); } - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { #if DUMP_DATA_TYPES os << '('; @@ -853,6 +941,11 @@ return (unsigned short)-1; } + virtual int Precedence() const { + return precedencemap.atomprecedence(); + } + + private: RegisterIndex mRegister; };/*}}}*/ @@ -875,7 +968,7 @@ std::string Name() const throw() { return mName; } - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { #if DUMP_DATA_TYPES os << '('; @@ -917,6 +1010,10 @@ Addr Address(); + virtual int Precedence() const { + return precedencemap.atomprecedence(); + } + static Expression_ptr CreateFrom(ea_t ea, ea_t from = INVALID_ADDR); static std::string GetName(ea_t ea, ea_t from = INVALID_ADDR); @@ -943,6 +1040,10 @@ { visitor.Visit(*this); } + virtual int Precedence() const { + return precedencemap.atomprecedence(); + } + };/*}}}*/ class Dummy : public Expression/*{{{*/ @@ -961,7 +1062,7 @@ visitor.Visit(*this); } - virtual void GenerateCode(std::ostream& os, int level) + virtual void GenerateCode(std::ostream& os) { // empty } @@ -970,6 +1071,10 @@ { return Expression_ptr(new Dummy()); } + virtual int Precedence() const { + return precedencemap.atomprecedence(); + } + };/*}}}*/ #endif |
From: <wjh...@us...> - 2007-01-30 09:48:05
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17002 Modified Files: codegen.cpp Log Message: formatted address with boost::format as 8 digit hex number Index: codegen.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/codegen.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- codegen.cpp 15 Oct 2005 23:54:37 -0000 1.5 +++ codegen.cpp 30 Jan 2007 09:48:02 -0000 1.6 @@ -173,10 +173,7 @@ { if (LISTING_STYLE == mStyle) { - mOut.width(8); - mOut.fill('0'); - mOut << std::hex << instruction.Address() << std::dec << ' '; - mOut.width(0); + mOut << boost::format("%08x ") % instruction.Address(); } if (indent == INDENT) |
From: <wjh...@us...> - 2007-01-30 09:48:00
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv16984 Modified Files: expression.cpp Log Message: improved expression readability, by writing only () when nescesary, based on operator precedence moved GlobalVariable::CreateFrom and GlobalVariable::GetName to idapro.cpp Index: expression.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/expression.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- expression.cpp 15 Oct 2005 23:55:13 -0000 1.8 +++ expression.cpp 30 Jan 2007 09:47:53 -0000 1.9 @@ -45,6 +45,8 @@ #include "frontend.hpp" #include "idapro.hpp" +BinaryOpPrecedences precedencemap; + std::string Register::Name(RegisterIndex index)/*{{{*/ { return Frontend::Get().RegisterName(index); @@ -220,44 +222,6 @@ return mAddress; } -/** - * May return a NULL pointer - */ -Expression_ptr GlobalVariable::CreateFrom(ea_t ea, ea_t from/* = INVALID_ADDR*/)/*{{{*/ -{ - Expression_ptr result; - - std::string name = GetName(ea, from); - if (!name.empty()) - result.reset(new GlobalVariable(name, /*index*/0, ea)); - else - { - char label[MAXSTR]; - qsnprintf(label, sizeof(label), "loc_%08lx", ea); - name = label; - result.reset(new GlobalVariable(name, 0, ea)); - } - - return result; -}/*}}}*/ - -std::string GlobalVariable::GetName(ea_t ea, ea_t from/* = INVALID_ADDR*/)/*{{{*/ -{ - char name[MAXSTR]; - if (get_name(from, ea, name, sizeof(name))) - { - return std::string(name); - } - else if (from!=INVALID_ADDR) - { - return str(boost::format("local_%08lx_%08lx") % from % ea); - } - else - { - return str(boost::format("global_%08lx") % ea); - } -}/*}}}*/ - #if 1 bool Expression::Equal(Expression_ptr a, Expression_ptr b) { |
From: <wjh...@us...> - 2007-01-30 09:47:52
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv16967 Modified Files: desquirr.cpp Log Message: added message function which can display large strings, without truncating them Index: desquirr.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/desquirr.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- desquirr.cpp 15 Oct 2005 23:54:58 -0000 1.8 +++ desquirr.cpp 30 Jan 2007 09:47:46 -0000 1.9 @@ -65,6 +65,13 @@ va_end(va); return nbytes; } +int message(const std::string& str) +{ + int nbytes=0; + for (size_t i= 0 ; i<str.size() ; i+=1024) + nbytes += message("%s", str.substr(i, 1024).c_str()); + return nbytes; +} static LongSize s_size = UNKNOWN_LONG_SIZE; @@ -237,13 +244,13 @@ Node_list nodes; msg("-> Creating node list\n"); Node::CreateList(instructions, nodes); - if (g_bDumpNodeContents) DumpList(nodes); + //if (g_bDumpNodeContents) DumpList(nodes); msg("-> Update uses and definitions\n"); UpdateUsesAndDefinitions(nodes); - if (g_bDumpNodeContents) DumpList(nodes); + //if (g_bDumpNodeContents) DumpList(nodes); msg("-> Live register analysis\n"); Node::LiveRegisterAnalysis(nodes); - if (g_bDumpNodeContents) DumpList(nodes); + //if (g_bDumpNodeContents) DumpList(nodes); msg("-> Finding DU chains\n"); Node::FindDefintionUseChains(nodes); if (g_bDumpNodeContents) DumpList(nodes); @@ -337,7 +344,7 @@ { std::ostringstream strstr; printlist(strstr, list); - message("%s", strstr.str().c_str()); + message(strstr.str()); } struct DumpNodeHelper { @@ -362,7 +369,7 @@ { std::ostringstream strstr; printlist(strstr, list); - message("%s", strstr.str().c_str()); + message(strstr.str()); } struct DumpExprHelper { @@ -391,7 +398,7 @@ { std::ostringstream strstr; printvector(strstr, list); - message("%s", strstr.str().c_str()); + message(strstr.str()); } |
From: <wjh...@us...> - 2005-10-15 23:56:17
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14244 Modified Files: node.hpp Log Message: added print functions to all node types Index: node.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/node.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- node.hpp 23 Jul 2005 10:03:51 -0000 1.5 +++ node.hpp 15 Oct 2005 23:56:10 -0000 1.6 @@ -23,12 +23,25 @@ #ifndef _NODE_HPP #define _NODE_HPP +/* + * class hierarchy: + +Node ... begin-end + ReturnNode ! when last=ret + OneWayNode ... successor + FallThroughNode ! when succ=label + JumpNode ! when last=jump + TwoWayNode ... succA, succB + ConditinalJumpNode ! when last=jcond + CallNode ! when last=call + N_WayNode ... list! when last=load PC with expression. +*/ + // // Local includes // #include "desquirr.hpp" #include "instruction.hpp" - class Node/*{{{*/ { public: @@ -43,7 +56,8 @@ }; Instruction_list& Instructions() { return mInstructions; } - Addr Address() { return mAddress; } + Addr Address() const { return mAddress; } + NodeType Type() const { return mType; } BoolArray& Definitions() { return mDefinitions; } BoolArray& Uses() { return mUses; } @@ -79,7 +93,23 @@ // default implementation return false; } - + friend std::ostream& operator<< (std::ostream& os, Node& n) + { + n.print(os); + printlist(os, n.Instructions()); + return os; + } + virtual void print(std::ostream& os) + { + os << boost::format("node %08lx-%08lx #insn=%d") + % Address() + % (Instructions().back()->Address()) + % Instructions().size(); + os << " use=" << Uses(); + os << " def=" << Definitions(); + os << " in=" << LiveIn(); + os << " out=" << LiveOut(); + } static void CreateList(Instruction_list& instructions, Node_list& nodes); static void ConnectSuccessors(Node_list& nodes); @@ -110,6 +140,9 @@ } } + public: + virtual ~Node() {} + private: Addr mAddress; NodeType mType; @@ -178,7 +211,6 @@ mSuccessorAddress[0] = successorA; mSuccessorAddress[1] = successorB; } - virtual int SuccessorCount() { return 2; @@ -234,8 +266,60 @@ Addr mSuccessorAddress[2]; Node_ptr mSuccessor[2]; };/*}}}*/ +#if 0 +class N_WayNode : public Node/*{{{*/ +{ + protected: + N_WayNode(const std::vector<Addr> &successor_list, + Instruction_list::iterator begin, + Instruction_list::iterator end) + : Node(N_WAY, begin, end) + { + mSuccessorAddress = successor_list; + mSuccessor.resize(successor_list.size()); + } + + virtual int SuccessorCount() + { + return mSuccessorAddress.size(); + } + + virtual Addr SuccessorAddress(int index) + { + if (index<0 || index>=mSuccessorAddress.size()) + return INVALID_ADDR; + return mSuccessorAddress[index]; + } + + virtual Node_ptr Successor(int index) + { + Node_ptr result; + if (index<0 || index>=mSuccessor.size()) { + msg("ERROR: N_WayNode::Successor(%d) called\n", index); + return result; + } + + return mSuccessor[index]; + } + + virtual bool ConnectSuccessor(int index, Node_ptr successor) + { + if (index<0 || index>=mSuccessorAddress.size()) + return false; + + if (successor->Address() == mSuccessorAddress[index]) + { + mSuccessor[index] = successor; + return true; + } + } + private: + std::vector<Addr> mSuccessorAddress; + std::vector<Node_ptr> mSuccessor; +};/*}}}*/ +#endif class JumpNode : public OneWayNode/*{{{*/ { public: @@ -244,6 +328,12 @@ Instruction_list::iterator end) : OneWayNode(JUMP, destination, begin, end) {} + virtual void print(std::ostream& os) + { + Node::print(os); + os << boost::format("JUMP target=%08lx\n") + % Successor(0).get(); + } static Node_ptr CreateFrom(Instruction_ptr i, Instruction_list::iterator begin, @@ -259,6 +349,14 @@ Instruction_list::iterator end) : TwoWayNode(CONDITIONAL_JUMP, destination, follower, begin, end) {} + virtual void print(std::ostream& os) + { + Node::print(os); + os << boost::format("CONDJUMP target=%08lx follow=%08lx\n") + % Successor(0).get() + % Successor(1).get(); + } + static Node_ptr CreateFrom(Instruction_ptr i, Addr follower, @@ -275,6 +373,14 @@ Instruction_list::iterator end) : OneWayNode(FALL_THROUGH, follower, begin, end) {} + virtual void print(std::ostream& os) + { + Node::print(os); + os << boost::format("FALLTHROUGH follow=%08lx\n") + % Successor(0).get(); + } + + };/*}}}*/ class ReturnNode : public Node/*{{{*/ @@ -285,20 +391,32 @@ Instruction_list::iterator end) : Node(RETURN, begin, end) {} + + virtual void print(std::ostream& os) + { + Node::print(os); + os << boost::format("RETURN\n"); + } };/*}}}*/ -#if 0 -class CallNode : public OneWayNode +class CallNode : public TwoWayNode { public: CallNode( + Addr calladdr, Addr follower, Instruction_list::iterator begin, Instruction_list::iterator end) - : CallNode(CALL, follower, begin, end) + : TwoWayNode(CALL, calladdr, follower, begin, end) {} + virtual void print(std::ostream& os) + { + Node::print(os); + os << boost::format("CALL target=%08lx follow=%08lx\n") + % Successor(0).get() + % Successor(1).get(); + } }; -#endif #endif |
From: <wjh...@us...> - 2005-10-15 23:56:17
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14227 Modified Files: node.cpp usedefine.cpp Log Message: renamed CallExpressen+GlobalVariable. Index: node.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/node.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- node.cpp 23 Jul 2005 09:23:26 -0000 1.3 +++ node.cpp 15 Oct 2005 23:56:03 -0000 1.4 @@ -26,6 +26,7 @@ #include "node.hpp" #include "dataflow.hpp" +// this finds consequetive sequences of instructions. void Node::CreateList(Instruction_list& instructions, Node_list& nodes)/*{{{*/ { Instruction_list::iterator cur = instructions.begin(); @@ -73,7 +74,22 @@ node.reset( new ReturnNode(begin, cur) ); begin = cur; break; - +/* + * TODO: currently call's are in the instruction list as: + * AssignmentInstruction(CallExpression()) + case Instruction::CALL: + cur++; + node.reset( new CallNode(instruction->Address(), instruction->.., begin, cur) ); + begin = cur; + break; +*/ +/* + case Instruction::SWITCH: + cur++; + node.reset( new N_WayNode(GetSwitchExpression(), begin, cur) ); + begin = cur; + break; +*/ default: cur++; break; @@ -98,11 +114,11 @@ if (destination->IsType(Expression::GLOBAL)) { - address = static_cast<Global*>(destination.get())->Address(); + address = static_cast<GlobalVariable*>(destination.get())->Address(); } else { - message("%p Error! Jump destination is not a Global!\n", jump->Address()); + message("%p Error! Jump destination is not a GlobalVariable!\n", jump->Address()); address = INVALID_ADDR; } @@ -121,11 +137,11 @@ if (destination->IsType(Expression::GLOBAL)) { - address = static_cast<Global*>(destination.get())->Address(); + address = static_cast<GlobalVariable*>(destination.get())->Address(); } else { - message("%p Error! Jump destination is not a Global!\n", jump->Address()); + message("%p Error! Jump destination is not a GlobalVariable!\n", jump->Address()); address = INVALID_ADDR; } @@ -151,6 +167,8 @@ typedef std::map<Addr, Node_ptr> Node_map; + + struct ConnectSuccessorsMapBuilder { Node_map& mMap; Index: usedefine.cpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/usedefine.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- usedefine.cpp 20 Jun 2002 18:00:45 -0000 1.1.1.1 +++ usedefine.cpp 15 Oct 2005 23:56:03 -0000 1.2 @@ -41,9 +41,9 @@ } virtual void Visit(BinaryExpression&) {} - virtual void Visit(Call& expression) {} + virtual void Visit(CallExpression& expression) {} virtual void Visit(Dummy&) {} - virtual void Visit(Global&) {} + virtual void Visit(GlobalVariable&) {} virtual void Visit(NumericLiteral&) {} virtual void Visit(StackVariable&) {} virtual void Visit(StringLiteral&) {} |
From: <wjh...@us...> - 2005-10-15 23:56:04
|
Update of /cvsroot/desquirr/desquirr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14215 Modified Files: instruction.hpp Log Message: added print functions to all insn types Index: instruction.hpp =================================================================== RCS file: /cvsroot/desquirr/desquirr/instruction.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- instruction.hpp 23 Jul 2005 10:02:05 -0000 1.7 +++ instruction.hpp 15 Oct 2005 23:55:56 -0000 1.8 @@ -22,7 +22,24 @@ // $Id$ #ifndef _INSTRUCTION_HPP #define _INSTRUCTION_HPP - +/* + * +Instruction ... ea + LowLevel ... insn_t + Label ... name + Case ... case_value + Throw ... exception_expr, datatype + UnaryInstruction ... operand + Push ... operand + Pop ... operand + Jump ... target=opnd + Return ... returnvalue=opnd + Switch ... switchvalue=opnd, ??? +--- Call ... target=opnd + BinaryInstruction ... first, second + ConditionalJump ... cond=first, target=second + Assignment ... dest=first, src=second + */ #include <sstream> #include "desquirr.hpp" @@ -128,14 +145,13 @@ count++; return count; } - - void Dump(std::ostream& os) const + friend std::ostream& operator<< (std::ostream& os, const BoolArray& ba) { bool first = true; os << '{'; for (int i = 0; i < SIZE; i++) { - if (Get(i)) + if (ba.Get(i)) { if (first) first = false; @@ -146,8 +162,8 @@ } } os << '}'; + return os; } - private: BITFIELD mBitfield; @@ -172,6 +188,8 @@ class InstructionVisitor { public: + virtual ~InstructionVisitor() {} + virtual void Visit(Assignment&) = 0; virtual void Visit(Case&) = 0; virtual void Visit(ConditionalJump&) = 0; @@ -272,10 +290,10 @@ return false; } - BoolArray& Definitions() { return mDefinitions; } - BoolArray& Uses() { return mUses; } - BoolArray& LastDefinitions() { return mLastDefinitions; } - BoolArray& FlagDefinitions() { return mFlagDefinitions; } + BoolArray& Definitions() { return mDefinitions; } + BoolArray& Uses() { return mUses; } + BoolArray& LastDefinitions() { return mLastDefinitions; } + BoolArray& FlagDefinitions() { return mFlagDefinitions; } RegisterToAddress_map& DuChain() { return mDuChain; } @@ -315,7 +333,23 @@ }/*}}}*/ static void FindDefintionUseChains(Instruction_list& instructions); + static void DumpInstructionList(Instruction_list& insns); + friend std::ostream& operator<< (std::ostream& os, Instruction& insn) + { + insn.print(os); + return os; + } + + virtual void print(std::ostream& os) + { + os << boost::format(" insn %08lx") + % Address(); + os << " use=" << Uses(); + os << " def=" << Definitions(); + os << " last=" << LastDefinitions(); + os << " flag=" << FlagDefinitions(); + } protected: Instruction(InstructionType type, Addr ea) : mType(type), mAddress(ea) @@ -341,14 +375,19 @@ Label(Addr ea, const char* name) : Instruction(LABEL, ea), mName(name) {} + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << boost::format("LABEL %s\n") + % Name(); + } - const char* Name() { return mName.c_str(); } + const std::string& Name() const { return mName; } virtual void Accept(InstructionVisitor& visitor) { visitor.Visit(*this); } - private: std::string mName; };/*}}}*/ @@ -383,7 +422,7 @@ if (0 == index) mOperand = e; else - msg("ERROR: UnaryInstruction(%d, %08lx)\n", index, e); + msg("ERROR: UnaryInstruction(%d, %08lx)\n", index, e.get()); } #endif @@ -433,7 +472,7 @@ else if (1 == index) mSecond = e; else - msg("ERROR: BinaryInstruction(%d, %08lx)\n", index, e); + msg("ERROR: BinaryInstruction(%d, %08lx)\n", index, e.get()); } #endif @@ -458,6 +497,11 @@ Push(Addr ea, Expression_ptr operand) : UnaryInstruction(PUSH, ea, operand) {} + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << "PUSH " << *Operand(0) << "\n"; + } virtual void Accept(InstructionVisitor& visitor) { @@ -476,7 +520,12 @@ Pop(Addr ea, Expression_ptr operand) : UnaryInstruction(POP, ea, operand) {} - + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << "POP " << *Operand(0) << "\n"; + } + virtual void Accept(InstructionVisitor& visitor) { visitor.Visit(*this); @@ -522,7 +571,12 @@ Jump(Addr ea, Expression_ptr destination) : UnaryInstruction(JUMP, ea, destination) {} - + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << "JUMP " << *Operand(0) << "\n"; + } + virtual void Accept(InstructionVisitor& visitor) { visitor.Visit(*this); @@ -540,7 +594,12 @@ Return(Addr ea, Expression_ptr value) : UnaryInstruction(RETURN, ea, value) {} - + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << "RETURN " << *Operand(0) << "\n"; + } + virtual void Accept(InstructionVisitor& visitor) { visitor.Visit(*this); @@ -564,6 +623,11 @@ Expression_ptr condition, Expression_ptr destination) : BinaryInstruction(CONDITIONAL_JUMP, ea, condition, destination) {} + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << "CONDITIONAL (" << *Operand(0) << ") goto " << *Operand(1) << "\n"; + } virtual void Accept(InstructionVisitor& visitor) { @@ -583,6 +647,11 @@ Assignment(Addr ea, Expression_ptr destination, Expression_ptr source) : BinaryInstruction(ASSIGNMENT, ea, destination, source) {} + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << "ASSIGN " << *Operand(0) << " := " << *Operand(1) << "\n"; + } bool IsCall() { @@ -650,6 +719,11 @@ Switch(Addr ea, Expression_ptr value/*, switch_info_t& si*/) : UnaryInstruction(SWITCH, ea, value)//, mSwitchInfo(si) {} + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << "SWITCH " << *Operand(0) << "\n"; + } virtual void Accept(InstructionVisitor& visitor) { @@ -672,6 +746,11 @@ Case(Addr ea, unsigned int value) : Instruction(CASE, ea), mValue(value) {} + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << boost::format("CASE %08lx\n") % Value(); + } unsigned int Value() { return mValue; } @@ -690,9 +769,14 @@ class Throw : public Instruction/*{{{*/ { public: - Throw(Addr ea, Expression_ptr exception, std::string dataType) + Throw(Addr ea, Expression_ptr exception, const std::string& dataType) : Instruction(THROW, ea), mException(exception), mDataType(dataType) {} + virtual void print(std::ostream& os) + { + Instruction::print(os); + os << "THROW " << mDataType << " " << *mException << "\n"; + } Throw(Addr ea) : Instruction(THROW, ea) @@ -723,7 +807,7 @@ if (0 == index) mException = e; else - msg("ERROR: Throw(%d, %08lx)\n", index, e); + msg("ERROR: Throw(%d, %08lx)\n", index, e.get()); } bool IsRethrow() |