Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMPStaticAnalyzer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
SMPStaticAnalyzer
Compare revisions
21f81981bd84809e87ae4000df504b558330a01f to c83b62097a717690207cb668f7105247780d5190
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
opensrc/SMPStaticAnalyzer
Select target project
No results found
c83b62097a717690207cb668f7105247780d5190
Select Git revision
Swap
Target
opensrc/SMPStaticAnalyzer
Select target project
opensrc/SMPStaticAnalyzer
1 result
21f81981bd84809e87ae4000df504b558330a01f
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
Stack frame analysis fix when push occurs after frame alloc.
· c83b6209
Clark Coleman
authored
5 years ago
c83b6209
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/base/SMPFunction.cpp
+27
-16
27 additions, 16 deletions
src/base/SMPFunction.cpp
src/interfaces/idapro/STARSIDAProgram.cpp
+5
-1
5 additions, 1 deletion
src/interfaces/idapro/STARSIDAProgram.cpp
with
32 additions
and
17 deletions
src/base/SMPFunction.cpp
View file @
c83b6209
...
...
@@ -2936,7 +2936,8 @@ bool SMPFunction::MDFixFrameInfo(void) {
CallAddr = InstAddr;
}
if (CurrInstr->MDIsPushInstr()) {
SaveAddr = InstAddr;
if (!FoundAllocInstr)
SaveAddr = InstAddr;
// We will make the gcc-linux assumption that a PUSH in
// the first basic block, prior to the stack allocating
// instruction, is a callee register save. To make this
...
...
@@ -3068,7 +3069,7 @@ bool SMPFunction::MDFixFrameInfo(void) {
if (CallSeen) {
++PostCallNonAllocInstructions;
if (STARS_POST_CALL_NONALLOC_INSTR_LIMIT <= PostCallNonAllocInstructions) {
SMP_msg("INFO: Stopping search of first block
after call
for frame allocations at %llx\n",
SMP_msg("INFO: Stopping search of first block for frame allocations
after call
at %llx\n",
(unsigned long long) InstAddr);
break;
}
...
...
@@ -3210,14 +3211,13 @@ void SMPFunction::MDFindSavedRegs(void) {
STARS_Function_t *CurrFunc = SMP_get_func(this->GetStartAddr());
assert(nullptr != CurrFunc);
for (InstIter = this->Instrs.begin(); InstIter != this->Instrs.end(); ++InstIter) {
SMPInstr *CurrInst = (*InstIter);
if (CurrInst->IsMarkerInst())
continue;
if (CurrInst->GetAddr() > this->LocalVarsAllocInstr)
break;
if (!(CurrInst->MDIsPushInstr()))
continue;
for (SMPInstr *CurrInst : this->Instrs) {
STARS_ea_t InstAddr = CurrInst->GetAddr();
if (!(CurrInst->MDIsPushInstr())) {
if (InstAddr != this->LocalVarsAllocInstr) {
continue;
}
}
STARS_sval_t CurrOffset = CurrInst->GetStackPtrOffset();
if (CurrInst->GetIDAOpcode() == STARS_NN_push) {
...
...
@@ -3251,6 +3251,9 @@ void SMPFunction::MDFindSavedRegs(void) {
else if (CurrInst->MDIsEnterInstr()) {
this->SavedRegLoc[(std::size_t) STARS_x86_R_bp] = CurrOffset - global_STARS_program->GetSTARS_ISA_Bytewidth();
}
if (InstAddr == this->LocalVarsAllocInstr)
break;
} // end for all instructions
return;
...
...
@@ -4665,6 +4668,7 @@ bool SMPFunction::IsDefnInStackPtrCopySet(const STARSOpndTypePtr &CurrOp, const
// Return true if such an allocation is found and false otherwise.
bool SMPFunction::FindAlloca(void) {
bool FoundAlloca = false;
bool FoundFrameAlloc = false;
list<SMPInstr *>::iterator InstIter = this->Instrs.begin();
SMPInstr *CurrInst;
STARS_ea_t InstAddr;
...
...
@@ -4674,7 +4678,9 @@ bool SMPFunction::FindAlloca(void) {
for ( ; InstIter != this->Instrs.end(); ++InstIter) {
CurrInst = (*InstIter);
InstAddr = CurrInst->GetAddr();
if (InstAddr > this->LocalVarsAllocInstr) {
if (InstAddr == this->LocalVarsAllocInstr)
FoundFrameAlloc = true;
else if (FoundFrameAlloc) {
if (CurrInst->MDIsFrameAllocInstr()) {
FoundAlloca = true;
if (CurrInst->HasAllocaRTL()) {
...
...
@@ -4735,8 +4741,13 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) {
STARS_asize_t TempRegionBytes = (STARS_asize_t) CurrentRegionBytes;
STARS_asize_t TempOutArgsSize = (STARS_asize_t) this->OutgoingArgsSize;
if (this->GetLocalVarsSize() != (TempRegionBytes + TempOutArgsSize)) {
SMP_msg("ERROR: LocalVarsSize: %lu not sum of CurrentRegionBytes: %lu and OutArgsSize: %lu at %llx\n",
(unsigned long) this->GetLocalVarsSize(), (unsigned long)TempRegionBytes, (unsigned long)TempOutArgsSize, (uint64_t)addr);
if (!this->HasPushAfterFrameAlloc()) {
SMP_msg("ERROR: LocalVarsSize: %lu not sum of CurrentRegionBytes: %lu and OutArgsSize: %lu at %llx\n",
(unsigned long) this->GetLocalVarsSize(), (unsigned long)TempRegionBytes, (unsigned long)TempOutArgsSize, (uint64_t)addr);
#if 1
this->Dump();
#endif
}
}
SMP_fprintf(AnnotFile, "%18llx %6u DATAREF STACK %lu esp + 0 PARENT LocalFrame LOCALFRAME\n",
(unsigned long long) addr, CurrentRegionBytes + this->OutgoingArgsSize, (unsigned long) ParentReferentID);
...
...
@@ -17211,14 +17222,14 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) {
SMP_fprintf(AnnotFile, "FUNC_LEAF ");
// Store the first return instruction's address
// NOTE: This was useless info and we just print an address to keep the line format the same for easy parsing.
SMP_fprintf(AnnotFile,"%18llx ", (u
nsigned long long)
(this->FuncInfo->get_startEA() + this->FuncInfo->GetFuncSize() - 1));
SMP_fprintf(AnnotFile,
"%18llx ", (u
int64_t)
(this->FuncInfo->get_startEA() + this->FuncInfo->GetFuncSize() - 1));
if (this->IsLibFunc())
SMP_fprintf(AnnotFile, "LIBRARY ");
SMP_fprintf(AnnotFile, "\n");
// Emit annotations about how to restore register values
SMP_fprintf(AnnotFile, "%18llx %6d FUNC FRAMERESTORE ", (u
nsigned long long
) this->GetStartAddr(), 0);
SMP_fprintf(AnnotFile, "%18llx %6d FUNC FRAMERESTORE ", (u
int64_t
) this->GetStartAddr(), 0);
for (int i = STARS_x86_R_ax; i <= global_STARS_program->GetSTARS_MD_LAST_SAVED_REG_NUM(); i++) {
SMP_fprintf(AnnotFile, "%d %d %d ", i, this->SavedRegLoc[i], this->ReturnRegTypes[i]);
}
...
...
@@ -17226,7 +17237,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) {
// Print type left in the return register.
if (MD_RETURN_VALUE_REG != STARS_x86_R_none) {
SMP_fprintf(InfoAnnotFile, "%18llx %6u FUNC RETURNTYPE ", (u
nsigned long long
) this->GetStartAddr(), this->Size);
SMP_fprintf(InfoAnnotFile, "%18llx %6u FUNC RETURNTYPE ", (u
int64_t
) this->GetStartAddr(), this->Size);
SMP_fprintf(InfoAnnotFile, "%s %d\n", MDGetRegNumName(MD_RETURN_VALUE_REG, global_STARS_program->GetSTARS_ISA_Bytewidth()), this->ReturnRegTypes[MD_RETURN_VALUE_REG]);
}
// Print types of incoming arguments, if any.
...
...
This diff is collapsed.
Click to expand it.
src/interfaces/idapro/STARSIDAProgram.cpp
View file @
c83b6209
...
...
@@ -469,7 +469,11 @@ void STARS_IDA_Program_t::PrintAllAddressTakenXrefs(STARS_ea_t InstAddr, std::si
const
auto
to_addr
=
xrefs
.
GetTo
();
// skip empty To fields.
if
(
to_addr
==
0
)
continue
;
if
(
to_addr
==
0
)
continue
;
STARS_Segment_t
*
AddrSeg
=
global_stars_interface
->
getseg
(
to_addr
);
if
(
nullptr
==
AddrSeg
)
continue
;
// skip constants that are not even addresses in segments
/*
auto addr=STARS_InstructionID_t(to_addr);
...
...
This diff is collapsed.
Click to expand it.