adds elfio test utility

This commit is contained in:
Eyck Jentzsch 2024-09-23 09:29:08 +02:00
parent a8f56b6e27
commit f6be8ec006
2 changed files with 42 additions and 0 deletions

View File

@ -262,3 +262,9 @@ if(TARGET scc-sysc)
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
) )
endif() endif()
project(elfio-test)
find_package(Boost COMPONENTS program_options thread REQUIRED)
add_executable(${PROJECT_NAME} src/elfio.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC elfio::elfio)

36
src/elfio.cpp Normal file
View File

@ -0,0 +1,36 @@
#ifdef _MSC_VER
#define _SCL_SECURE_NO_WARNINGS
#define ELFIO_NO_INTTYPES
#endif
#include <iostream>
#include <elfio/elfio_dump.hpp>
using namespace ELFIO;
int main( int argc, char** argv )
{
if ( argc != 2 ) {
printf( "Usage: elfdump <file_name>\n" );
return 1;
}
elfio reader;
if ( !reader.load( argv[1] ) ) {
printf( "File %s is not found or it is not an ELF file\n", argv[1] );
return 1;
}
dump::header( std::cout, reader );
dump::section_headers( std::cout, reader );
dump::segment_headers( std::cout, reader );
dump::symbol_tables( std::cout, reader );
dump::notes( std::cout, reader );
dump::modinfo( std::cout, reader );
dump::dynamic_tags( std::cout, reader );
dump::section_datas( std::cout, reader );
dump::segment_datas( std::cout, reader );
return 0;
}