...
 
Commits (2)
...@@ -152,14 +152,14 @@ class LSDA_t ...@@ -152,14 +152,14 @@ class LSDA_t
virtual uint8_t getTTEncoding() const =0; virtual uint8_t getTTEncoding() const =0;
virtual void print() const=0; virtual void print() const=0;
virtual uint64_t getLandingPadBaseAddress() const = 0; virtual uint64_t getLandingPadBaseAddress() const = 0;
virtual const CallSiteVector_t* getCallSites() const =0; virtual const CallSiteVector_t* getCallSites() const =0;
virtual uint64_t getCallSiteTableAddress() const = 0; virtual uint64_t getCallSiteTableAddress() const = 0;
virtual uint64_t getCallSiteTableAddressLocation() const = 0; virtual uint64_t getCallSiteTableAddressLocation() const = 0;
virtual uint8_t getCallSiteTableEncoding() const = 0; virtual uint8_t getCallSiteTableEncoding() const = 0;
virtual const TypeTableVector_t* getTypeTable() const =0; virtual const TypeTableVector_t* getTypeTable() const =0;
virtual uint64_t getTypeTableAddress() const = 0; virtual uint64_t getTypeTableAddress() const = 0;
virtual uint64_t getTypeTableAddressLocation() const = 0; virtual uint64_t getTypeTableAddressLocation() const = 0;
virtual uint64_t getCallSiteTableLength() const = 0; virtual uint64_t getCallSiteTableLength() const = 0;
virtual uint8_t getTypeTableEncoding() const = 0; virtual uint8_t getTypeTableEncoding() const = 0;
unique_ptr<LSDA_t> factory(const string lsda_data, const uint64_t lsda_start_addr); unique_ptr<LSDA_t> factory(const string lsda_data, const uint64_t lsda_start_addr);
}; };
...@@ -182,15 +182,16 @@ class FDEContents_t ...@@ -182,15 +182,16 @@ class FDEContents_t
virtual const LSDA_t* getLSDA() const =0; virtual const LSDA_t* getLSDA() const =0;
virtual uint64_t getLSDAAddress() const =0; virtual uint64_t getLSDAAddress() const =0;
virtual uint64_t getStartAddressPosition() const = 0; virtual uint64_t getStartAddressPosition() const = 0;
virtual uint64_t getEndAddressPosition() const = 0; virtual uint64_t getEndAddressPosition() const = 0;
virtual uint64_t getEndAddressSize() const = 0; virtual uint64_t getEndAddressSize() const = 0;
virtual uint64_t getLSDAAddressPosition() const = 0; virtual uint64_t getLSDAAddressPosition() const = 0;
virtual uint64_t getLSDAAddressSize() const = 0; virtual uint64_t getLSDAAddressSize() const = 0;
virtual void print() const=0; // move to ostream? toString? virtual void print() const=0; // move to ostream? toString?
}; };
using EHPEndianness_t = enum EHPEndianness { HOST, BIG, LITTLE } ;
using FDEVector_t = vector<const FDEContents_t*>; using FDEVector_t = vector<const FDEContents_t*>;
using CIEVector_t = vector<const CIEContents_t*>; using CIEVector_t = vector<const CIEContents_t*>;
class EHFrameParser_t class EHFrameParser_t
...@@ -198,9 +199,9 @@ class EHFrameParser_t ...@@ -198,9 +199,9 @@ class EHFrameParser_t
protected: protected:
EHFrameParser_t() {} EHFrameParser_t() {}
EHFrameParser_t(const EHFrameParser_t&) {} EHFrameParser_t(const EHFrameParser_t&) {}
virtual bool parse(const bool is_be)=0;
public: public:
virtual ~EHFrameParser_t() {} virtual ~EHFrameParser_t() {}
virtual bool parse()=0;
virtual void print() const=0; virtual void print() const=0;
virtual const FDEVector_t* getFDEs() const =0; virtual const FDEVector_t* getFDEs() const =0;
virtual const CIEVector_t* getCIEs() const =0; virtual const CIEVector_t* getCIEs() const =0;
...@@ -209,8 +210,10 @@ class EHFrameParser_t ...@@ -209,8 +210,10 @@ class EHFrameParser_t
#if USE_ELFIO #if USE_ELFIO
static unique_ptr<const EHFrameParser_t> factory(const string filename); static unique_ptr<const EHFrameParser_t> factory(const string filename);
#endif #endif
static unique_ptr<const EHFrameParser_t> factory( static unique_ptr<const EHFrameParser_t> factory(
uint8_t ptrsize, uint8_t ptrsize,
EHPEndianness_t endian_style,
const string eh_frame_data, const uint64_t eh_frame_data_start_addr, const string eh_frame_data, const uint64_t eh_frame_data_start_addr,
const string eh_frame_hdr_data, const uint64_t eh_frame_hdr_data_start_addr, const string eh_frame_hdr_data, const uint64_t eh_frame_hdr_data_start_addr,
const string gcc_except_table_data, const uint64_t gcc_except_table_data_start_addr const string gcc_except_table_data, const uint64_t gcc_except_table_data_start_addr
......
This diff is collapsed.
...@@ -49,17 +49,20 @@ class eh_frame_util_t ...@@ -49,17 +49,20 @@ class eh_frame_util_t
{ {
public: public:
template <class T> template <class T>
static bool read_type(T &value, uint64_t &position, const uint8_t* const data, const uint64_t max); static bool read_type(T &value, uint64_t &position, const uint8_t* const data, const uint64_t max, const bool is_be);
template <class T> template <class T>
static bool read_type_with_encoding static bool read_type_with_encoding (
(const uint8_t encoding, T &value, const uint8_t encoding, T &value,
uint64_t &position, uint64_t &position,
const uint8_t* const data, const uint8_t* const data,
const uint64_t max, const uint64_t max,
const uint64_t section_start_addr ); const uint64_t section_start_addr,
const bool is_be
);
static bool read_string static bool read_string (
(string &s, string &s,
uint64_t &position, uint64_t &position,
const uint8_t* const data, const uint8_t* const data,
const uint64_t max); const uint64_t max);
...@@ -67,23 +70,28 @@ class eh_frame_util_t ...@@ -67,23 +70,28 @@ class eh_frame_util_t
// see https://en.wikipedia.org/wiki/LEB128 // see https://en.wikipedia.org/wiki/LEB128
static bool read_uleb128 static bool read_uleb128
( uint64_t &result, (
uint64_t &result,
uint64_t &position, uint64_t &position,
const uint8_t* const data, const uint8_t* const data,
const uint64_t max); const uint64_t max
);
// see https://en.wikipedia.org/wiki/LEB128 // see https://en.wikipedia.org/wiki/LEB128
static bool read_sleb128 ( static bool read_sleb128 (
int64_t &result, int64_t &result,
uint64_t &position, uint64_t &position,
const uint8_t* const data, const uint8_t* const data,
const uint64_t max); const uint64_t max
);
static bool read_length( static bool read_length(
uint64_t &act_length, uint64_t &act_length,
uint64_t &position, uint64_t &position,
const uint8_t* const data, const uint8_t* const data,
const uint64_t max); const uint64_t max,
const bool is_be
);
}; };
template <int ptrsize> template <int ptrsize>
...@@ -113,7 +121,9 @@ class eh_program_insn_t : public EHProgramInstruction_t ...@@ -113,7 +121,9 @@ class eh_program_insn_t : public EHProgramInstruction_t
uint8_t opcode, uint8_t opcode,
uint64_t &pos, uint64_t &pos,
const uint8_t* const data, const uint8_t* const data,
const uint64_t &max); const uint64_t &max,
const bool is_be
);
bool isNop() const ; bool isNop() const ;
bool isDefCFAOffset() const ; bool isDefCFAOffset() const ;
...@@ -144,7 +154,9 @@ class eh_program_t : public EHProgram_t ...@@ -144,7 +154,9 @@ class eh_program_t : public EHProgram_t
bool parse_program( bool parse_program(
const uint64_t& program_start_position, const uint64_t& program_start_position,
const uint8_t* const data, const uint8_t* const data,
const uint64_t &max_program_pos); const uint64_t &max_program_pos,
const bool is_be
);
virtual const EHProgramInstructionVector_t* getInstructions() const ; virtual const EHProgramInstructionVector_t* getInstructions() const ;
vector<eh_program_insn_t <ptrsize> >& getInstructionsInternal() ; vector<eh_program_insn_t <ptrsize> >& getInstructionsInternal() ;
const vector<eh_program_insn_t <ptrsize> >& getInstructionsInternal() const ; const vector<eh_program_insn_t <ptrsize> >& getInstructionsInternal() const ;
...@@ -163,19 +175,19 @@ class cie_contents_t : public CIEContents_t, private eh_frame_util_t<ptrsize> ...@@ -163,19 +175,19 @@ class cie_contents_t : public CIEContents_t, private eh_frame_util_t<ptrsize>
private: private:
uint64_t cie_position; uint64_t cie_position;
uint64_t length; uint64_t length;
uint8_t cie_id; uint8_t cie_id;
uint8_t cie_version; uint8_t cie_version;
string augmentation; string augmentation;
uint64_t code_alignment_factor; uint64_t code_alignment_factor;
int64_t data_alignment_factor; int64_t data_alignment_factor;
uint64_t return_address_register_column; uint64_t return_address_register_column;
uint64_t augmentation_data_length; uint64_t augmentation_data_length;
uint8_t personality_encoding; uint8_t personality_encoding;
uint64_t personality; uint64_t personality;
uint64_t personality_pointer_position; uint64_t personality_pointer_position;
uint64_t personality_pointer_size; uint64_t personality_pointer_size;
uint8_t lsda_encoding; uint8_t lsda_encoding;
uint8_t fde_encoding; uint8_t fde_encoding;
eh_program_t<ptrsize> eh_pgm; eh_program_t<ptrsize> eh_pgm;
public: public:
...@@ -186,8 +198,8 @@ class cie_contents_t : public CIEContents_t, private eh_frame_util_t<ptrsize> ...@@ -186,8 +198,8 @@ class cie_contents_t : public CIEContents_t, private eh_frame_util_t<ptrsize>
uint64_t getPosition() const { return cie_position; } uint64_t getPosition() const { return cie_position; }
uint64_t getLength() const { return length; } uint64_t getLength() const { return length; }
uint64_t getCAF() const ; uint64_t getCAF() const ;
int64_t getDAF() const ; int64_t getDAF() const ;
uint8_t getPersonalityEncoding() const { return personality_encoding; } uint8_t getPersonalityEncoding() const { return personality_encoding; }
uint64_t getPersonality() const ; uint64_t getPersonality() const ;
uint64_t getPersonalityPointerPosition() const { return personality_pointer_position; }; uint64_t getPersonalityPointerPosition() const { return personality_pointer_position; };
uint64_t getPersonalityPointerSize() const { return personality_pointer_size; }; uint64_t getPersonalityPointerSize() const { return personality_pointer_size; };
...@@ -201,7 +213,9 @@ class cie_contents_t : public CIEContents_t, private eh_frame_util_t<ptrsize> ...@@ -201,7 +213,9 @@ class cie_contents_t : public CIEContents_t, private eh_frame_util_t<ptrsize>
const uint64_t &cie_position, const uint64_t &cie_position,
const uint8_t* const data, const uint8_t* const data,
const uint64_t max, const uint64_t max,
const uint64_t eh_addr); const uint64_t eh_addr,
const bool is_be
);
void print(const uint64_t startAddr) const ; void print(const uint64_t startAddr) const ;
}; };
...@@ -215,7 +229,7 @@ class lsda_call_site_action_t : public LSDACallSiteAction_t, private eh_frame_ut ...@@ -215,7 +229,7 @@ class lsda_call_site_action_t : public LSDACallSiteAction_t, private eh_frame_ut
lsda_call_site_action_t() ; lsda_call_site_action_t() ;
int64_t getAction() const ; int64_t getAction() const ;
bool parse_lcsa(uint64_t &pos, const uint8_t* const data, const uint64_t max, bool &end); bool parse_lcsa(uint64_t &pos, const uint8_t* const data, const uint64_t max, bool &end, const bool is_be);
void print() const; void print() const;
}; };
...@@ -243,7 +257,8 @@ class lsda_type_table_entry_t: public LSDATypeTableEntry_t, private eh_frame_uti ...@@ -243,7 +257,8 @@ class lsda_type_table_entry_t: public LSDATypeTableEntry_t, private eh_frame_uti
const uint64_t index, const uint64_t index,
const uint8_t* const data, const uint8_t* const data,
const uint64_t max, const uint64_t max,
const uint64_t data_addr const uint64_t data_addr,
const bool is_be
); );
void print() const; void print() const;
...@@ -295,7 +310,9 @@ class lsda_call_site_t : public LSDACallSite_t, private eh_frame_util_t<ptrsize> ...@@ -295,7 +310,9 @@ class lsda_call_site_t : public LSDACallSite_t, private eh_frame_util_t<ptrsize>
const uint64_t max, /* call site table max */ const uint64_t max, /* call site table max */
const uint64_t data_addr, const uint64_t data_addr,
const uint64_t landing_pad_base_addr, const uint64_t landing_pad_base_addr,
const uint64_t gcc_except_table_max); const uint64_t gcc_except_table_max,
const bool is_be
);
void print() const; void print() const;
...@@ -345,7 +362,8 @@ class lsda_t : public LSDA_t, private eh_frame_util_t<ptrsize> ...@@ -345,7 +362,8 @@ class lsda_t : public LSDA_t, private eh_frame_util_t<ptrsize>
uint8_t getTTEncoding() const ; uint8_t getTTEncoding() const ;
bool parse_lsda(const uint64_t lsda_addr, bool parse_lsda(const uint64_t lsda_addr,
const ScoopReplacement_t* gcc_except_scoop_data, const ScoopReplacement_t* gcc_except_scoop_data,
const uint64_t fde_region_start const uint64_t fde_region_start,
const bool is_be
); );
void print() const; void print() const;
uint64_t getLandingPadBaseAddress() const { return landing_pad_base_addr; } uint64_t getLandingPadBaseAddress() const { return landing_pad_base_addr; }
...@@ -370,16 +388,16 @@ class fde_contents_t : public FDEContents_t, eh_frame_util_t<ptrsize> ...@@ -370,16 +388,16 @@ class fde_contents_t : public FDEContents_t, eh_frame_util_t<ptrsize>
uint64_t fde_position; uint64_t fde_position;
uint64_t cie_position; uint64_t cie_position;
uint64_t length; uint64_t length;
uint8_t id; uint8_t id;
uint64_t fde_start_addr; uint64_t fde_start_addr;
uint64_t fde_end_addr; uint64_t fde_end_addr;
uint64_t fde_range_len; uint64_t fde_range_len;
uint64_t lsda_addr; uint64_t lsda_addr;
uint64_t fde_start_addr_position; uint64_t fde_start_addr_position;
uint64_t fde_end_addr_position; uint64_t fde_end_addr_position;
uint64_t fde_end_addr_size; uint64_t fde_end_addr_size;
uint64_t fde_lsda_addr_position; uint64_t fde_lsda_addr_position;
uint64_t fde_lsda_addr_size; uint64_t fde_lsda_addr_size;
lsda_t<ptrsize> lsda; lsda_t<ptrsize> lsda;
eh_program_t<ptrsize> eh_pgm; eh_program_t<ptrsize> eh_pgm;
...@@ -409,10 +427,10 @@ class fde_contents_t : public FDEContents_t, eh_frame_util_t<ptrsize> ...@@ -409,10 +427,10 @@ class fde_contents_t : public FDEContents_t, eh_frame_util_t<ptrsize>
const LSDA_t* getLSDA() const { return &lsda; } // shared_ptr<LSDA_t>(new lsda_t<ptrsize>(lsda)) ; } const LSDA_t* getLSDA() const { return &lsda; } // shared_ptr<LSDA_t>(new lsda_t<ptrsize>(lsda)) ; }
const lsda_t<ptrsize>& getLSDAInternal() const { return lsda; } const lsda_t<ptrsize>& getLSDAInternal() const { return lsda; }
uint64_t getLSDAAddress() const { return lsda_addr; } uint64_t getLSDAAddress() const { return lsda_addr; }
uint64_t getStartAddressPosition() const { return fde_start_addr_position; } uint64_t getStartAddressPosition() const { return fde_start_addr_position; }
uint64_t getEndAddressPosition() const { return fde_end_addr_position; } uint64_t getEndAddressPosition() const { return fde_end_addr_position; }
uint64_t getEndAddressSize() const { return fde_end_addr_size; } uint64_t getEndAddressSize() const { return fde_end_addr_size; }
uint64_t getLSDAAddressPosition() const { return fde_lsda_addr_position; } uint64_t getLSDAAddressPosition() const { return fde_lsda_addr_position; }
uint64_t getLSDAAddressSize() const { return fde_lsda_addr_size; } uint64_t getLSDAAddressSize() const { return fde_lsda_addr_size; }
...@@ -422,7 +440,8 @@ class fde_contents_t : public FDEContents_t, eh_frame_util_t<ptrsize> ...@@ -422,7 +440,8 @@ class fde_contents_t : public FDEContents_t, eh_frame_util_t<ptrsize>
const uint8_t* const data, const uint8_t* const data,
const uint64_t max, const uint64_t max,
const uint64_t eh_addr, const uint64_t eh_addr,
const ScoopReplacement_t *gcc_except_scoop); const ScoopReplacement_t *gcc_except_scoop,
const bool is_be);
void print() const; void print() const;
...@@ -449,7 +468,7 @@ class split_eh_frame_impl_t : public EHFrameParser_t ...@@ -449,7 +468,7 @@ class split_eh_frame_impl_t : public EHFrameParser_t
mutable FDEVector_t fdes_cache; mutable FDEVector_t fdes_cache;
bool iterate_fdes(); bool iterate_fdes(const bool is_be);
public: public:
...@@ -466,7 +485,7 @@ class split_eh_frame_impl_t : public EHFrameParser_t ...@@ -466,7 +485,7 @@ class split_eh_frame_impl_t : public EHFrameParser_t
{ {
} }
bool parse(); bool parse(const bool is_be);
void print() const; void print() const;
virtual const FDEVector_t* getFDEs() const; virtual const FDEVector_t* getFDEs() const;
......