-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy patheh-frame-hdr.cpp
47 lines (44 loc) · 1.22 KB
/
eh-frame-hdr.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <boost/optional.hpp>
#include <fileno.hpp>
#include <dwarfpp/lib.hpp>
#include <dwarfpp/expr.hpp>
#include <dwarfpp/frame.hpp>
#include <dwarfpp/regs.hpp>
#include <gelf.h>
using std::cout;
using std::cerr;
using std::endl;
using std::ostringstream;
using std::map;
using namespace dwarf;
using dwarf::lib::Dwarf_Addr;
using dwarf::core::FrameSection;
using boost::optional;
int main(int argc, char **argv)
{
cout << "Opening " << argv[1] << "..." << endl;
std::ifstream in(argv[1]);
core::root_die root(fileno(in));
auto& fs = root.get_frame_section();
cout << "Binary search table in .eh_frame_hdr has "
<< fs.hdr_tbl_nbytes
<< " bytes of content, encoding 0x"
<< std::hex << fs.hdr_tbl_encoding << std::endl;
cout << "The table contains:" << endl;
for (auto i_pair = fs.hdr_tbl_begin();
i_pair != fs.hdr_tbl_end();
++i_pair)
{
cout << "location: " << std::hex << "0x" << i_pair->first
<< " (raw: " << i_pair.dereference_raw().first << ")"
<< ", FDE address in PT_GNU_EH_FRAME segment: 0x" << i_pair->second
<< " (vaddr: 0x" << (i_pair->second + fs.hdr_vaddr) << ")" << endl;
}
return 0;
}