diff --git a/SConscript b/SConscript index 24c10568e47edf1e6dda13f3c6e4ac6bfac57a29..718e08038424c9fab7cc1c603d92e28bbe3091f8 100644 --- a/SConscript +++ b/SConscript @@ -1,66 +1,9 @@ -import os - +import os Import('env') -myenv=env.Clone() -myenv.Replace(SECURITY_TRANSFORMS_HOME=os.environ['SECURITY_TRANSFORMS_HOME']) - -installed=[] - -if 'build_tools' not in myenv or myenv['build_tools'] is None or int(myenv['build_tools']) == 1: - - cpppath=''' - $SECURITY_TRANSFORMS_HOME/include - $SECURITY_TRANSFORMS_HOME/libIRDB/include - $SECURITY_TRANSFORMS_HOME/libMEDSannotation/include - $SECURITY_TRANSFORMS_HOME/libEXEIO/include - ''' - - LIBPATH="$SECURITY_TRANSFORMS_HOME/lib" - LIBS=Split( 'IRDB-cfg IRDB-util ' + env.subst('$BASE_IRDB_LIBS')+ " MEDSannotation") - - myenv=myenv.Clone(CPPPATH=Split(cpppath)) - - myenv.Append(CCFLAGS=" -std=c++11 -Wall") - - ehframe=myenv.Object("read_ehframe.cpp"); - split_eh_frame=myenv.Object("split_eh_frame.cpp"); - - pgm=myenv.Program("fill_in_indtargs.exe", ehframe+split_eh_frame+Split("fill_in_indtargs.cpp check_thunks.cpp"), LIBPATH=LIBPATH, LIBS=LIBS) - install=myenv.Install("$SECURITY_TRANSFORMS_HOME/bin/", pgm) - Default(install) - installed=installed+install - - pgm=myenv.Program("fill_in_cfg.exe", split_eh_frame+Split("fill_in_cfg.cpp"), LIBPATH=LIBPATH, LIBS=LIBS) - install=myenv.Install("$SECURITY_TRANSFORMS_HOME/bin/", pgm) - Default(install) - installed=installed+install - - pgm=myenv.Program("fix_calls.exe", ehframe+Split("fix_calls.cpp"), LIBPATH=LIBPATH, LIBS=LIBS) - install=myenv.Install("$SECURITY_TRANSFORMS_HOME/bin/", pgm) - Default(install) - installed=installed+install - - # most programs go to $sectrans/bin - pgms='''clone - generate_spri - find_strings - mark_functions_safe - ''' - for i in Split(pgms): - # print "Registering pgm: "+ i - pgm=myenv.Program(target=i+".exe", source=Split(i+".cpp"), LIBPATH=LIBPATH, LIBS=LIBS) - install=myenv.Install("$SECURITY_TRANSFORMS_HOME/bin/", pgm) - Default(install) - installed=installed+install - - # ilr goes to $sectrans/plugins_install - pgm=myenv.Program(target="ilr.exe", source=Split("ilr.cpp"), LIBPATH=LIBPATH, LIBS=LIBS) - install=myenv.Install("$SECURITY_TRANSFORMS_HOME/plugins_install/", pgm) - Default(install) - installed=installed+install +lib=SConscript("src/SConscript") -Return('installed') +Return('lib') diff --git a/src/SConscript b/src/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..c6e12cac9d1dad532ff3750bec244af7ef3f6b56 --- /dev/null +++ b/src/SConscript @@ -0,0 +1,24 @@ +import os + + + +Import('env') +myenv=env.Clone() + +files="ehp.cpp" + +cpppath=''' + ../include + ''' + + +LIBPATH="$SECURITY_TRANSFORMS_HOME/lib" +LIBS=Split("") + +myenv=myenv.Clone(CPPPATH=Split(cpppath)) +myenv.Append(CXXFLAGS = " -std=c++11 -Wall -Werror -fmax-errors=2") + +lib=myenv.Library("ehp", Split(files), LIBPATH=LIBPATH, LIBS=LIBS) +Default(lib) + +Return('lib') diff --git a/src/SConstruct b/src/SConstruct new file mode 100644 index 0000000000000000000000000000000000000000..b5b7b78c5f88640c7e8877a9df76dc9191af7498 --- /dev/null +++ b/src/SConstruct @@ -0,0 +1,8 @@ + + + +env=Environment() +Export('env') +lib=SConscript("SConscript") + +Return('lib') diff --git a/src/split_eh_frame.cpp b/src/ehp.cpp similarity index 74% rename from src/split_eh_frame.cpp rename to src/ehp.cpp index 117895efbf7d199841600464ea2690fac4c550e0..62ead1e253c469b56e20dcf43c9fd3576678a77b 100644 --- a/src/split_eh_frame.cpp +++ b/src/ehp.cpp @@ -1,4 +1,3 @@ -#include <libIRDB-core.hpp> #include <iostream> #include <iomanip> #include <fstream> @@ -11,14 +10,10 @@ #include <algorithm> #include <memory> -#include <exeio.h> -#include "dwarf2.h" - -#include "eh_frame.hpp" +#include "ehp.hpp" using namespace std; -using namespace EXEIO; -using namespace libIRDB; +using namespace EHP; #define WHOLE_CONTAINER(s) begin(s), end(s) @@ -1038,12 +1033,6 @@ void cie_contents_t<ptrsize>::print() const } -template <int ptrsize> -void cie_contents_t<ptrsize>::build_ir(Instruction_t* insn) const -{ - // nothing to do? built up one level. - //eh_pgm.print(); -} template <int ptrsize> lsda_call_site_action_t<ptrsize>::lsda_call_site_action_t() : @@ -1246,98 +1235,6 @@ void lsda_call_site_t<ptrsize>::print() const } -template <int ptrsize> -bool lsda_call_site_t<ptrsize>::appliesTo(const Instruction_t* insn) const -{ - assert(insn && insn->GetAddress()); - auto insn_addr=insn->GetAddress()->GetVirtualOffset(); - - return ( call_site_addr <=insn_addr && insn_addr<call_site_end_addr ); -} - - -template <int ptrsize> -void lsda_call_site_t<ptrsize>::build_ir(Instruction_t* insn, const vector<lsda_type_table_entry_t <ptrsize> > &type_table, const uint8_t& tt_encoding, const OffsetMap_t& om, FileIR_t* firp) const -{ - assert(appliesTo(insn)); - - // find landing pad instruction. - auto lp_insn=(Instruction_t*)NULL; - auto lp_it=om.find(landing_pad_addr); - if(lp_it!=om.end()) - lp_insn=lp_it->second; - - // create the callsite. - auto new_ehcs = new EhCallSite_t(BaseObj_t::NOT_IN_DATABASE, tt_encoding, lp_insn); - firp->GetAllEhCallSites().insert(new_ehcs); - insn->SetEhCallSite(new_ehcs); - - //cout<<"landing pad addr : 0x"<<hex<<landing_pad_addr<<endl; - if(action_table.size() == 0 ) - { - new_ehcs->SetHasCleanup(); - // cout<<"Destructors to call, but no exceptions to catch"<<endl; - } - else - { - for_each(action_table.begin(), action_table.end(), [&](const lsda_call_site_action_t<ptrsize>& p) - { - const auto action=p.GetAction(); - if(action==0) - { - new_ehcs->GetTTOrderVector().push_back(action); - //cout<<"Cleanup only (no catches) ."<<endl; - } - else if(action>0) - { - new_ehcs->GetTTOrderVector().push_back(action); - const auto index=action - 1; - //cout<<"Catch for type: "; - // the type table reveral was done during parsing, type table is right-side-up now. - //type_table.at(index).print(); - auto wrt=(DataScoop_t*)NULL; - if(type_table.at(index).GetTypeInfoPointer()!=0) - { - wrt=firp->FindScoop(type_table.at(index).GetTypeInfoPointer()); - assert(wrt); - } - const auto offset=index*type_table.at(index).GetTTEncodingSize(); - auto addend=0; - if(wrt!=NULL) - addend=type_table.at(index).GetTypeInfoPointer()-wrt->GetStart()->GetVirtualOffset(); - auto newreloc=new Relocation_t(BaseObj_t::NOT_IN_DATABASE, offset, "type_table_entry", wrt, addend); - new_ehcs->GetRelocations().insert(newreloc); - firp->GetRelocations().insert(newreloc); - - //if(wrt==NULL) - // cout<<"Catch all in type table"<<endl; - //else - // cout<<"Catch for type at "<<wrt->GetName()<<"+0x"<<hex<<addend<<"."<<endl; - } - else if(action<0) - { - static auto already_warned=false; - if(!already_warned) - { - ofstream fout("warning.txt"); - fout<<"Dynamic exception specification in eh_frame not fully supported."<<endl; - already_warned=true; - } - - // this isn't right at all, but pretend it's a cleanup! - new_ehcs->SetHasCleanup(); - //cout<<"Cleanup only (no catches) ."<<endl; - } - else - { - cout<<"What? :"<< action <<endl; - exit(1); - } - }); - } -} - - template <int ptrsize> uint8_t lsda_t<ptrsize>::GetTTEncoding() const { return type_table_encoding; } @@ -1357,7 +1254,12 @@ lsda_t<ptrsize>::lsda_t() : {} template <int ptrsize> -bool lsda_t<ptrsize>::parse_lsda(const uint64_t lsda_addr, const DataScoop_t* gcc_except_scoop, const uint64_t fde_region_start) +bool lsda_t<ptrsize>::parse_lsda( + const uint64_t lsda_addr, + //const DataScoop_t* gcc_except_scoop, + const uint8_t* gcc_except_scoop_data, + const uint64_t fde_region_start + ) { // make sure there's a scoop and that we're in the range. if(!gcc_except_scoop) @@ -1457,7 +1359,9 @@ bool lsda_t<ptrsize>::parse_lsda(const uint64_t lsda_addr, const DataScoop_t* gc } else if(type_filter<0) { - // a type filter < 0 indicates a dynamic exception specification is in play. + // a type filter < 0 indicates a dynamic exception specification (DES) is in play. + // a DES is where the runtime enforces whether exceptions can be thrown or not, + // and if an unexpected exception is thrown, a separate handler is invoked. // these are not common and even less likely to be needed for correct execution. // we ignore for now. A warning is printed if they are found in build_ir. } @@ -1503,25 +1407,6 @@ void lsda_t<ptrsize>::print() const }); } -template <int ptrsize> -void lsda_t<ptrsize>::build_ir(Instruction_t* insn, const OffsetMap_t& om, FileIR_t* firp) const -{ - auto cs_it=find_if(call_site_table.begin(), call_site_table.end(), [&](const lsda_call_site_t<ptrsize>& p) - { - return p.appliesTo(insn); - }); - - if(cs_it!= call_site_table.end()) - { - cs_it->build_ir(insn, type_table, GetTTEncoding(), om, firp); - } - else - { - // no call site table entry for this instruction. - } -} - - template <int ptrsize> fde_contents_t<ptrsize>::fde_contents_t() : fde_position(0), @@ -1535,15 +1420,6 @@ fde_contents_t<ptrsize>::fde_contents_t() : {} -template <int ptrsize> -bool fde_contents_t<ptrsize>::appliesTo(const Instruction_t* insn) const -{ - assert(insn && insn->GetAddress()); - auto insn_addr=insn->GetAddress()->GetVirtualOffset(); - - return ( fde_start_addr<=insn_addr && insn_addr<fde_end_addr ); -} - template <int ptrsize> const cie_contents_t<ptrsize>& fde_contents_t<ptrsize>::GetCIE() const { return cie_info; } @@ -1563,7 +1439,8 @@ bool fde_contents_t<ptrsize>::parse_fde( const uint8_t* const data, const uint64_t max, const uint64_t eh_addr, - const DataScoop_t* gcc_except_scoop) + const uint8_t* gcc_except_scoop_data) +// const DataScoop_t* gcc_except_scoop) { auto &c=*this; const auto eh_frame_scoop_data=data; @@ -1642,29 +1519,9 @@ void fde_contents_t<ptrsize>::print() const cout<<" No LSDA for this FDE."<<endl; } -template <int ptrsize> -void fde_contents_t<ptrsize>::build_ir(Instruction_t* insn, const OffsetMap_t &om, FileIR_t* firp) const -{ - // assert this is the right FDE. - assert( fde_start_addr<= insn->GetAddress()->GetVirtualOffset() && insn->GetAddress()->GetVirtualOffset() <= fde_end_addr); - - //eh_pgm.print(fde_start_addr); - if(lsda_addr!=0) - lsda.build_ir(insn,om,firp); -} - -template <int ptrsize> -bool split_eh_frame_impl_t<ptrsize>::init_offset_map() -{ - for_each(firp->GetInstructions().begin(), firp->GetInstructions().end(), [&](Instruction_t* i) - { - offset_to_insn_map[i->GetAddress()->GetVirtualOffset()]=i; - }); - return false; -} template <int ptrsize> @@ -1727,35 +1584,6 @@ bool split_eh_frame_impl_t<ptrsize>::iterate_fdes() } -template <int ptrsize> -split_eh_frame_impl_t<ptrsize>::split_eh_frame_impl_t(FileIR_t* p_firp) - : firp(p_firp), - eh_frame_scoop(NULL), - eh_frame_hdr_scoop(NULL), - gcc_except_table_scoop(NULL) -{ - assert(firp!=NULL); - - // function to find a scoop by name. - auto lookup_scoop_by_name=[&](const string &name) -> DataScoop_t* - { - auto scoop_it=find_if(firp->GetDataScoops().begin(), firp->GetDataScoops().end(), [name](DataScoop_t* scoop) - { - return scoop->GetName()==name; - }); - - if(scoop_it!=firp->GetDataScoops().end()) - return *scoop_it; - return NULL; - }; - - eh_frame_scoop=lookup_scoop_by_name(".eh_frame"); - eh_frame_hdr_scoop=lookup_scoop_by_name(".eh_frame_hdr"); - gcc_except_table_scoop=lookup_scoop_by_name(".gcc_except_table"); - -} - - template <int ptrsize> bool split_eh_frame_impl_t<ptrsize>::parse() { @@ -1763,9 +1591,6 @@ bool split_eh_frame_impl_t<ptrsize>::parse() return true; // no frame info in this binary - if(init_offset_map()) - return true; - if(iterate_fdes()) return true; @@ -1787,270 +1612,4 @@ void split_eh_frame_impl_t<ptrsize>::print() const } -template <int ptrsize> -void split_eh_frame_impl_t<ptrsize>::build_ir() const -{ - typedef pair<EhProgram_t*,uint64_t> whole_pgm_t; - - auto reusedpgms=size_t(0); - struct EhProgramComparator_t { -// bool operator() (const EhProgram_t* a, const EhProgram_t* b) { return *a < *b; } - bool operator() (const whole_pgm_t& a, const whole_pgm_t& b) - { return tie(*a.first, a.second) < tie(*b.first,b.second); } - }; - - // this is used to avoid adding duplicate entries to the program's IR, it allows a lookup by value - // instead of the IR's set which allows duplicates. - auto eh_program_cache = set<whole_pgm_t, EhProgramComparator_t>(); - - // find the right cie and fde, and build the IR from those for this instruction. - auto build_ir_insn=[&](Instruction_t* insn) -> void - { - const auto tofind=fde_contents_t<ptrsize>( insn->GetAddress()->GetVirtualOffset(), insn->GetAddress()->GetVirtualOffset()+1 ); - const auto fie_it=fdes.find(tofind); - - if(fie_it!=fdes.end()) - { - - if(getenv("EHIR_VERBOSE")!=NULL) - { - cout<<hex<<insn->GetAddress()->GetVirtualOffset()<<":" - <<insn->GetBaseID()<<":"<<insn->getDisassembly()<<" -> "<<endl; - //fie_it->GetCIE().print(); - fie_it->print(); - } - - const auto fde_addr=fie_it->GetFDEStartAddress(); - const auto caf=fie_it->GetCIE().GetCAF(); - const auto daf=fie_it->GetCIE().GetDAF(); - const auto return_reg=fie_it->GetCIE().GetReturnRegister(); - const auto personality=fie_it->GetCIE().GetPersonality(); - const auto insn_addr=insn->GetAddress()->GetVirtualOffset(); - - auto import_pgm = [&](EhProgramListing_t& out_pgm, const eh_program_t<ptrsize> in_pgm) -> void - { - auto cur_addr=fde_addr; - for(const auto & insn : in_pgm.GetInstructions()) - { - if(insn.Advance(cur_addr, caf)) - { - if(cur_addr > insn_addr) - break; - } - else if(insn.isNop()) - { - // skip nops - } - else if(insn.isRestoreState()) - { - // if a restore state happens, pop back out any instructions until - // we find the corresponding remember_state - while(1) - { - if(out_pgm.size()==0) - { - // unmatched remember state - cerr<<"Error in CIE/FDE program: unmatched restore_state command"<<endl; - break; - } - const auto back_str=out_pgm.back(); - out_pgm.pop_back(); - const auto back_insn=eh_program_insn_t<ptrsize>(back_str); - if(back_insn.isRememberState()) - break; - } - } - else - { - string to_push(insn.GetBytes().begin(),insn.GetBytes().end()); - out_pgm.push_back(to_push); - } - - } - if(getenv("EHIR_VERBOSE")!=NULL) - { - cout<<"\tPgm has insn_count="<<out_pgm.size()<<endl; - } - }; - - // build an eh program on the stack; - - auto ehpgm=EhProgram_t(BaseObj_t::NOT_IN_DATABASE,caf,daf,return_reg, ptrsize); - import_pgm(ehpgm.GetCIEProgram(), fie_it->GetCIE().GetProgram()); - import_pgm(ehpgm.GetFDEProgram(), fie_it->GetProgram()); - - - if(getenv("EHIR_VERBOSE")!=NULL) - ehpgm.print(); - // see if we've already built this one. - auto ehpgm_it = eh_program_cache.find(whole_pgm_t(&ehpgm, personality)) ; - if(ehpgm_it != eh_program_cache.end()) - { - // yes, use the cached program. - insn->SetEhProgram(ehpgm_it->first); - if(getenv("EHIR_VERBOSE")!=NULL) - cout<<"Re-using existing Program!"<<endl; - reusedpgms++; - } - else /* doesn't yet exist! */ - { - - if(getenv("EHIR_VERBOSE")!=NULL) - cout<<"Allocating new Program!"<<endl; - - // allocate a new pgm in the heap so we can give it to the IR. - auto newehpgm=new EhProgram_t(ehpgm); // copy constructor - assert(newehpgm); - firp->GetAllEhPrograms().insert(newehpgm); - - // allocate a relocation for the personality and give it to the IR. - auto personality_scoop=firp->FindScoop(personality); - auto personality_insn_it=offset_to_insn_map.find(personality); - auto personality_insn=personality_insn_it==offset_to_insn_map.end() ? (Instruction_t*)NULL : personality_insn_it->second; - auto personality_obj = personality_scoop ? (BaseObj_t*)personality_scoop : (BaseObj_t*)personality_insn; - auto addend= personality_scoop ? personality - personality_scoop->GetStart()->GetVirtualOffset() : 0; - auto newreloc=new Relocation_t(BaseObj_t::NOT_IN_DATABASE, 0, "personality", personality_obj, addend); - assert(personality==0 || personality_obj!=NULL); - assert(newreloc); - - if(personality_obj==NULL) - { - if(getenv("EHIR_VERBOSE")!=NULL) - cout<<"Null personality obj: 0x"<<hex<<personality<<endl; - } - else if(personality_scoop) - { - if(getenv("EHIR_VERBOSE")!=NULL) - cout<<"Found personality scoop: 0x"<<hex<<personality<<" -> " - <<personality_scoop->GetName()<<"+0x"<<hex<<addend<<endl; - } - else if(personality_insn) - { - if(getenv("EHIR_VERBOSE")!=NULL) - cout<<"Found personality insn: 0x"<<hex<<personality<<" -> " - <<personality_insn->GetBaseID()<<":"<<personality_insn->getDisassembly()<<endl; - } - else - assert(0); - - newehpgm->GetRelocations().insert(newreloc); - firp->GetRelocations().insert(newreloc); - - - // record for this insn - insn->SetEhProgram(newehpgm); - - // update cache. - eh_program_cache.insert(whole_pgm_t(newehpgm,personality)); - } - - // build the IR from the FDE. - fie_it->GetCIE().build_ir(insn); - fie_it->build_ir(insn, offset_to_insn_map,firp); - } - else - { - if(getenv("EHIR_VERBOSE")!=NULL) - { - cout<<hex<<insn->GetAddress()->GetVirtualOffset()<<":" - <<insn->GetBaseID()<<":"<<insn->getDisassembly()<<" has no FDE "<<endl; - } - } - - }; - - - auto remove_reloc=[&](Relocation_t* r) -> void - { - firp->GetRelocations().erase(r); - delete r; - }; - - auto remove_address=[&](AddressID_t* a) -> void - { - firp->GetAddresses().erase(a); - for(auto &r : a->GetRelocations()) remove_reloc(r); - for(auto &r : firp->GetRelocations()) assert(r->GetWRT() != a); - delete a; - }; - - auto remove_scoop=[&] (DataScoop_t* s) -> void - { - if(s==NULL) - return; - firp->GetDataScoops().erase(s); - remove_address(s->GetStart()); - remove_address(s->GetEnd()); - for(auto &r : s->GetRelocations()) remove_reloc(r); - for(auto &r : firp->GetRelocations()) assert(r->GetWRT() != s); - delete s; - }; - - for(Instruction_t* i : firp->GetInstructions()) - { - build_ir_insn(i); - } - - cout<<"# ATTRIBUTE Split_Exception_Handler::total_eh_programs_created="<<dec<<firp->GetAllEhPrograms().size()<<endl; - cout<<"# ATTRIBUTE Split_Exception_Handler::total_eh_programs_reused="<<dec<<reusedpgms<<endl; - cout<<"# ATTRIBUTE Split_Exception_Handler::total_eh_programs="<<dec<<firp->GetAllEhPrograms().size()+reusedpgms<<endl; - cout<<"# ATTRIBUTE Split_Exception_Handler::pct_eh_programs="<<std::fixed<<((float)firp->GetAllEhPrograms().size()/(float)firp->GetAllEhPrograms().size()+reusedpgms)*100.00<<"%"<<endl; - cout<<"# ATTRIBUTE Split_Exception_Handler::pct_eh_programs_reused="<<std::fixed<<((float)reusedpgms/(float)firp->GetAllEhPrograms().size()+reusedpgms)*100.00<<"%"<<endl; - - remove_scoop(eh_frame_scoop); - remove_scoop(eh_frame_hdr_scoop); - remove_scoop(gcc_except_table_scoop); - -} - -template <int ptrsize> -libIRDB::Instruction_t* split_eh_frame_impl_t<ptrsize>::find_lp(libIRDB::Instruction_t* i) const -{ - const auto tofind=fde_contents_t<ptrsize>( i->GetAddress()->GetVirtualOffset(), i->GetAddress()->GetVirtualOffset()+1); - const auto fde_it=fdes.find(tofind); - - if(fde_it==fdes.end()) - return NULL; - - const auto &the_fde=*fde_it; - const auto &the_lsda=the_fde.GetLSDA(); - const auto &cstab = the_lsda.GetCallSites(); - - const auto cstab_it=find_if(cstab.begin(), cstab.end(), [&](const lsda_call_site_t <ptrsize>& cs) - { return cs.appliesTo(i); }); - if(cstab_it==cstab.end()) - return NULL; - - const auto &the_cstab_entry=*cstab_it; - const auto lp_addr= the_cstab_entry.GetLandingPadAddress(); - - const auto om_it=offset_to_insn_map.find(lp_addr); - - if(om_it==offset_to_insn_map.end()) - return NULL; - - auto lp=om_it->second; - return lp; -} - - -unique_ptr<split_eh_frame_t> split_eh_frame_t::factory(FileIR_t *firp) -{ - if( firp->GetArchitectureBitWidth()==64) - return unique_ptr<split_eh_frame_t>(new split_eh_frame_impl_t<8>(firp)); - else - return unique_ptr<split_eh_frame_t>(new split_eh_frame_impl_t<4>(firp)); - -} - -void split_eh_frame(FileIR_t* firp) -{ - auto found_err=false; - //auto eh_frame_splitter=(unique_ptr<split_eh_frame_t>)NULL; - const auto eh_frame_splitter=split_eh_frame_t::factory(firp); - found_err=eh_frame_splitter->parse(); - eh_frame_splitter->build_ir(); - - assert(!found_err); -} diff --git a/include/eh_frame.hpp b/src/ehp.hpp similarity index 86% rename from include/eh_frame.hpp rename to src/ehp.hpp index d5826f1eb9483f67b058da877b07ebcada86d696..420a0d747cd5a42b82f47a2e825c68274241a1b5 100644 --- a/include/eh_frame.hpp +++ b/src/ehp.hpp @@ -1,7 +1,6 @@ -#ifndef eh_frame_hpp -#define eh_frame_hpp +#ifndef ehp_hpp +#define ehp_hpp -#include <libIRDB-core.hpp> #include <iostream> #include <iomanip> #include <fstream> @@ -13,14 +12,16 @@ #include <elf.h> #include <algorithm> #include <memory> +#include <set> -#include <exeio.h> -#include "dwarf2.h" +#include "ehp_dwarf2.hpp" +namespace EHP +{ +using namespace std; -typedef std::map<libIRDB::virtual_offset_t, libIRDB::Instruction_t*> OffsetMap_t; template <int ptrsize> class eh_frame_util_t @@ -169,7 +170,6 @@ class cie_contents_t : eh_frame_util_t<ptrsize> const uint32_t max, const uint64_t eh_addr); void print() const ; - void build_ir(libIRDB::Instruction_t* insn) const; }; template <int ptrsize> @@ -254,9 +254,8 @@ class lsda_call_site_t : private eh_frame_util_t<ptrsize> void print() const; - bool appliesTo(const libIRDB::Instruction_t* insn) const; +// bool appliesTo(const libIRDB::Instruction_t* insn) const; - void build_ir(libIRDB::Instruction_t* insn, const std::vector<lsda_type_table_entry_t <ptrsize> > &type_table, const uint8_t& tt_encoding, const OffsetMap_t& om, libIRDB::FileIR_t* firp) const; }; @@ -287,9 +286,12 @@ class lsda_t : private eh_frame_util_t<ptrsize> lsda_t() ; - bool parse_lsda(const uint64_t lsda_addr, const libIRDB::DataScoop_t* gcc_except_scoop, const uint64_t fde_region_start); + bool parse_lsda(const uint64_t lsda_addr, + /*const libIRDB::DataScoop_t* gcc_except_scoop, */ + const uint8_t *gcc_except_scoop_data, + const uint64_t fde_region_start + ); void print() const; - void build_ir(libIRDB::Instruction_t* insn, const OffsetMap_t& om, libIRDB::FileIR_t* firp) const; const call_site_table_t<ptrsize> GetCallSites() const { return call_site_table;} @@ -322,7 +324,7 @@ class fde_contents_t : eh_frame_util_t<ptrsize> fde_end_addr(end_addr) {} - bool appliesTo(const libIRDB::Instruction_t* insn) const; +// bool appliesTo(const libIRDB::Instruction_t* insn) const; uint64_t GetFDEStartAddress() const { return fde_start_addr; } uint64_t GetFDEEndAddress() const {return fde_end_addr; } @@ -341,11 +343,11 @@ class fde_contents_t : eh_frame_util_t<ptrsize> const uint8_t* const data, const uint64_t max, const uint64_t eh_addr, - const libIRDB::DataScoop_t* gcc_except_scoop); + const uint8_t *gcc_except_scoop_data + /* const libIRDB::DataScoop_t* gcc_except_scoop*/); void print() const; - void build_ir(libIRDB::Instruction_t* insn, const OffsetMap_t &om, libIRDB::FileIR_t* firp) const; }; @@ -358,11 +360,7 @@ class split_eh_frame_t public: virtual bool parse()=0; - virtual void build_ir() const =0; virtual void print() const=0; - virtual libIRDB::Instruction_t* find_lp(libIRDB::Instruction_t*) const =0; - - static std::unique_ptr<split_eh_frame_t> factory(libIRDB::FileIR_t *firp); }; @@ -371,32 +369,32 @@ class split_eh_frame_impl_t : public split_eh_frame_t { private: +/* libIRDB::FileIR_t* firp; libIRDB::DataScoop_t* eh_frame_scoop; libIRDB::DataScoop_t* eh_frame_hdr_scoop; libIRDB::DataScoop_t* gcc_except_table_scoop; OffsetMap_t offset_to_insn_map; +*/ std::vector<cie_contents_t <ptrsize> > cies; std::set<fde_contents_t <ptrsize> > fdes; - bool init_offset_map(); - bool iterate_fdes(); public: +/* split_eh_frame_impl_t(libIRDB::FileIR_t* p_firp); +*/ bool parse(); void print() const; - void build_ir() const; - libIRDB::Instruction_t* find_lp(libIRDB::Instruction_t*) const ; }; -void split_eh_frame(libIRDB::FileIR_t* firp); - +} #endif + diff --git a/src/ehp_dwarf2.hpp b/src/ehp_dwarf2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6917b1457496310a34a8d33508e9ff89f062e56c --- /dev/null +++ b/src/ehp_dwarf2.hpp @@ -0,0 +1,595 @@ +/* Declarations and definitions of codes relating to the DWARF2 symbolic + debugging information format. + Copyright (C) 1992-2014 Free Software Foundation, Inc. + Contributed by Gary Funck (gary@intrepid.com). Derived from the + DWARF 1 implementation written by Ron Guilmette (rfg@monkeys.com). + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _DWARF2_H +#define _DWARF2_H 1 + +/* This file is derived from the DWARF specification (a public document) + Revision 2.0.0 (July 27, 1993) developed by the UNIX International + Programming Languages Special Interest Group (UI/PLSIG) and distributed + by UNIX International. Copies of this specification are available from + UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054. */ + +/* This file is shared between GCC and GDB, and should not contain + prototypes. */ + +#ifndef __ASSEMBLER__ +/* Tag names and codes. */ + +enum dwarf_tag + { + DW_TAG_padding = 0x00, + DW_TAG_array_type = 0x01, + DW_TAG_class_type = 0x02, + DW_TAG_entry_point = 0x03, + DW_TAG_enumeration_type = 0x04, + DW_TAG_formal_parameter = 0x05, + DW_TAG_imported_declaration = 0x08, + DW_TAG_label = 0x0a, + DW_TAG_lexical_block = 0x0b, + DW_TAG_member = 0x0d, + DW_TAG_pointer_type = 0x0f, + DW_TAG_reference_type = 0x10, + DW_TAG_compile_unit = 0x11, + DW_TAG_string_type = 0x12, + DW_TAG_structure_type = 0x13, + DW_TAG_subroutine_type = 0x15, + DW_TAG_typedef = 0x16, + DW_TAG_union_type = 0x17, + DW_TAG_unspecified_parameters = 0x18, + DW_TAG_variant = 0x19, + DW_TAG_common_block = 0x1a, + DW_TAG_common_inclusion = 0x1b, + DW_TAG_inheritance = 0x1c, + DW_TAG_inlined_subroutine = 0x1d, + DW_TAG_module = 0x1e, + DW_TAG_ptr_to_member_type = 0x1f, + DW_TAG_set_type = 0x20, + DW_TAG_subrange_type = 0x21, + DW_TAG_with_stmt = 0x22, + DW_TAG_access_declaration = 0x23, + DW_TAG_base_type = 0x24, + DW_TAG_catch_block = 0x25, + DW_TAG_const_type = 0x26, + DW_TAG_constant = 0x27, + DW_TAG_enumerator = 0x28, + DW_TAG_file_type = 0x29, + DW_TAG_friend = 0x2a, + DW_TAG_namelist = 0x2b, + DW_TAG_namelist_item = 0x2c, + DW_TAG_packed_type = 0x2d, + DW_TAG_subprogram = 0x2e, + DW_TAG_template_type_param = 0x2f, + DW_TAG_template_value_param = 0x30, + DW_TAG_thrown_type = 0x31, + DW_TAG_try_block = 0x32, + DW_TAG_variant_part = 0x33, + DW_TAG_variable = 0x34, + DW_TAG_volatile_type = 0x35, + /* SGI/MIPS Extensions */ + DW_TAG_MIPS_loop = 0x4081, + /* GNU extensions */ + DW_TAG_format_label = 0x4101, /* for FORTRAN 77 and Fortran 90 */ + DW_TAG_function_template = 0x4102, /* for C++ */ + DW_TAG_class_template = 0x4103, /* for C++ */ + DW_TAG_GNU_BINCL = 0x4104, + DW_TAG_GNU_EINCL = 0x4105 + }; + +#define DW_TAG_lo_user 0x4080 +#define DW_TAG_hi_user 0xffff + +/* flag that tells whether entry has a child or not */ +#define DW_children_no 0 +#define DW_children_yes 1 + +/* Form names and codes. */ +enum dwarf_form + { + DW_FORM_addr = 0x01, + DW_FORM_block2 = 0x03, + DW_FORM_block4 = 0x04, + DW_FORM_data2 = 0x05, + DW_FORM_data4 = 0x06, + DW_FORM_data8 = 0x07, + DW_FORM_string = 0x08, + DW_FORM_block = 0x09, + DW_FORM_block1 = 0x0a, + DW_FORM_data1 = 0x0b, + DW_FORM_flag = 0x0c, + DW_FORM_sdata = 0x0d, + DW_FORM_strp = 0x0e, + DW_FORM_udata = 0x0f, + DW_FORM_ref_addr = 0x10, + DW_FORM_ref1 = 0x11, + DW_FORM_ref2 = 0x12, + DW_FORM_ref4 = 0x13, + DW_FORM_ref8 = 0x14, + DW_FORM_ref_udata = 0x15, + DW_FORM_indirect = 0x16 + }; + +/* Attribute names and codes. */ + +enum dwarf_attribute + { + DW_AT_sibling = 0x01, + DW_AT_location = 0x02, + DW_AT_name = 0x03, + DW_AT_ordering = 0x09, + DW_AT_subscr_data = 0x0a, + DW_AT_byte_size = 0x0b, + DW_AT_bit_offset = 0x0c, + DW_AT_bit_size = 0x0d, + DW_AT_element_list = 0x0f, + DW_AT_stmt_list = 0x10, + DW_AT_low_pc = 0x11, + DW_AT_high_pc = 0x12, + DW_AT_language = 0x13, + DW_AT_member = 0x14, + DW_AT_discr = 0x15, + DW_AT_discr_value = 0x16, + DW_AT_visibility = 0x17, + DW_AT_import = 0x18, + DW_AT_string_length = 0x19, + DW_AT_common_reference = 0x1a, + DW_AT_comp_dir = 0x1b, + DW_AT_const_value = 0x1c, + DW_AT_containing_type = 0x1d, + DW_AT_default_value = 0x1e, + DW_AT_inline = 0x20, + DW_AT_is_optional = 0x21, + DW_AT_lower_bound = 0x22, + DW_AT_producer = 0x25, + DW_AT_prototyped = 0x27, + DW_AT_return_addr = 0x2a, + DW_AT_start_scope = 0x2c, + DW_AT_stride_size = 0x2e, + DW_AT_upper_bound = 0x2f, + DW_AT_abstract_origin = 0x31, + DW_AT_accessibility = 0x32, + DW_AT_address_class = 0x33, + DW_AT_artificial = 0x34, + DW_AT_base_types = 0x35, + DW_AT_calling_convention = 0x36, + DW_AT_count = 0x37, + DW_AT_data_member_location = 0x38, + DW_AT_decl_column = 0x39, + DW_AT_decl_file = 0x3a, + DW_AT_decl_line = 0x3b, + DW_AT_declaration = 0x3c, + DW_AT_discr_list = 0x3d, + DW_AT_encoding = 0x3e, + DW_AT_external = 0x3f, + DW_AT_frame_base = 0x40, + DW_AT_friend = 0x41, + DW_AT_identifier_case = 0x42, + DW_AT_macro_info = 0x43, + DW_AT_namelist_items = 0x44, + DW_AT_priority = 0x45, + DW_AT_segment = 0x46, + DW_AT_specification = 0x47, + DW_AT_static_link = 0x48, + DW_AT_type = 0x49, + DW_AT_use_location = 0x4a, + DW_AT_variable_parameter = 0x4b, + DW_AT_virtuality = 0x4c, + DW_AT_vtable_elem_location = 0x4d, + /* SGI/MIPS Extensions */ + DW_AT_MIPS_fde = 0x2001, + DW_AT_MIPS_loop_begin = 0x2002, + DW_AT_MIPS_tail_loop_begin = 0x2003, + DW_AT_MIPS_epilog_begin = 0x2004, + DW_AT_MIPS_loop_unroll_factor = 0x2005, + DW_AT_MIPS_software_pipeline_depth = 0x2006, + DW_AT_MIPS_linkage_name = 0x2007, + DW_AT_MIPS_stride = 0x2008, + DW_AT_MIPS_abstract_name = 0x2009, + DW_AT_MIPS_clone_origin = 0x200a, + DW_AT_MIPS_has_inlines = 0x200b, + /* GNU extensions. */ + DW_AT_sf_names = 0x2101, + DW_AT_src_info = 0x2102, + DW_AT_mac_info = 0x2103, + DW_AT_src_coords = 0x2104, + DW_AT_body_begin = 0x2105, + DW_AT_body_end = 0x2106 + }; + +#define DW_AT_lo_user 0x2000 /* implementation-defined range start */ +#define DW_AT_hi_user 0x3ff0 /* implementation-defined range end */ + +/* Location atom names and codes. */ + +enum dwarf_location_atom + { + DW_OP_addr = 0x03, + DW_OP_deref = 0x06, + DW_OP_const1u = 0x08, + DW_OP_const1s = 0x09, + DW_OP_const2u = 0x0a, + DW_OP_const2s = 0x0b, + DW_OP_const4u = 0x0c, + DW_OP_const4s = 0x0d, + DW_OP_const8u = 0x0e, + DW_OP_const8s = 0x0f, + DW_OP_constu = 0x10, + DW_OP_consts = 0x11, + DW_OP_dup = 0x12, + DW_OP_drop = 0x13, + DW_OP_over = 0x14, + DW_OP_pick = 0x15, + DW_OP_swap = 0x16, + DW_OP_rot = 0x17, + DW_OP_xderef = 0x18, + DW_OP_abs = 0x19, + DW_OP_and = 0x1a, + DW_OP_div = 0x1b, + DW_OP_minus = 0x1c, + DW_OP_mod = 0x1d, + DW_OP_mul = 0x1e, + DW_OP_neg = 0x1f, + DW_OP_not = 0x20, + DW_OP_or = 0x21, + DW_OP_plus = 0x22, + DW_OP_plus_uconst = 0x23, + DW_OP_shl = 0x24, + DW_OP_shr = 0x25, + DW_OP_shra = 0x26, + DW_OP_xor = 0x27, + DW_OP_bra = 0x28, + DW_OP_eq = 0x29, + DW_OP_ge = 0x2a, + DW_OP_gt = 0x2b, + DW_OP_le = 0x2c, + DW_OP_lt = 0x2d, + DW_OP_ne = 0x2e, + DW_OP_skip = 0x2f, + DW_OP_lit0 = 0x30, + DW_OP_lit1 = 0x31, + DW_OP_lit2 = 0x32, + DW_OP_lit3 = 0x33, + DW_OP_lit4 = 0x34, + DW_OP_lit5 = 0x35, + DW_OP_lit6 = 0x36, + DW_OP_lit7 = 0x37, + DW_OP_lit8 = 0x38, + DW_OP_lit9 = 0x39, + DW_OP_lit10 = 0x3a, + DW_OP_lit11 = 0x3b, + DW_OP_lit12 = 0x3c, + DW_OP_lit13 = 0x3d, + DW_OP_lit14 = 0x3e, + DW_OP_lit15 = 0x3f, + DW_OP_lit16 = 0x40, + DW_OP_lit17 = 0x41, + DW_OP_lit18 = 0x42, + DW_OP_lit19 = 0x43, + DW_OP_lit20 = 0x44, + DW_OP_lit21 = 0x45, + DW_OP_lit22 = 0x46, + DW_OP_lit23 = 0x47, + DW_OP_lit24 = 0x48, + DW_OP_lit25 = 0x49, + DW_OP_lit26 = 0x4a, + DW_OP_lit27 = 0x4b, + DW_OP_lit28 = 0x4c, + DW_OP_lit29 = 0x4d, + DW_OP_lit30 = 0x4e, + DW_OP_lit31 = 0x4f, + DW_OP_reg0 = 0x50, + DW_OP_reg1 = 0x51, + DW_OP_reg2 = 0x52, + DW_OP_reg3 = 0x53, + DW_OP_reg4 = 0x54, + DW_OP_reg5 = 0x55, + DW_OP_reg6 = 0x56, + DW_OP_reg7 = 0x57, + DW_OP_reg8 = 0x58, + DW_OP_reg9 = 0x59, + DW_OP_reg10 = 0x5a, + DW_OP_reg11 = 0x5b, + DW_OP_reg12 = 0x5c, + DW_OP_reg13 = 0x5d, + DW_OP_reg14 = 0x5e, + DW_OP_reg15 = 0x5f, + DW_OP_reg16 = 0x60, + DW_OP_reg17 = 0x61, + DW_OP_reg18 = 0x62, + DW_OP_reg19 = 0x63, + DW_OP_reg20 = 0x64, + DW_OP_reg21 = 0x65, + DW_OP_reg22 = 0x66, + DW_OP_reg23 = 0x67, + DW_OP_reg24 = 0x68, + DW_OP_reg25 = 0x69, + DW_OP_reg26 = 0x6a, + DW_OP_reg27 = 0x6b, + DW_OP_reg28 = 0x6c, + DW_OP_reg29 = 0x6d, + DW_OP_reg30 = 0x6e, + DW_OP_reg31 = 0x6f, + DW_OP_breg0 = 0x70, + DW_OP_breg1 = 0x71, + DW_OP_breg2 = 0x72, + DW_OP_breg3 = 0x73, + DW_OP_breg4 = 0x74, + DW_OP_breg5 = 0x75, + DW_OP_breg6 = 0x76, + DW_OP_breg7 = 0x77, + DW_OP_breg8 = 0x78, + DW_OP_breg9 = 0x79, + DW_OP_breg10 = 0x7a, + DW_OP_breg11 = 0x7b, + DW_OP_breg12 = 0x7c, + DW_OP_breg13 = 0x7d, + DW_OP_breg14 = 0x7e, + DW_OP_breg15 = 0x7f, + DW_OP_breg16 = 0x80, + DW_OP_breg17 = 0x81, + DW_OP_breg18 = 0x82, + DW_OP_breg19 = 0x83, + DW_OP_breg20 = 0x84, + DW_OP_breg21 = 0x85, + DW_OP_breg22 = 0x86, + DW_OP_breg23 = 0x87, + DW_OP_breg24 = 0x88, + DW_OP_breg25 = 0x89, + DW_OP_breg26 = 0x8a, + DW_OP_breg27 = 0x8b, + DW_OP_breg28 = 0x8c, + DW_OP_breg29 = 0x8d, + DW_OP_breg30 = 0x8e, + DW_OP_breg31 = 0x8f, + DW_OP_regx = 0x90, + DW_OP_fbreg = 0x91, + DW_OP_bregx = 0x92, + DW_OP_piece = 0x93, + DW_OP_deref_size = 0x94, + DW_OP_xderef_size = 0x95, + DW_OP_nop = 0x96 + }; + +#define DW_OP_lo_user 0x80 /* implementation-defined range start */ +#define DW_OP_hi_user 0xff /* implementation-defined range end */ + +/* Type encodings. */ + +enum dwarf_type + { + DW_ATE_void = 0x0, + DW_ATE_address = 0x1, + DW_ATE_boolean = 0x2, + DW_ATE_complex_float = 0x3, + DW_ATE_float = 0x4, + DW_ATE_signed = 0x5, + DW_ATE_signed_char = 0x6, + DW_ATE_unsigned = 0x7, + DW_ATE_unsigned_char = 0x8 + }; + +#define DW_ATE_lo_user 0x80 +#define DW_ATE_hi_user 0xff + +/* Array ordering names and codes. */ +enum dwarf_array_dim_ordering + { + DW_ORD_row_major = 0, + DW_ORD_col_major = 1 + }; + +/* access attribute */ +enum dwarf_access_attribute + { + DW_ACCESS_public = 1, + DW_ACCESS_protected = 2, + DW_ACCESS_private = 3 + }; + +/* visibility */ +enum dwarf_visibility_attribute + { + DW_VIS_local = 1, + DW_VIS_exported = 2, + DW_VIS_qualified = 3 + }; + +/* virtuality */ +enum dwarf_virtuality_attribute + { + DW_VIRTUALITY_none = 0, + DW_VIRTUALITY_virtual = 1, + DW_VIRTUALITY_pure_virtual = 2 + }; + +/* case sensitivity */ +enum dwarf_id_case + { + DW_ID_case_sensitive = 0, + DW_ID_up_case = 1, + DW_ID_down_case = 2, + DW_ID_case_insensitive = 3 + }; + +/* calling convention */ +enum dwarf_calling_convention + { + DW_CC_normal = 0x1, + DW_CC_program = 0x2, + DW_CC_nocall = 0x3 + }; + +#define DW_CC_lo_user 0x40 +#define DW_CC_hi_user 0xff + +/* inline attribute */ +enum dwarf_inline_attribute + { + DW_INL_not_inlined = 0, + DW_INL_inlined = 1, + DW_INL_declared_not_inlined = 2, + DW_INL_declared_inlined = 3 + }; + +/* discriminant lists */ +enum dwarf_discrim_list + { + DW_DSC_label = 0, + DW_DSC_range = 1 + }; + +/* line number opcodes */ +enum dwarf_line_number_ops + { + DW_LNS_extended_op = 0, + DW_LNS_copy = 1, + DW_LNS_advance_pc = 2, + DW_LNS_advance_line = 3, + DW_LNS_set_file = 4, + DW_LNS_set_column = 5, + DW_LNS_negate_stmt = 6, + DW_LNS_set_basic_block = 7, + DW_LNS_const_add_pc = 8, + DW_LNS_fixed_advance_pc = 9 + }; + +/* line number extended opcodes */ +enum dwarf_line_number_x_ops + { + DW_LNE_end_sequence = 1, + DW_LNE_set_address = 2, + DW_LNE_define_file = 3 + }; + +/* call frame information */ +enum dwarf_call_frame_info + { + DW_CFA_advance_loc = 0x40, + DW_CFA_offset = 0x80, + DW_CFA_restore = 0xc0, + DW_CFA_nop = 0x00, + DW_CFA_set_loc = 0x01, + DW_CFA_advance_loc1 = 0x02, + DW_CFA_advance_loc2 = 0x03, + DW_CFA_advance_loc4 = 0x04, + DW_CFA_offset_extended = 0x05, + DW_CFA_restore_extended = 0x06, + DW_CFA_undefined = 0x07, + DW_CFA_same_value = 0x08, + DW_CFA_register = 0x09, + DW_CFA_remember_state = 0x0a, + DW_CFA_restore_state = 0x0b, + DW_CFA_def_cfa = 0x0c, + DW_CFA_def_cfa_register = 0x0d, + DW_CFA_def_cfa_offset = 0x0e, + DW_CFA_def_cfa_expression = 0x0f, + DW_CFA_expression = 0x10, + /* Dwarf 2.1 */ + DW_CFA_offset_extended_sf = 0x11, + DW_CFA_def_cfa_sf = 0x12, + DW_CFA_def_cfa_offset_sf = 0x13, + /* added by jdh for newer version of dwarf? libc uses this in ubuntu 14.04 */ + DW_CFA_val_offset = 0x14, + DW_CFA_val_offset_sf = 0x15, + DW_CFA_val_expression = 0x16, + + + /* SGI/MIPS specific */ + DW_CFA_MIPS_advance_loc8 = 0x1d, + + /* GNU extensions */ + DW_CFA_GNU_window_save = 0x2d, + DW_CFA_GNU_args_size = 0x2e, + DW_CFA_GNU_negative_offset_extended = 0x2f + }; + +#define DW_CIE_ID 0xffffffff +#define DW_CIE_VERSION 1 + +#define DW_CFA_extended 0 +#define DW_CFA_low_user 0x1c +#define DW_CFA_high_user 0x3f + +#define DW_CHILDREN_no 0x00 +#define DW_CHILDREN_yes 0x01 + +#define DW_ADDR_none 0 + +/* Source language names and codes. */ + +enum dwarf_source_language + { + DW_LANG_C89 = 0x0001, + DW_LANG_C = 0x0002, + DW_LANG_Ada83 = 0x0003, + DW_LANG_C_plus_plus = 0x0004, + DW_LANG_Cobol74 = 0x0005, + DW_LANG_Cobol85 = 0x0006, + DW_LANG_Fortran77 = 0x0007, + DW_LANG_Fortran90 = 0x0008, + DW_LANG_Pascal83 = 0x0009, + DW_LANG_Modula2 = 0x000a, + DW_LANG_Java = 0x000b, + DW_LANG_Mips_Assembler = 0x8001 + }; + + +#define DW_LANG_lo_user 0x8000 /* implementation-defined range start */ +#define DW_LANG_hi_user 0xffff /* implementation-defined range start */ + +/* Names and codes for macro information. */ + +enum dwarf_macinfo_record_type + { + DW_MACINFO_define = 1, + DW_MACINFO_undef = 2, + DW_MACINFO_start_file = 3, + DW_MACINFO_end_file = 4, + DW_MACINFO_vendor_ext = 255 + }; + +#endif /* !ASSEMBLER */ + +/* @@@ For use with GNU frame unwind information. */ + +#define DW_EH_PE_absptr 0x00 +#define DW_EH_PE_omit 0xff + +#define DW_EH_PE_uleb128 0x01 +#define DW_EH_PE_udata2 0x02 +#define DW_EH_PE_udata4 0x03 +#define DW_EH_PE_udata8 0x04 +#define DW_EH_PE_sleb128 0x09 +#define DW_EH_PE_sdata2 0x0A +#define DW_EH_PE_sdata4 0x0B +#define DW_EH_PE_sdata8 0x0C +#define DW_EH_PE_signed 0x08 + +#define DW_EH_PE_pcrel 0x10 +#define DW_EH_PE_textrel 0x20 +#define DW_EH_PE_datarel 0x30 +#define DW_EH_PE_funcrel 0x40 +#define DW_EH_PE_aligned 0x50 + +#define DW_EH_PE_indirect 0x80 + +#endif /* dwarf2.h */