mirror of
https://github.com/serge1/ELFIO.git
synced 2025-01-30 06:32:43 +00:00
Better support for read-only ELF access
This commit is contained in:
parent
ced83b14be
commit
972f89e022
@ -852,6 +852,16 @@ class elfio
|
|||||||
return parent->sections_.end();
|
return parent->sections_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
std::vector<section*>::const_iterator begin() const {
|
||||||
|
return parent->sections_.cbegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
std::vector<section*>::const_iterator end() const {
|
||||||
|
return parent->sections_.cend();
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
elfio* parent;
|
elfio* parent;
|
||||||
@ -897,6 +907,16 @@ class elfio
|
|||||||
return parent->segments_.end();
|
return parent->segments_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
std::vector<segment*>::const_iterator begin() const {
|
||||||
|
return parent->segments_.cbegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
std::vector<segment*>::const_iterator end() const {
|
||||||
|
return parent->segments_.cend();
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
elfio* parent;
|
elfio* parent;
|
||||||
|
@ -26,13 +26,14 @@ THE SOFTWARE.
|
|||||||
namespace ELFIO {
|
namespace ELFIO {
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
class dynamic_section_accessor
|
template< class S >
|
||||||
|
class dynamic_section_accessor_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
dynamic_section_accessor( const elfio& elf_file_, section* section_ ) :
|
dynamic_section_accessor_template( const elfio& elf_file_, S* section_ ) :
|
||||||
elf_file( elf_file_ ),
|
elf_file( elf_file_ ),
|
||||||
dynamic_section( section_ )
|
dynamic_section( section_ )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,9 +246,12 @@ class dynamic_section_accessor
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
const elfio& elf_file;
|
const elfio& elf_file;
|
||||||
section* dynamic_section;
|
S* dynamic_section;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using dynamic_section_accessor = dynamic_section_accessor_template<section>;
|
||||||
|
using const_dynamic_section_accessor = dynamic_section_accessor_template<const section>;
|
||||||
|
|
||||||
} // namespace ELFIO
|
} // namespace ELFIO
|
||||||
|
|
||||||
#endif // ELFIO_DYNAMIC_HPP
|
#endif // ELFIO_DYNAMIC_HPP
|
||||||
|
@ -38,12 +38,13 @@ namespace ELFIO {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
class note_section_accessor
|
template< class S >
|
||||||
|
class note_section_accessor_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
note_section_accessor( const elfio& elf_file_, section* section_ ) :
|
note_section_accessor_template( const elfio& elf_file_, S* section_ ) :
|
||||||
elf_file( elf_file_ ), note_section( section_ )
|
elf_file( elf_file_ ), note_section( section_ )
|
||||||
{
|
{
|
||||||
process_section();
|
process_section();
|
||||||
}
|
}
|
||||||
@ -157,10 +158,13 @@ class note_section_accessor
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
const elfio& elf_file;
|
const elfio& elf_file;
|
||||||
section* note_section;
|
S* note_section;
|
||||||
std::vector<Elf_Xword> note_start_positions;
|
std::vector<Elf_Xword> note_start_positions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using note_section_accessor = note_section_accessor_template<section>;
|
||||||
|
using const_note_section_accessor = note_section_accessor_template<const section>;
|
||||||
|
|
||||||
} // namespace ELFIO
|
} // namespace ELFIO
|
||||||
|
|
||||||
#endif // ELFIO_NOTE_HPP
|
#endif // ELFIO_NOTE_HPP
|
||||||
|
@ -73,13 +73,14 @@ template<> struct get_sym_and_type< Elf64_Rela >
|
|||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
class relocation_section_accessor
|
template< class S >
|
||||||
|
class relocation_section_accessor_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
relocation_section_accessor( const elfio& elf_file_, section* section_ ) :
|
relocation_section_accessor_template( const elfio& elf_file_, S* section_ ) :
|
||||||
elf_file( elf_file_ ),
|
elf_file( elf_file_ ),
|
||||||
relocation_section( section_ )
|
relocation_section( section_ )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,9 +362,12 @@ class relocation_section_accessor
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
const elfio& elf_file;
|
const elfio& elf_file;
|
||||||
section* relocation_section;
|
S* relocation_section;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using relocation_section_accessor = relocation_section_accessor_template<section>;
|
||||||
|
using const_relocation_section_accessor = relocation_section_accessor_template<const section>;
|
||||||
|
|
||||||
} // namespace ELFIO
|
} // namespace ELFIO
|
||||||
|
|
||||||
#endif // ELFIO_RELOCATION_HPP
|
#endif // ELFIO_RELOCATION_HPP
|
||||||
|
@ -30,12 +30,13 @@ THE SOFTWARE.
|
|||||||
namespace ELFIO {
|
namespace ELFIO {
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
class string_section_accessor
|
template< class S >
|
||||||
|
class string_section_accessor_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
string_section_accessor( section* section_ ) :
|
string_section_accessor_template( S* section_ ) :
|
||||||
string_section( section_ )
|
string_section( section_ )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,9 +89,12 @@ class string_section_accessor
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
section* string_section;
|
S* string_section;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using string_section_accessor = string_section_accessor_template<section>;
|
||||||
|
using const_string_section_accessor = string_section_accessor_template<const section>;
|
||||||
|
|
||||||
} // namespace ELFIO
|
} // namespace ELFIO
|
||||||
|
|
||||||
#endif // ELFIO_STRINGS_HPP
|
#endif // ELFIO_STRINGS_HPP
|
||||||
|
@ -26,13 +26,14 @@ THE SOFTWARE.
|
|||||||
namespace ELFIO {
|
namespace ELFIO {
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
class symbol_section_accessor
|
template< class S >
|
||||||
|
class symbol_section_accessor_template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
symbol_section_accessor( const elfio& elf_file_, section* symbol_section_ ) :
|
symbol_section_accessor_template( const elfio& elf_file_, S* symbol_section_ ) :
|
||||||
elf_file( elf_file_ ),
|
elf_file( elf_file_ ),
|
||||||
symbol_section( symbol_section_ )
|
symbol_section( symbol_section_ )
|
||||||
{
|
{
|
||||||
find_hash_section();
|
find_hash_section();
|
||||||
}
|
}
|
||||||
@ -268,11 +269,14 @@ class symbol_section_accessor
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
const elfio& elf_file;
|
const elfio& elf_file;
|
||||||
section* symbol_section;
|
S* symbol_section;
|
||||||
Elf_Half hash_section_index;
|
Elf_Half hash_section_index;
|
||||||
const section* hash_section;
|
const section* hash_section;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using symbol_section_accessor = symbol_section_accessor_template<section>;
|
||||||
|
using const_symbol_section_accessor = symbol_section_accessor_template<const section>;
|
||||||
|
|
||||||
} // namespace ELFIO
|
} // namespace ELFIO
|
||||||
|
|
||||||
#endif // ELFIO_SYMBOLS_HPP
|
#endif // ELFIO_SYMBOLS_HPP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user