Commit 02f2ff55 authored by Jason Hiser's avatar Jason Hiser 🚜

re-added yylex hack and fixed commenting style to be consistent

parent 342b6fa4
......@@ -29,9 +29,9 @@ using namespace std;
using namespace IRDB_SDK;
using namespace InitStack;
/*
* constructor
*/
//
// constructor
//
InitStack_t::InitStack_t(FileIR_t *p_variantIR, const string& p_functionsFilename, int p_initValue, bool p_verbose)
:
Transform_t(p_variantIR), // initialize the Transform class so things like insertAssembly and getFileIR() can be used
......@@ -52,11 +52,11 @@ InitStack_t::InitStack_t(FileIR_t *p_variantIR, const string& p_functionsFilenam
}
}
/*
* read list of functions to auto-initialize
*
* post conditions: set of functions to auto-initialize
*/
//
// read list of functions to auto-initialize
//
// post conditions: set of functions to auto-initialize
//
void InitStack_t::readFunctionsFromFile(const string &p_filename)
{
const auto &all_funcs=getFileIR()->getFunctions();
......@@ -79,13 +79,13 @@ void InitStack_t::readFunctionsFromFile(const string &p_filename)
}
}
/*
* Execute the transform by transforming all to-transform functions
*
* preconditions: the FileIR is read as from the IRDB. valid file listing functions to auto-initialize
* postcondition: instructions added to auto-initialize stack for each specified function
*
*/
//
// Execute the transform by transforming all to-transform functions
//
// preconditions: the FileIR is read as from the IRDB. valid file listing functions to auto-initialize
// postcondition: instructions added to auto-initialize stack for each specified function
//
//
bool InitStack_t::execute()
{
// transform all functions
......@@ -103,36 +103,37 @@ bool InitStack_t::execute()
return m_numTransformed>0; // true means success
}
/*
* preconditions : f is not NULL
* postconditions: stack auto-initialized if stack frame size > 0
*/
//
// preconditions : f is not NULL
// postconditions: stack auto-initialized if stack frame size > 0
//
void InitStack_t::initStack(Function_t* f)
{
/* preconditions */
// preconditions
assert(f!=nullptr);
/* check that the frame size is in the area we care about */
// check that the frame size is in the area we care about
const auto frame_size = f->getStackFrameSize();
const auto num_locs = static_cast<uint64_t> (ceil(frame_size / 4.0));
// todo: remove this line
if (frame_size <= MIN_STACK_FRAME_SIZE || frame_size >= MAX_STACK_FRAME_SIZE) return;
/* debug output */
// debug output
cout << "Function: " << f->getName() << " frame size: " << f->getStackFrameSize() << endl;
/* not all functions have an entry point */
// not all functions have an entry point
const auto entry = f->getEntryPoint();
if (!entry) return;
// log what we are doing
cout << "Function: " << f->getName() << " auto-initialize " << dec << num_locs << " stack memory locations (4 bytes at a time) with value = " << hex << m_initValue << endl;
/* determine the registers to use on x86-32 or x86-64 */
// determine the registers to use on x86-32 or x86-64
const auto sp_reg = getFileIR()->getArchitectureBitWidth()==64 ? "rsp" : "esp";
const auto scratch_reg = getFileIR()->getArchitectureBitWidth()==64 ? "r11" : "ecx";
// Now, do the dirty work of inserting new assembly to initialize the stack.
// assume: flags and scratch_reg are dead at function entry.
// insert these instructions at the start of the function (to initialize the stack frame before the function runs)
auto tmp=entry;
......
......@@ -183,6 +183,14 @@ bool StackStamp_t::can_stamp(Function_t* f)
}
};
//
// Hack alert!
// The yylex function is a problem in AWS so we return false. No additional detail is available.
// Future work: figure out why and remove this line.
//
if(f->getName()=="yylex") return false;
// we passed all sanity checks, so go ahead and stamp this function
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment