13 Parser::Parser(std::string filename
) : filename(filename
) {
14 std::cout
<< "ELF::Parser::Parser(): filename is \"" << filename
<< "\"\n";
15 file_fd
= open(filename
.c_str(), O_RDONLY
);
17 header
= new Header(file_fd
);
19 lseek(file_fd
, header
->get_section_header_offset(), SEEK_SET
);
21 for(std::size_t x
= 0; x
< header
->get_num_sections(); x
++) {
22 section_list
.push_back(new Section(file_fd
));
25 /* Remove the first section, since, according to the standard, it is "reserved and should be all zeros" */
26 /*section_list.erase(section_list.begin());*/
28 string_table
= section_list
[header
->get_string_table_index()];
30 string_table
->read_content();
32 for(section_list_t::iterator i
= section_list
.begin(); i
!= section_list
.end(); i
++) {
33 Byte
*p
= string_table
->get_content()->get_data();
34 p
+= (*i
)->get_name_offset();
36 /*std::cout << "Section, name is \"" << (char *)p << "\'\n";*/
38 (*i
)->set_name((char *)p
);
41 symbol_parser
= new SymbolParser(this);
48 Misc::SmartPointer
<Section
> Parser::get_section(std::string name
) const {
49 for(section_list_t::const_iterator i
= section_list
.begin(); i
!= section_list
.end(); i
++) {
50 if((*i
)->get_name() == name
) return *i
;
55 Misc::SmartPointer
<Symbol
> Parser::get_symbol(std::string name
) const {
56 return symbol_parser
->get_symbol(name
);
60 } // namespace Monitor
61 } // namespace Aesalon