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

gah, forgot to commit a few files.

Former-commit-id: 09bd427e933a6f89ca6df4257f682b847b8850ff
parent a073df28
Branches
Tags
No related merge requests found
...@@ -247,6 +247,7 @@ libIRDB/src/core/address.cpp -text ...@@ -247,6 +247,7 @@ libIRDB/src/core/address.cpp -text
libIRDB/src/core/all.hpp -text libIRDB/src/core/all.hpp -text
libIRDB/src/core/baseobj.cpp -text libIRDB/src/core/baseobj.cpp -text
libIRDB/src/core/dbinterface.cpp -text libIRDB/src/core/dbinterface.cpp -text
libIRDB/src/core/eh.cpp -text
libIRDB/src/core/file.cpp -text libIRDB/src/core/file.cpp -text
libIRDB/src/core/fileir.cpp -text libIRDB/src/core/fileir.cpp -text
libIRDB/src/core/function.cpp -text libIRDB/src/core/function.cpp -text
...@@ -254,6 +255,7 @@ libIRDB/src/core/generate_spri.cpp -text ...@@ -254,6 +255,7 @@ libIRDB/src/core/generate_spri.cpp -text
libIRDB/src/core/icfs.cpp -text libIRDB/src/core/icfs.cpp -text
libIRDB/src/core/instruction.cpp -text libIRDB/src/core/instruction.cpp -text
libIRDB/src/core/pqxxdb.cpp -text libIRDB/src/core/pqxxdb.cpp -text
libIRDB/src/core/reloc.cpp -text
libIRDB/src/core/scoop.cpp -text libIRDB/src/core/scoop.cpp -text
libIRDB/src/core/type.cpp -text libIRDB/src/core/type.cpp -text
libIRDB/src/core/variantid.cpp -text libIRDB/src/core/variantid.cpp -text
......
...@@ -45,7 +45,7 @@ class Instruction_t : public BaseObj_t ...@@ -45,7 +45,7 @@ class Instruction_t : public BaseObj_t
std::string GetCallback() const { return callback; } std::string GetCallback() const { return callback; }
std::string GetComment() const { return comment; } std::string GetComment() const { return comment; }
EhProgram_t* GetEhProgram() const { return eh_pgm; } EhProgram_t* GetEhProgram() const { return eh_pgm; }
EhCallSite_t* GetEhCallSite_t() const { return eh_cs; } EhCallSite_t* GetEhCallSite() const { return eh_cs; }
void SetAddress(AddressID_t* newaddr) { my_address=newaddr; } void SetAddress(AddressID_t* newaddr) { my_address=newaddr; }
......
/*
* 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 <all.hpp>
#include <utils.hpp>
#include <tuple>
#include <functional>
#include <assert.h>
#include <sstream>
#include <iostream>
#include <iomanip>
using namespace libIRDB;
using namespace std;
bool libIRDB::operator<(const EhProgram_t&a, const EhProgram_t&b)
{
return tie(a.cie_program,a.fde_program,a.code_alignment_factor,a.data_alignment_factor,a.ptrsize)
<
tie(b.cie_program,b.fde_program,b.code_alignment_factor,b.data_alignment_factor,b.ptrsize);
}
namespace std
{
template<>
class hash<EhProgramListing_t>
{
public:
std::size_t operator()(const EhProgramListing_t& s) const
{
auto sub_hasher=std::hash<string>();
auto res=std::size_t(0);
for(const auto& i: s)
{
res ^= sub_hasher(i);
}
return res;
}
};
}
void libIRDB::EhProgram_t::print() const
{
std::hash<EhProgramListing_t> ehpgmlist_hash;
auto cie_hash=ehpgmlist_hash(cie_program);
auto fde_hash=ehpgmlist_hash(fde_program);
cout<<dec<<"CAF: "<<code_alignment_factor<<" DAF: "<<data_alignment_factor<<" ptrsize="<< +ptrsize<<" cie_hash: "<<hex<<cie_hash<<" fde_hash: "<<fde_hash<<endl;
}
std::string EhProgram_t::WriteToDB(File_t* fid) // writes to DB, ID is not -1.
{
auto str_to_encoded_string=[](const string& data) -> string
{
ostringstream hex_data;
hex_data << setfill('0') << hex;
for (size_t i = 0; i < data.length(); ++i)
hex_data << setw(2) << (int)(data[i]&0xff);
return hex_data.str();
};
auto vec_to_encoded_string=[&](const vector<string>& in) -> string
{
string q="";
for(const auto& i : in)
{
if(q!="")
q+=",";
q+=str_to_encoded_string(i);
}
return q;
};
string encoded_cie_program=vec_to_encoded_string(cie_program);
string encoded_fde_program=vec_to_encoded_string(fde_program);
string q;
q ="insert into " + fid->GetEhProgramTableName();
q+="(eh_pgm_id,caf,daf,ptrsize,cie_program,fde_program) "+
string(" VALUES (") +
string("'") + to_string(GetBaseID()) + string("', ") +
string("'") + to_string(code_alignment_factor) + string("', ") +
string("'") + to_string(data_alignment_factor) + string("', ") +
string("'") + to_string(+ptrsize) + string("', ") +
string("'") + encoded_cie_program + string("', ") +
string("'") + encoded_fde_program + string("') ; ");
return q;
}
std::string EhCallSite_t::WriteToDB(File_t* fid) // writes to DB, ID is not -1.
{
string q;
auto landing_pad_id=BaseObj_t::NOT_IN_DATABASE;
if(landing_pad != NULL)
landing_pad_id=landing_pad->GetBaseID();
q ="insert into " + fid->GetEhCallSiteTableName();
q+="(ehcs_id,tt_encoding,lp_insn_id) "+
string(" VALUES (") +
string("'") + to_string(GetBaseID()) + string("', ") +
string("'") + to_string(+tt_encoding) + string("', ") +
string("'") + to_string(landing_pad_id) + string("') ;");
return q;
}
/*
* 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 <all.hpp>
#include <utils.hpp>
using namespace std;
std::string Relocation_t::WriteToDB(File_t* fid, BaseObj_t* myinsn)
{
string q;
db_id_t wrt_id=wrt_obj ? wrt_obj->GetBaseID() : BaseObj_t::NOT_IN_DATABASE;
q ="insert into " + fid->relocs_table_name;
q+="(reloc_id,reloc_offset,reloc_type,instruction_id,wrt_id,addend,doip_id) "+
string(" VALUES (") +
string("'") + to_string(GetBaseID()) + string("', ") +
string("'") + to_string(offset) + string("', ") +
string("'") + (type) + string("', ") +
string("'") + to_string(myinsn->GetBaseID()) + string("', ") +
string("'") + to_string(wrt_id) + string("', ") +
string("'") + to_string(addend) + string("', ") +
string("'") + to_string(GetDoipID()) + string("') ; ") ;
return q;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment