Skip to content
Snippets Groups Projects
Commit e02cbe3c authored by jdh8d's avatar jdh8d
Browse files

First draft and reading/using dead-reg annotations via stars2irdb w/libMEDS.

Former-commit-id: e615dc460ff8cb5faa96b8584985723e381d7fdb
parent 9b3a8dae
No related branches found
No related tags found
No related merge requests found
......@@ -300,6 +300,7 @@ libMEDSannotation/include/FuncExitAnnotation.hpp -text
libMEDSannotation/include/MEDS.hpp -text
libMEDSannotation/include/MEDS_AnnotationBase.hpp -text
libMEDSannotation/include/MEDS_AnnotationParser.hpp -text
libMEDSannotation/include/MEDS_DeadRegAnnotation.hpp -text
libMEDSannotation/include/MEDS_FPTRShadowAnnotation.hpp -text
libMEDSannotation/include/MEDS_FRSafeAnnotation.hpp -text
libMEDSannotation/include/MEDS_FuncAnnotation.hpp -text
......@@ -312,6 +313,7 @@ libMEDSannotation/include/MEDS_ShadowAnnotation.hpp -text
libMEDSannotation/include/VirtualOffset.hpp -text
libMEDSannotation/src/FuncExitAnnotation.cpp -text
libMEDSannotation/src/MEDS_AnnotationParser.cpp -text
libMEDSannotation/src/MEDS_DeadRegAnnotation.cpp -text
libMEDSannotation/src/MEDS_FPTRShadowAnnotation.cpp -text
libMEDSannotation/src/MEDS_FRSafeAnnotation.cpp -text
libMEDSannotation/src/MEDS_FuncPrototypeAnnotation.cpp -text
......
......@@ -10,6 +10,7 @@ files= '''
src/FuncExitAnnotation.cpp
src/MEDS_AnnotationParser.cpp
src/MEDS_FPTRShadowAnnotation.cpp
src/MEDS_DeadRegAnnotation.cpp
src/MEDS_FRSafeAnnotation.cpp
src/MEDS_FuncPrototypeAnnotation.cpp
src/MEDS_InstructionCheckAnnotation.cpp
......
......@@ -55,7 +55,6 @@ class MEDS_AnnotationBase
virtual void init() { m_isValid = false; m_size = 0; }
virtual bool isFuncAnnotation() const { return false; } // false by default
// virtual bool isFuncPrototypeAnnotation() const { return false; } // false by default
protected:
bool m_isValid;
......
/*
* Copyright (c) 2014 - Zephyr Software LLC
*
* This file may be used and modified for non-commercial purposes as long as
* all copyright, permission, and nonwarranty notices are preserved.
* Redistribution is prohibited without prior written consent from Zephyr
* Software.
*
* Please contact the authors for restrictions applying to commercial use.
*
* THIS SOURCE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Author: Zephyr Software
* e-mail: jwd@zephyr-software.com
* URL : http://www.zephyr-software.com/
*
*/
#ifndef _MEDS_DEADREGSANNOTATION_H_
#define _MEDS_DEADREGSANNOTATION_H_
#include <algorithm>
#include <string>
#include <stdint.h>
#include "VirtualOffset.hpp"
#include "MEDS_Register.hpp"
#include "MEDS_AnnotationBase.hpp"
namespace MEDS_Annotation
{
using namespace std;
using namespace MEDS_Annotation;
//
// Class to handle one MEDS limited function pointer shadow annotation
//
class MEDS_DeadRegAnnotation : public MEDS_AnnotationBase
{
public:
MEDS_DeadRegAnnotation();
MEDS_DeadRegAnnotation(const string& p_rawLine);
virtual ~MEDS_DeadRegAnnotation() {}
virtual const string toString() const { return "deadregs: " + m_rawInputLine; }
RegisterSet_t& getRegisterSet() { return regset; }
private:
// base class requirements.
void parse();
private:
RegisterSet_t regset;
string m_rawInputLine;
};
}
#endif
......@@ -29,6 +29,7 @@
#include "MEDS_ProblemFuncAnnotation.hpp"
#include "MEDS_FRSafeAnnotation.hpp"
#include "MEDS_FPTRShadowAnnotation.hpp"
#include "MEDS_DeadRegAnnotation.hpp"
// @todo: multiple annotation per instruction
......@@ -92,6 +93,7 @@ void MEDS_AnnotationParser::parseFile(istream &p_inputStream)
//cerr << "MEDS_AnnotationParser: line: " << line << endl;
if(add_if_valid<MEDS_DeadRegAnnotation>(line)) continue;
if(add_if_valid<MEDS_FPTRShadowAnnotation>(line)) continue;
if(add_if_valid<MEDS_InstructionCheckAnnotation>(line)) continue;
if(add_if_valid<MEDS_FuncPrototypeAnnotation>(line)) continue;
......
/*
* Copyright (c) 2014 - Zephyr Software LLC
*
* This file may be used and modified for non-commercial purposes as long as
* all copyright, permission, and nonwarranty notices are preserved.
* Redistribution is prohibited without prior written consent from Zephyr
* Software.
*
* Please contact the authors for restrictions applying to commercial use.
*
* THIS SOURCE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Author: Zephyr Software
* e-mail: jwd@zephyr-software.com
* URL : http://www.zephyr-software.com/
*
*/
#include <stdlib.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include "MEDS_DeadRegAnnotation.hpp"
using namespace std;
using namespace MEDS_Annotation;
/*
example:
4010f0 4 INSTR DEADREGS EFLAGS RAX ZZ sub rsp, 8 ; _init
need to parse out eflags, and rax into the regset variable.
*/
MEDS_DeadRegAnnotation::MEDS_DeadRegAnnotation()
{
setInvalid();
}
MEDS_DeadRegAnnotation::MEDS_DeadRegAnnotation(const string &p_rawLine)
{
setInvalid();
m_rawInputLine=p_rawLine;
parse();
}
void MEDS_DeadRegAnnotation::parse()
{
string tofind=" INSTR DEADREGS ";
size_t pos=m_rawInputLine.find(tofind);
if (pos==string::npos)
return;
// ignore result of getRegisterSet method because
// we don't need to parse the rest of the line.
Register::readRegisterSet(m_rawInputLine.substr(pos+tofind.length()), regset);
setValid();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment