Skip to content
Snippets Groups Projects
Commit b32c7093 authored by Jason Hiser's avatar Jason Hiser :tractor:
Browse files

revised edt tests to work with irdb-sdk

Former-commit-id: c27b08f85e91e3c01c8336779ba997f6c89dcce6
parent bccdc062
No related branches found
No related tags found
No related merge requests found
......@@ -9,10 +9,12 @@ myenv=env.Clone()
myenv.Replace(SECURITY_TRANSFORMS_HOME=os.environ['SECURITY_TRANSFORMS_HOME'])
myenv.Replace(ZIPR_HOME=os.environ['ZIPR_HOME'])
myenv.Replace(ZIPR_SDK=os.environ['ZIPR_SDK'])
myenv.Replace(IRDB_SDK=os.environ['IRDB_SDK'])
myenv.Replace(ZIPR_INSTALL=os.environ['ZIPR_INSTALL'])
myenv.Replace(CXXFLAGS = " -g -std=c++11 -Wall ")
cpppath='''
$IRDB_SDK/include
$SECURITY_TRANSFORMS_HOME/include
$SECURITY_TRANSFORMS_HOME/libIRDB/include
$SECURITY_TRANSFORMS_HOME/libMEDSannotation/include
......
#include "edt.hpp"
#include <libElfDep.hpp>
#include "Rewrite_Utility.hpp"
#include <Rewrite_Utility.hpp>
#include <algorithm>
using namespace libTransform;
using namespace libIRDB;
using namespace IRDB_SDK;
using namespace std;
using namespace IRDBUtility;
using namespace ElfDep_Tester;
......@@ -23,7 +23,7 @@ ElfDep_Tester_t::ElfDep_Tester_t(FileIR_t* firp)
int ElfDep_Tester_t::execute()
{
// insert the PLT and GOT entries needed
auto ed=ElfDependencies_t(getFileIR());
auto ed=libIRDB::ElfDependencies_t(getFileIR());
(void)ed.appendLibraryDepedencies("libelf_dep_test.so");
auto edpcb=ed.appendPltEntry("elf_dep_test_callback");
auto edvar=ed.appendGotEntry("elf_dep_test_var");
......@@ -32,11 +32,11 @@ int ElfDep_Tester_t::execute()
// find the insertion point.
const auto &all_funcs=getFileIR()->GetFunctions();
const auto main_func_it=find_if(ALLOF(all_funcs), [&](const Function_t* f) { return f->GetName()=="main";});
const auto &all_funcs=getFileIR()->getFunctions();
const auto main_func_it=find_if(ALLOF(all_funcs), [&](const Function_t* f) { return f->getName()=="main";});
assert(main_func_it!=all_funcs.end());
const auto main_func=*main_func_it;
auto insert_loc=main_func->GetEntryPoint();
auto insert_loc=main_func->getEntryPoint();
// insert the instrumentation
......@@ -61,10 +61,8 @@ int ElfDep_Tester_t::execute()
// map the load to point at the GOT entry.
auto got_reloc=new Relocation_t(BaseObj_t::NOT_IN_DATABASE, edvar_offset, "pcrel", edvar_scoop);
getFileIR()->GetRelocations().insert(got_reloc);
got_insn->GetRelocations().insert(got_reloc);
auto got_reloc=getFileIR()->addNewRelocation(got_insn, edvar_offset, "pcrel", edvar_scoop);
(void)got_reloc; // just give to IR
return 0;
}
......
#include <string>
#include <set>
#include <libIRDB-core.hpp>
#include <irdb-core>
#include <transform.hpp>
namespace ElfDep_Tester
{
using namespace libTransform;
using namespace libIRDB;
using namespace IRDB_SDK;
using namespace std;
......
......@@ -2,11 +2,11 @@
#include <fstream>
#include <string>
#include "edt.hpp"
#include <libIRDB-core.hpp>
#include <irdb-core>
#include <getopt.h>
using namespace std;
using namespace libIRDB;
using namespace IRDB_SDK;
using namespace ElfDep_Tester;
void usage(string programName)
......@@ -21,8 +21,7 @@ int main(int argc, char **argv)
char *strtolError = NULL;
int transformExitCode = 0;
int variantID = -1;
VariantID_t *pidp = NULL;
pqxxDB_t pqxx_interface;
auto pqxx_interface=pqxxDB_t::factory();
int exit_code=0;
/*
......@@ -69,21 +68,21 @@ int main(int argc, char **argv)
/* setup the interface to the sql server */
BaseObj_t::SetInterface(&pqxx_interface);
BaseObj_t::setInterface(pqxx_interface.get());
pidp=new VariantID_t(variantID);
assert(pidp && pidp->IsRegistered()==true);
auto pidp=VariantID_t::factory(variantID);
assert(pidp && pidp->isRegistered()==true);
for(set<File_t*>::iterator it=pidp->GetFiles().begin();
it!=pidp->GetFiles().end();
for(set<File_t*>::iterator it=pidp->getFiles().begin();
it!=pidp->getFiles().end();
++it)
{
try
{
/* read the IR from the DB */
File_t* this_file = *it;
FileIR_t *firp = new FileIR_t(*pidp, this_file);
cout<<"Transforming "<<this_file->GetURL()<<endl;
auto firp = FileIR_t::factory(pidp.get(), this_file);
cout<<"Transforming "<<this_file->getURL()<<endl;
assert(firp && pidp);
......@@ -91,7 +90,7 @@ int main(int argc, char **argv)
* Create a transformation and then
* invoke its execution.
*/
auto ed=ElfDep_Tester_t(firp);
auto ed=ElfDep_Tester_t(firp.get());
transformExitCode = ed.execute();
/*
* If everything about the transformation
......@@ -102,9 +101,8 @@ int main(int argc, char **argv)
{
if(getenv("MG_NOUPDATE")==NULL)
{
firp->WriteToDB();
firp->writeToDB();
}
delete firp;
}
else
{
......@@ -129,8 +127,7 @@ int main(int argc, char **argv)
exit(1);
}
}
pqxx_interface.Commit();
delete pidp;
pqxx_interface->commit();
return exit_code;
}
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