165042b18Sopenharmony_ci/* 265042b18Sopenharmony_cielfdump.cpp - Dump ELF file using ELFIO library. 365042b18Sopenharmony_ci 465042b18Sopenharmony_ciCopyright (C) 2001-present by Serge Lamikhov-Center 565042b18Sopenharmony_ci 665042b18Sopenharmony_ciPermission is hereby granted, free of charge, to any person obtaining a copy 765042b18Sopenharmony_ciof this software and associated documentation files (the "Software"), to deal 865042b18Sopenharmony_ciin the Software without restriction, including without limitation the rights 965042b18Sopenharmony_cito use, copy, modify, merge, publish, distribute, sublicense, and/or sell 1065042b18Sopenharmony_cicopies of the Software, and to permit persons to whom the Software is 1165042b18Sopenharmony_cifurnished to do so, subject to the following conditions: 1265042b18Sopenharmony_ci 1365042b18Sopenharmony_ciThe above copyright notice and this permission notice shall be included in 1465042b18Sopenharmony_ciall copies or substantial portions of the Software. 1565042b18Sopenharmony_ci 1665042b18Sopenharmony_ciTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1765042b18Sopenharmony_ciIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1865042b18Sopenharmony_ciFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1965042b18Sopenharmony_ciAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2065042b18Sopenharmony_ciLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2165042b18Sopenharmony_ciOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 2265042b18Sopenharmony_ciTHE SOFTWARE. 2365042b18Sopenharmony_ci*/ 2465042b18Sopenharmony_ci 2565042b18Sopenharmony_ci#ifdef _MSC_VER 2665042b18Sopenharmony_ci#define _SCL_SECURE_NO_WARNINGS 2765042b18Sopenharmony_ci#define ELFIO_NO_INTTYPES 2865042b18Sopenharmony_ci#endif 2965042b18Sopenharmony_ci 3065042b18Sopenharmony_ci#include <iostream> 3165042b18Sopenharmony_ci#include <elfio/elfio_dump.hpp> 3265042b18Sopenharmony_ci 3365042b18Sopenharmony_ciusing namespace ELFIO; 3465042b18Sopenharmony_ci 3565042b18Sopenharmony_ciint main( int argc, char** argv ) 3665042b18Sopenharmony_ci{ 3765042b18Sopenharmony_ci if ( argc != 2 ) { 3865042b18Sopenharmony_ci printf( "Usage: elfdump <file_name>\n" ); 3965042b18Sopenharmony_ci return 1; 4065042b18Sopenharmony_ci } 4165042b18Sopenharmony_ci 4265042b18Sopenharmony_ci elfio reader; 4365042b18Sopenharmony_ci 4465042b18Sopenharmony_ci if ( !reader.load( argv[1] ) ) { 4565042b18Sopenharmony_ci printf( "File %s is not found or it is not an ELF file\n", argv[1] ); 4665042b18Sopenharmony_ci return 1; 4765042b18Sopenharmony_ci } 4865042b18Sopenharmony_ci 4965042b18Sopenharmony_ci dump::header( std::cout, reader ); 5065042b18Sopenharmony_ci dump::section_headers( std::cout, reader ); 5165042b18Sopenharmony_ci dump::segment_headers( std::cout, reader ); 5265042b18Sopenharmony_ci dump::symbol_tables( std::cout, reader ); 5365042b18Sopenharmony_ci dump::notes( std::cout, reader ); 5465042b18Sopenharmony_ci dump::modinfo( std::cout, reader ); 5565042b18Sopenharmony_ci dump::dynamic_tags( std::cout, reader ); 5665042b18Sopenharmony_ci dump::section_datas( std::cout, reader ); 5765042b18Sopenharmony_ci dump::segment_datas( std::cout, reader ); 5865042b18Sopenharmony_ci 5965042b18Sopenharmony_ci return 0; 6065042b18Sopenharmony_ci} 61