Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • opensrc/SMPStaticAnalyzer
1 result
Show changes
Commits on Source (1)
......@@ -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 ", (unsigned long long) (this->FuncInfo->get_startEA() + this->FuncInfo->GetFuncSize() - 1));
SMP_fprintf(AnnotFile, "%18llx ", (uint64_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 ", (unsigned long long) this->GetStartAddr(), 0);
SMP_fprintf(AnnotFile, "%18llx %6d FUNC FRAMERESTORE ", (uint64_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 ", (unsigned long long) this->GetStartAddr(), this->Size);
SMP_fprintf(InfoAnnotFile, "%18llx %6u FUNC RETURNTYPE ", (uint64_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.
......
......@@ -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);
......