Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • third-party-mirrors/ELFIO
1 result
Show changes
Showing
with 2379 additions and 1364 deletions
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center
Copyright (C) 2001-present by Serge Lamikhov-Center
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -30,67 +30,68 @@ THE SOFTWARE.
namespace ELFIO {
//------------------------------------------------------------------------------
class string_section_accessor
template <class S> class string_section_accessor_template
{
public:
//------------------------------------------------------------------------------
string_section_accessor( section* section_ ) :
string_section( section_ )
//------------------------------------------------------------------------------
explicit string_section_accessor_template( S* section )
: string_section( section )
{
}
//------------------------------------------------------------------------------
const char*
get_string( Elf_Word index ) const
//------------------------------------------------------------------------------
const char* get_string( Elf_Word index ) const
{
if ( string_section ) {
if ( index < string_section->get_size() ) {
const char* data = string_section->get_data();
if ( 0 != data ) {
const char* data = string_section->get_data();
if ( index < string_section->get_size() && nullptr != data ) {
size_t string_length =
strnlen( data + index, string_section->get_size() - index );
if ( string_length < ( string_section->get_size() - index ) )
return data + index;
}
}
}
return 0;
return nullptr;
}
//------------------------------------------------------------------------------
Elf_Word
add_string( const char* str )
//------------------------------------------------------------------------------
Elf_Word add_string( const char* str )
{
Elf_Word current_position = 0;
if (string_section) {
if ( string_section ) {
// Strings are addeded to the end of the current section data
current_position = (Elf_Word)string_section->get_size();
current_position =
static_cast<Elf_Word>( string_section->get_size() );
if ( current_position == 0 ) {
char empty_string = '\0';
string_section->append_data( &empty_string, 1 );
current_position++;
}
string_section->append_data( str, (Elf_Word)std::strlen( str ) + 1 );
string_section->append_data(
str, static_cast<Elf_Word>( std::strlen( str ) + 1 ) );
}
return current_position;
}
//------------------------------------------------------------------------------
Elf_Word
add_string( const std::string& str )
//------------------------------------------------------------------------------
Elf_Word add_string( const std::string& str )
{
return add_string( str.c_str() );
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
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
#endif // ELFIO_STRINGS_HPP
This diff is collapsed.
This diff is collapsed.
#define ELFIO_VERSION "3.12"
This diff is collapsed.
add_subdirectory(add_section)
add_subdirectory(anonymizer)
add_subdirectory(elfdump)
add_subdirectory(proc_mem)
add_subdirectory(tutorial)
add_subdirectory(write_obj)
add_subdirectory(writer)
#add_subdirectory(c_wrapper)
\ No newline at end of file
SUBDIRS = elfdump tutorial writer write_obj
This diff is collapsed.
This diff is collapsed.
add_executable(add_section add_section.cpp)
target_link_libraries(add_section PRIVATE elfio::elfio)
This diff is collapsed.
add_executable(anonymizer anonymizer.cpp)
target_link_libraries(anonymizer PRIVATE elfio::elfio)
This diff is collapsed.
add_executable(c_example c_example.c elfio_c_wrapper.cpp elfio_c_wrapper.h)
target_link_libraries(c_example PRIVATE elfio::elfio)
This diff is collapsed.
This diff is collapsed.