├── lib ├── gtest-1.6.0 │ ├── CMakeFiles │ │ ├── progress.marks │ │ ├── gtest.dir │ │ │ ├── progress.make │ │ │ ├── cmake_clean_target.cmake │ │ │ ├── depend.make │ │ │ ├── link.txt │ │ │ ├── cmake_clean.cmake │ │ │ ├── flags.make │ │ │ └── DependInfo.cmake │ │ ├── gtest_main.dir │ │ │ ├── progress.make │ │ │ ├── cmake_clean_target.cmake │ │ │ ├── depend.make │ │ │ ├── link.txt │ │ │ ├── cmake_clean.cmake │ │ │ ├── flags.make │ │ │ └── DependInfo.cmake │ │ └── CMakeDirectoryInformation.cmake │ ├── xcode │ │ ├── Config │ │ │ ├── TestTarget.xcconfig │ │ │ ├── FrameworkTarget.xcconfig │ │ │ ├── StaticLibraryTarget.xcconfig │ │ │ ├── DebugProject.xcconfig │ │ │ ├── ReleaseProject.xcconfig │ │ │ └── General.xcconfig │ │ ├── Samples │ │ │ └── FrameworkSample │ │ │ │ ├── Info.plist │ │ │ │ ├── widget.h │ │ │ │ ├── widget.cc │ │ │ │ ├── runtests.sh │ │ │ │ └── widget_test.cc │ │ ├── Resources │ │ │ └── Info.plist │ │ └── Scripts │ │ │ └── runtests.sh │ ├── m4 │ │ ├── ltversion.m4 │ │ └── gtest.m4 │ ├── cmake_install.cmake │ ├── CONTRIBUTORS │ ├── COPYING │ ├── test │ │ ├── production.cc │ │ ├── gtest_main_unittest.cc │ │ ├── gtest_uninitialized_test_.cc │ │ ├── gtest_xml_outfile1_test_.cc │ │ ├── gtest_xml_outfile2_test_.cc │ │ ├── gtest-typed-test2_test.cc │ │ ├── gtest_help_test_.cc │ │ ├── production.h │ │ ├── gtest_all_test.cc │ │ ├── gtest_prod_test.cc │ │ ├── gtest_sole_header_test.cc │ │ ├── gtest-param-test_test.h │ │ ├── gtest_no_test_unittest.cc │ │ ├── gtest-typed-test_test.h │ │ ├── gtest_throw_on_failure_test_.cc │ │ ├── gtest_uninitialized_test.py │ │ ├── gtest_list_tests_unittest_.cc │ │ ├── gtest-param-test2_test.cc │ │ └── gtest_color_test_.cc │ ├── src │ │ ├── gtest_main.cc │ │ └── gtest-all.cc │ ├── fused-src │ │ └── gtest │ │ │ └── gtest_main.cc │ ├── codegear │ │ ├── gtest_all.cc │ │ ├── gtest_link.cc │ │ └── gtest.groupproj │ ├── scripts │ │ └── test │ │ │ └── Makefile │ ├── samples │ │ ├── sample4_unittest.cc │ │ ├── sample1.h │ │ ├── sample4.cc │ │ ├── sample4.h │ │ ├── sample2.cc │ │ ├── sample1.cc │ │ └── sample2.h │ ├── build-aux │ │ └── config.h.in │ ├── msvc │ │ ├── gtest.sln │ │ └── gtest-md.sln │ ├── include │ │ └── gtest │ │ │ └── gtest_prod.h │ ├── configure.ac │ └── make │ │ └── Makefile └── hash-lib │ ├── md5.hpp │ ├── sha1.hpp │ └── sha256.hpp ├── src ├── ui │ ├── assets │ │ ├── bug.png │ │ ├── new.png │ │ ├── close.png │ │ ├── edit.png │ │ ├── goto.png │ │ ├── help.png │ │ ├── open.png │ │ ├── reset.png │ │ ├── show.png │ │ └── rpasser.png │ ├── inttablewidget.hpp │ ├── inttablewidget.cpp │ ├── QHexView-ng.hpp │ └── mainwindow.hpp ├── tests │ ├── test_files │ │ ├── bf │ │ ├── true │ │ ├── 32_arm_ls │ │ ├── 32_intel_ls │ │ ├── 64_intel_ls │ │ └── 32_mips_be_ping │ └── tiny_tests.cpp ├── structures │ ├── error.hpp │ ├── noteformat.hpp │ ├── capabilities.hpp │ ├── relocation.hpp │ ├── symtable_entry.hpp │ ├── programheader.hpp │ ├── dynamicstruct.hpp │ ├── sectionheader.hpp │ └── elfheader.hpp ├── version.hpp ├── datastructures │ ├── search_value.hpp │ ├── search_node.cpp │ ├── search_node.hpp │ └── search_tree.hpp ├── segment_types │ ├── segment_type.cpp │ ├── interp_segment.cpp │ ├── debuglink_segment.cpp │ ├── comment_segment.cpp │ ├── interp_segment.hpp │ ├── debuglink_segment.hpp │ ├── comment_segment.hpp │ ├── readonly_segment.hpp │ ├── strtable_segment.hpp │ ├── note_segment.hpp │ ├── readonly_segment.cpp │ ├── strtable_segment.cpp │ └── segment_type.hpp ├── initarray.hpp ├── abstract_dynamic.hpp ├── segment.cpp ├── abstract_symbol.hpp ├── endian.hpp ├── segment.hpp ├── initarray.cpp ├── symbols.hpp ├── abstract_programheader.hpp ├── programheaders.hpp ├── dynamicsection.hpp ├── abstract_sectionheader.hpp ├── programheaders.cpp └── sectionheaders.hpp ├── assets ├── gui-win-main.png ├── gui-win-segments.png └── gui-win-capabilities.png ├── .gitignore ├── LICENSE └── README.md /lib/gtest-1.6.0/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /src/ui/assets/bug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/bug.png -------------------------------------------------------------------------------- /src/ui/assets/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/new.png -------------------------------------------------------------------------------- /assets/gui-win-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/assets/gui-win-main.png -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest.dir/progress.make: -------------------------------------------------------------------------------- 1 | CMAKE_PROGRESS_1 = 57 2 | CMAKE_PROGRESS_2 = 58 3 | 4 | -------------------------------------------------------------------------------- /src/tests/test_files/bf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/tests/test_files/bf -------------------------------------------------------------------------------- /src/ui/assets/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/close.png -------------------------------------------------------------------------------- /src/ui/assets/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/edit.png -------------------------------------------------------------------------------- /src/ui/assets/goto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/goto.png -------------------------------------------------------------------------------- /src/ui/assets/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/help.png -------------------------------------------------------------------------------- /src/ui/assets/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/open.png -------------------------------------------------------------------------------- /src/ui/assets/reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/reset.png -------------------------------------------------------------------------------- /src/ui/assets/show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/show.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | realeses 3 | .cache 4 | .vscode 5 | *.user* 6 | .gitignore 7 | .* 8 | *elfparser* 9 | System* -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest.dir/cmake_clean_target.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "libgtest.a" 3 | ) 4 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest_main.dir/progress.make: -------------------------------------------------------------------------------- 1 | CMAKE_PROGRESS_1 = 59 2 | CMAKE_PROGRESS_2 = 60 3 | 4 | -------------------------------------------------------------------------------- /src/tests/test_files/true: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/tests/test_files/true -------------------------------------------------------------------------------- /src/ui/assets/rpasser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/ui/assets/rpasser.png -------------------------------------------------------------------------------- /assets/gui-win-segments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/assets/gui-win-segments.png -------------------------------------------------------------------------------- /assets/gui-win-capabilities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/assets/gui-win-capabilities.png -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest_main.dir/cmake_clean_target.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "libgtest_main.a" 3 | ) 4 | -------------------------------------------------------------------------------- /src/tests/test_files/32_arm_ls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/tests/test_files/32_arm_ls -------------------------------------------------------------------------------- /src/tests/test_files/32_intel_ls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/tests/test_files/32_intel_ls -------------------------------------------------------------------------------- /src/tests/test_files/64_intel_ls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/tests/test_files/64_intel_ls -------------------------------------------------------------------------------- /src/tests/test_files/32_mips_be_ping: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mentebinaria/elfparser-ng/HEAD/src/tests/test_files/32_mips_be_ping -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest.dir/depend.make: -------------------------------------------------------------------------------- 1 | # Empty dependencies file for gtest. 2 | # This may be replaced when dependencies are built. 3 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest.dir/link.txt: -------------------------------------------------------------------------------- 1 | /usr/bin/ar qc libgtest.a CMakeFiles/gtest.dir/src/gtest-all.cc.o 2 | /usr/bin/ranlib libgtest.a 3 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest_main.dir/depend.make: -------------------------------------------------------------------------------- 1 | # Empty dependencies file for gtest_main. 2 | # This may be replaced when dependencies are built. 3 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest_main.dir/link.txt: -------------------------------------------------------------------------------- 1 | /usr/bin/ar qc libgtest_main.a CMakeFiles/gtest_main.dir/src/gtest_main.cc.o 2 | /usr/bin/ranlib libgtest_main.a 3 | -------------------------------------------------------------------------------- /src/structures/error.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum file 4 | { 5 | ERROR_OPEN = -1, 6 | SUCESS_OPEN, 7 | 8 | ERROR_READ, 9 | SUCESS_READ, 10 | 11 | ERROR_WRITE, 12 | SUCESS_WRITE 13 | }; 14 | 15 | enum exit 16 | { 17 | EMPTY = -1, 18 | FULL, 19 | }; -------------------------------------------------------------------------------- /src/version.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SC_VERSION_HPP 2 | #define SC_VERSION_HPP 3 | 4 | std::string version_elf_parser() 5 | { 6 | return std::string("Version: elfparser-ng 1.6.0 \n Copyright: elfparser-ng (c) 2022 Mente Binária\n elfparser (c) 2014-2022 Jacob Baines"); 7 | } 8 | 9 | #endif // !SC_VERSION_HPP -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Config/TestTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // TestTarget.xcconfig 3 | // 4 | // These are Test target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | 7 | PRODUCT_NAME = $(TARGET_NAME) 8 | HEADER_SEARCH_PATHS = ../include 9 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/gtest.dir/src/gtest-all.cc.o" 3 | "libgtest.pdb" 4 | "libgtest.a" 5 | ) 6 | 7 | # Per-language clean rules from dependency scanning. 8 | foreach(lang CXX) 9 | include(CMakeFiles/gtest.dir/cmake_clean_${lang}.cmake OPTIONAL) 10 | endforeach() 11 | -------------------------------------------------------------------------------- /src/structures/noteformat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NOTE_FORMAT_HPP 2 | #define NOTE_FORMAT_HPP 3 | 4 | namespace elf 5 | { 6 | #pragma pack(push, 1) 7 | struct note 8 | { 9 | boost::uint32_t m_nameSize; 10 | boost::uint32_t m_descSize; 11 | boost::uint32_t m_type; 12 | }; 13 | #pragma pack(pop) 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest_main.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/gtest_main.dir/src/gtest_main.cc.o" 3 | "libgtest_main.pdb" 4 | "libgtest_main.a" 5 | ) 6 | 7 | # Per-language clean rules from dependency scanning. 8 | foreach(lang CXX) 9 | include(CMakeFiles/gtest_main.dir/cmake_clean_${lang}.cmake OPTIONAL) 10 | endforeach() 11 | -------------------------------------------------------------------------------- /src/ui/inttablewidget.hpp: -------------------------------------------------------------------------------- 1 | #ifdef QT_GUI 2 | #ifndef INTENTRY_HPP 3 | #define INTENTRY_HPP 4 | 5 | #include 6 | #include 7 | 8 | class IntWidgetItem : public QTableWidgetItem 9 | { 10 | private: 11 | //! the underlying value in int format 12 | boost::uint64_t m_value; 13 | 14 | public: 15 | IntWidgetItem(boost::uint64_t p_value, bool p_hex = false); 16 | ~IntWidgetItem(); 17 | bool operator <(const QTableWidgetItem &other) const; 18 | 19 | }; 20 | 21 | #endif //! INTENTRY_HPP 22 | #endif //! QT_GUI 23 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.13 3 | 4 | # compile CXX with /usr/bin/c++ 5 | CXX_FLAGS = -O2 -s -std=c++0x -Wall -Wextra -Wno-deprecated-declarations -O2 -s -std=c++0x -Wall -Wextra -Wno-deprecated-declarations -Wall -Wshadow -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra 6 | 7 | CXX_DEFINES = -DUNIT_TESTS 8 | 9 | CXX_INCLUDES = -I/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0/include -I/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0 -isystem /home/mob/Documents/C-C/elfparser/lib/hash-lib 10 | 11 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest_main.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.13 3 | 4 | # compile CXX with /usr/bin/c++ 5 | CXX_FLAGS = -O2 -s -std=c++0x -Wall -Wextra -Wno-deprecated-declarations -O2 -s -std=c++0x -Wall -Wextra -Wno-deprecated-declarations -Wall -Wshadow -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra 6 | 7 | CXX_DEFINES = -DUNIT_TESTS 8 | 9 | CXX_INCLUDES = -I/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0/include -I/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0 -isystem /home/mob/Documents/C-C/elfparser/lib/hash-lib 10 | 11 | -------------------------------------------------------------------------------- /src/datastructures/search_value.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SEARCH_VALUE_HPP 2 | #define SEARCH_VALUE_HPP 3 | 4 | #include 5 | 6 | #include "../structures/capabilities.hpp" 7 | 8 | class SearchValue 9 | { 10 | public: 11 | 12 | SearchValue(const std::string& p_search, elf::Capabilties p_capabilities, 13 | const std::string& p_info) : 14 | m_search(p_search), 15 | m_type(p_capabilities), 16 | m_info(p_info) 17 | { 18 | } 19 | 20 | ~SearchValue() 21 | { 22 | } 23 | 24 | public: 25 | std::string m_search; 26 | elf::Capabilties m_type; 27 | std::string m_info; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Config/FrameworkTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // FrameworkTarget.xcconfig 3 | // 4 | // These are Framework target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Dynamic libs need to be position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Dynamic libs should not have their external symbols stripped. 14 | STRIP_STYLE = non-global 15 | 16 | // Let the user install by specifying the $DSTROOT with xcodebuild 17 | SKIP_INSTALL = NO 18 | -------------------------------------------------------------------------------- /src/segment_types/segment_type.cpp: -------------------------------------------------------------------------------- 1 | #include "segment_type.hpp" 2 | 3 | SegmentType::SegmentType (const char*, boost::uint32_t p_offset, 4 | boost::uint32_t p_size, elf::section_type p_type) : 5 | m_type(p_type), 6 | m_offset(p_offset), 7 | m_size(p_size), 8 | m_strings(NULL) 9 | { 10 | } 11 | 12 | SegmentType::~SegmentType() 13 | { 14 | } 15 | 16 | elf::section_type SegmentType::getType() const 17 | { 18 | return m_type; 19 | } 20 | 21 | boost::uint32_t SegmentType::getOffset() const 22 | { 23 | return m_offset; 24 | } 25 | 26 | void SegmentType::setStrSegment(SegmentType* p_strSegment) 27 | { 28 | m_strings = p_strSegment; 29 | } 30 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Config/StaticLibraryTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // StaticLibraryTarget.xcconfig 3 | // 4 | // These are static library target settings for libgtest.a. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Static libs can be included in bundles so make them position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Static libs should not have their internal globals or external symbols 14 | // stripped. 15 | STRIP_STYLE = debugging 16 | 17 | // Let the user install by specifying the $DSTROOT with xcodebuild 18 | SKIP_INSTALL = NO 19 | -------------------------------------------------------------------------------- /src/structures/capabilities.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAPABILITIES_HPP 2 | #define CAPABILITIES_HPP 3 | 4 | namespace elf 5 | { 6 | enum Capabilties 7 | { 8 | k_fileFunctions = 0, 9 | k_networkFunctions, 10 | k_processManipulation, 11 | k_pipeFunctions, 12 | k_crypto, 13 | k_infoGathering, 14 | k_envVariables, 15 | k_permissions, 16 | k_syslog, 17 | k_packetSniff, 18 | k_shell, 19 | k_packed, 20 | k_irc, 21 | k_http, 22 | k_compression, 23 | k_ipAddress, 24 | k_url, 25 | k_hooking, 26 | k_antidebug, 27 | k_dropper, 28 | k_filePath 29 | }; 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/CMakeDirectoryInformation.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.13 3 | 4 | # Relative path conversion top directories. 5 | set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/mob/Documents/C-C/elfparser") 6 | set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/mob/Documents/C-C/elfparser") 7 | 8 | # Force unix paths in dependencies. 9 | set(CMAKE_FORCE_UNIX_PATHS 1) 10 | 11 | 12 | # The C and CXX include file regular expressions for this directory. 13 | set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") 14 | set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") 15 | set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) 16 | set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ELF Parser 2 | elfparser-ng (c) 2022 Mente Binária // elfparser (c) 2014-2022 Jacob Baines 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | -------------------------------------------------------------------------------- /src/segment_types/interp_segment.cpp: -------------------------------------------------------------------------------- 1 | #include "interp_segment.hpp" 2 | 3 | #include 4 | 5 | InterpSegment::InterpSegment(const char* start, boost::uint32_t p_offset, 6 | boost::uint32_t p_size, 7 | elf::section_type p_type) : 8 | SegmentType(start, p_offset, p_size, p_type), 9 | m_interpreter(start + p_offset) 10 | { 11 | } 12 | 13 | InterpSegment::~InterpSegment() 14 | { 15 | } 16 | 17 | std::string InterpSegment::printToStdOut() const 18 | { 19 | std::stringstream return_value; 20 | return_value << "Interpreter (offset= 0x" << std::hex << m_offset 21 | << ", size= " << std::dec << m_size << ")\n" << " Value= " << m_interpreter << std::endl; 22 | 23 | return return_value.str(); 24 | } 25 | -------------------------------------------------------------------------------- /src/segment_types/debuglink_segment.cpp: -------------------------------------------------------------------------------- 1 | #include "debuglink_segment.hpp" 2 | 3 | #include 4 | 5 | DebugLinkSegment::DebugLinkSegment(const char* start, boost::uint32_t p_offset, 6 | boost::uint32_t p_size, 7 | elf::section_type p_type) : 8 | SegmentType(start, p_offset, p_size, p_type), 9 | m_file(start + p_offset) 10 | { 11 | } 12 | 13 | DebugLinkSegment::~DebugLinkSegment() 14 | { 15 | } 16 | 17 | std::string DebugLinkSegment::printToStdOut() const 18 | { 19 | std::stringstream return_value; 20 | return_value << "Debug Link Segment (offset= 0x" << std::hex << m_offset 21 | << ", size= " << std::dec << m_size << ")\n" 22 | << " File= " << m_file << std::endl; 23 | return return_value.str(); 24 | } 25 | -------------------------------------------------------------------------------- /src/segment_types/comment_segment.cpp: -------------------------------------------------------------------------------- 1 | #include "comment_segment.hpp" 2 | 3 | CommentSegment::CommentSegment(const char *start, boost::uint32_t p_offset, 4 | boost::uint32_t p_size, elf::section_type p_type) : SegmentType(start, p_offset, p_size, p_type), 5 | m_comment(start + p_offset) 6 | { 7 | } 8 | 9 | CommentSegment::~CommentSegment() 10 | { 11 | } 12 | 13 | std::string CommentSegment::printToStdOut() const 14 | { 15 | std::stringstream return_value; 16 | return_value << "Comment Segment (offset=0x" << std::hex << m_offset 17 | << ", size=" << std::dec << m_size << ")\n" 18 | << " String= " << m_comment << std::endl; 19 | return return_value.str(); 20 | } 21 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3017 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3017]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6b' 20 | macro_revision='1.3017' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /src/initarray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INIT_ARRAY_HPP 2 | #define INIT_ARRAY_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class InitArray 9 | { 10 | public: 11 | explicit InitArray(const std::string& p_name); 12 | ~InitArray(); 13 | 14 | void set(const char* p_data, boost::uint32_t p_size, boost::uint32_t p_offset, 15 | boost::uint32_t p_entries, bool p_is64, bool p_isLE); 16 | 17 | boost::uint32_t getOffset() const; 18 | 19 | std::vector >& getEntries(); 20 | 21 | std::string printToStd() const; 22 | 23 | private: 24 | 25 | std::string m_name; 26 | boost::uint32_t m_offset; 27 | std::vector > m_entries; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | "CXX" 4 | ) 5 | # The set of files for implicit dependencies of each language: 6 | set(CMAKE_DEPENDS_CHECK_CXX 7 | "/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0/src/gtest-all.cc" "/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0/CMakeFiles/gtest.dir/src/gtest-all.cc.o" 8 | ) 9 | set(CMAKE_CXX_COMPILER_ID "GNU") 10 | 11 | # Preprocessor definitions for this target. 12 | set(CMAKE_TARGET_DEFINITIONS_CXX 13 | "UNIT_TESTS" 14 | ) 15 | 16 | # The include file search paths: 17 | set(CMAKE_CXX_TARGET_INCLUDE_PATH 18 | "lib/gtest-1.6.0/include" 19 | "lib/gtest-1.6.0" 20 | "lib/hash-lib" 21 | ) 22 | 23 | # Targets to which this target links. 24 | set(CMAKE_TARGET_LINKED_INFO_FILES 25 | ) 26 | 27 | # Fortran module output directory. 28 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 29 | -------------------------------------------------------------------------------- /src/ui/inttablewidget.cpp: -------------------------------------------------------------------------------- 1 | #ifdef QT_GUI 2 | #include "inttablewidget.hpp" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | IntWidgetItem::IntWidgetItem(boost::uint64_t p_value, bool p_hex) : 9 | QTableWidgetItem(), 10 | m_value(p_value) 11 | { 12 | if (!p_hex) 13 | { 14 | QString intValue(boost::lexical_cast(m_value).c_str()); 15 | setText(intValue); 16 | } 17 | else 18 | { 19 | std::stringstream value; 20 | value << "0x" << std::hex << p_value; 21 | QString intValue(value.str().c_str()); 22 | setText(intValue); 23 | } 24 | } 25 | 26 | IntWidgetItem::~IntWidgetItem() 27 | { 28 | } 29 | 30 | bool IntWidgetItem::operator <(const QTableWidgetItem& other) const 31 | { 32 | const IntWidgetItem& otherCasted = dynamic_cast(other); 33 | return m_value < otherCasted.m_value; 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Samples/FrameworkSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.gtest.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | CSResourcesFileMapped 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CMakeFiles/gtest_main.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | "CXX" 4 | ) 5 | # The set of files for implicit dependencies of each language: 6 | set(CMAKE_DEPENDS_CHECK_CXX 7 | "/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0/src/gtest_main.cc" "/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o" 8 | ) 9 | set(CMAKE_CXX_COMPILER_ID "GNU") 10 | 11 | # Preprocessor definitions for this target. 12 | set(CMAKE_TARGET_DEFINITIONS_CXX 13 | "UNIT_TESTS" 14 | ) 15 | 16 | # The include file search paths: 17 | set(CMAKE_CXX_TARGET_INCLUDE_PATH 18 | "lib/gtest-1.6.0/include" 19 | "lib/gtest-1.6.0" 20 | "lib/hash-lib" 21 | ) 22 | 23 | # Targets to which this target links. 24 | set(CMAKE_TARGET_LINKED_INFO_FILES 25 | "/home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0/CMakeFiles/gtest.dir/DependInfo.cmake" 26 | ) 27 | 28 | # Fortran module output directory. 29 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 30 | -------------------------------------------------------------------------------- /src/datastructures/search_node.cpp: -------------------------------------------------------------------------------- 1 | #include "search_node.hpp" 2 | 3 | #include 4 | 5 | SearchNode::SearchNode() : 6 | m_storedData(), 7 | m_next(), 8 | m_failureNode(NULL) 9 | { 10 | } 11 | 12 | SearchNode::~SearchNode() 13 | { 14 | } 15 | 16 | SearchNode* SearchNode::getNext(const unsigned char p_value) const 17 | { 18 | return m_next[p_value]; 19 | } 20 | 21 | void SearchNode::setNext(const unsigned char p_value, SearchNode* p_node) 22 | { 23 | m_next[p_value] = p_node; 24 | } 25 | 26 | const std::set& SearchNode::getStoredData() const 27 | { 28 | return m_storedData; 29 | } 30 | 31 | void SearchNode::addReturnValues(const std::set& p_dataSet) 32 | { 33 | m_storedData.insert(p_dataSet.begin(), p_dataSet.end()); 34 | } 35 | 36 | void SearchNode::addReturnValue(void* p_data) 37 | { 38 | m_storedData.insert(p_data); 39 | } 40 | 41 | SearchNode* SearchNode::getFailure() const 42 | { 43 | return m_failureNode; 44 | } 45 | 46 | void SearchNode::setFailure(SearchNode* const p_node) 47 | { 48 | m_failureNode = p_node; 49 | } 50 | -------------------------------------------------------------------------------- /src/structures/relocation.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RELOCATION_HPP 2 | #define RELOCATION_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace elf 8 | { 9 | struct relocation_32 10 | { 11 | boost::uint32_t m_offset; 12 | boost::uint32_t m_info; 13 | }; 14 | 15 | BOOST_STATIC_ASSERT(sizeof(relocation_32) == 8); 16 | 17 | struct relocation_64 18 | { 19 | boost::uint64_t m_offset; 20 | boost::uint64_t m_info; 21 | }; 22 | 23 | BOOST_STATIC_ASSERT(sizeof(relocation_64) == 16); 24 | 25 | #pragma pack(push, 1) 26 | struct rela_32 27 | { 28 | boost::uint32_t m_offset; 29 | boost::uint32_t m_info; 30 | boost::uint32_t m_addend; 31 | }; 32 | 33 | BOOST_STATIC_ASSERT(sizeof(rela_32) == 12); 34 | 35 | struct rela_64 36 | { 37 | boost::uint64_t m_offset; 38 | boost::uint64_t m_info; 39 | boost::uint64_t m_addend; 40 | }; 41 | #pragma pack(pop) 42 | BOOST_STATIC_ASSERT(sizeof(rela_64) == 24); 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/datastructures/search_node.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ELFPARSER_SEARCHNODE_HPP 2 | #define ELFPARSER_SEARCHNODE_HPP 3 | 4 | #include 5 | 6 | class SearchNode 7 | { 8 | private: 9 | 10 | SearchNode(const SearchNode& p_rhs); 11 | SearchNode& operator=(const SearchNode& p_rhs); 12 | 13 | std::set m_storedData; 14 | SearchNode* m_next[256]; 15 | SearchNode* m_failureNode; 16 | 17 | public: 18 | 19 | SearchNode(); 20 | ~SearchNode(); 21 | 22 | SearchNode* getNext(const unsigned char p_value) const; 23 | 24 | std::size_t getNextSize() const { return sizeof(m_next) / sizeof(void*); } 25 | 26 | void setNext(const unsigned char p_value, SearchNode* p_node); 27 | 28 | const std::set& getStoredData() const; 29 | void addReturnValues(const std::set& p_dataSet); 30 | void addReturnValue(void* p_data); 31 | 32 | SearchNode* getFailure() const; 33 | void setFailure(SearchNode* const p_node); 34 | }; 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Config/DebugProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // DebugProject.xcconfig 3 | // 4 | // These are Debug Configuration project settings for the gtest framework and 5 | // examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // No optimization 14 | GCC_OPTIMIZATION_LEVEL = 0 15 | 16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off 17 | DEPLOYMENT_POSTPROCESSING = NO 18 | 19 | // Dead code stripping off 20 | DEAD_CODE_STRIPPING = NO 21 | 22 | // Debug symbols should be on obviously 23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES 24 | 25 | // Define the DEBUG macro in all debug builds 26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1 27 | 28 | // These are turned off to avoid STL incompatibilities with client code 29 | // // Turns on special C++ STL checks to "encourage" good STL use 30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS 31 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.${PRODUCT_NAME} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | GTEST_VERSIONINFO_LONG 21 | CFBundleShortVersionString 22 | GTEST_VERSIONINFO_SHORT 23 | CFBundleGetInfoString 24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT} 25 | NSHumanReadableCopyright 26 | ${GTEST_VERSIONINFO_ABOUT} 27 | CSResourcesFileMapped 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Config/ReleaseProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // ReleaseProject.xcconfig 3 | // 4 | // These are Release Configuration project settings for the gtest framework 5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // subconfig/Release.xcconfig 14 | 15 | // Optimize for space and size (Apple recommendation) 16 | GCC_OPTIMIZATION_LEVEL = s 17 | 18 | // Deploment postprocessing is what triggers Xcode to strip 19 | DEPLOYMENT_POSTPROCESSING = YES 20 | 21 | // No symbols 22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO 23 | 24 | // Dead code strip does not affect ObjC code but can help for C 25 | DEAD_CODE_STRIPPING = YES 26 | 27 | // NDEBUG is used by things like assert.h, so define it for general compat. 28 | // ASSERT going away in release tends to create unused vars. 29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable 30 | 31 | // When we strip we want to strip all symbols in release, but save externals. 32 | STRIP_STYLE = all 33 | -------------------------------------------------------------------------------- /src/abstract_dynamic.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACT_DYNAMIC_HPP 2 | #define ABSTRACT_DYNAMIC_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class AbstractDynamicEntry 9 | { 10 | private: 11 | boost::uint64_t m_tag; 12 | boost::uint64_t m_value; 13 | std::string m_stringValue; 14 | 15 | public: 16 | AbstractDynamicEntry(boost::uint64_t p_tag, boost::uint64_t p_value); 17 | AbstractDynamicEntry(const AbstractDynamicEntry& p_rhs); 18 | ~AbstractDynamicEntry(); 19 | 20 | // string validate (m_stringValue) returns a buulean value if empty returns 1 if empty returns 0 21 | bool validString() const; 22 | void createString(const char* p_strOffset); 23 | std::string createTag(boost::uint64_t p_tag) const; 24 | std::string createValue(boost::uint64_t p_tag, boost::uint64_t p_value, const char *p_strTab) const; 25 | 26 | boost::uint64_t getTag() const; 27 | boost::uint64_t getValue() const; 28 | const std::string getString() const; 29 | 30 | std::string printToStdOut() const; 31 | 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/segment_types/interp_segment.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INTERP_SEGMENT_HPP 2 | #define INTERP_SEGMENT_HPP 3 | 4 | #include "segment_type.hpp" 5 | 6 | #include 7 | #include 8 | 9 | /*! 10 | * Stores the interpreter in a string. Example of the content: 11 | * "/lib64/ld-linux-x86-64.so.2" 12 | */ 13 | class InterpSegment : public SegmentType 14 | { 15 | public: 16 | 17 | /* 18 | * puts the interpreter into m_interpreter 19 | * p_start the start of the binary 20 | * p_offset the offset to this segment 21 | * p_size the size of this segment 22 | * p_type elf::k_progbits 23 | */ 24 | InterpSegment(const char* start, boost::uint32_t p_offset, 25 | boost::uint32_t p_size, elf::section_type p_type); 26 | 27 | // nothing of note 28 | ~InterpSegment(); 29 | 30 | // return the string representation of the interp segment 31 | virtual std::string printToStdOut() const; 32 | 33 | private: 34 | 35 | // disable evil things 36 | InterpSegment(const InterpSegment& p_rhs); 37 | InterpSegment& operator=(const InterpSegment& p_rhs); 38 | 39 | // the name of the interpreter 40 | std::string m_interpreter; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/segment_types/debuglink_segment.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DEBUGLINK_SEGMENT_HPP 2 | #define DEBUGLINK_SEGMENT_HPP 3 | 4 | #include "segment_type.hpp" 5 | 6 | #include 7 | #include 8 | 9 | /*! 10 | * Holds the file name pointed at by the debug link. See more information here: 11 | * https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html 12 | */ 13 | class DebugLinkSegment : public SegmentType 14 | { 15 | public: 16 | 17 | /* 18 | * Puts the file name into m_file 19 | * p_start the start of the binary 20 | * p_offset the offset to this segment 21 | * p_size the size of this segment 22 | * p_type elf::k_progbits 23 | */ 24 | DebugLinkSegment(const char* start, boost::uint32_t p_offset, 25 | boost::uint32_t p_size, elf::section_type p_type); 26 | 27 | // Nothing of note 28 | ~DebugLinkSegment(); 29 | 30 | // return the string representation of the debug link 31 | virtual std::string printToStdOut() const; 32 | 33 | private: 34 | 35 | // Disable evil things 36 | DebugLinkSegment(const DebugLinkSegment& p_rhs); 37 | DebugLinkSegment& operator=(const DebugLinkSegment& p_rhs); 38 | 39 | // The filename the debug link points to 40 | std::string m_file; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/segment.cpp: -------------------------------------------------------------------------------- 1 | #include "segment.hpp" 2 | #include "structures/sectionheader.hpp" 3 | 4 | 5 | Segment::Segment(const std::string &p_name, const std::string &p_type, boost::uint64_t p_physOffset, boost::uint64_t p_virtAddress, 6 | boost::uint64_t p_size, boost::uint32_t p_link, bool p_executable, bool p_writable, bool p_isDynamic) : m_name(p_name), 7 | m_type(p_type), 8 | m_physOffset(p_physOffset), 9 | m_virtAddress(p_virtAddress), 10 | m_size(p_size), 11 | m_link(p_link), 12 | m_executable(p_executable), 13 | m_writable(p_writable), 14 | m_isDynamic(p_isDynamic) 15 | { 16 | 17 | } 18 | 19 | Segment::~Segment() 20 | { } 21 | 22 | boost::uint64_t Segment::getVirtAddress() const 23 | { 24 | return m_virtAddress; 25 | } 26 | 27 | boost::uint64_t Segment::getSize() const 28 | { 29 | return m_size; 30 | } 31 | 32 | boost::uint64_t Segment::getPhysOffset() const 33 | { 34 | return m_physOffset; 35 | } 36 | 37 | boost::uint32_t Segment::getLink() const 38 | { 39 | return m_link; 40 | } 41 | 42 | const std::string &Segment::getName() const 43 | { 44 | return m_name; 45 | } 46 | 47 | const std::string &Segment::getType() const 48 | { 49 | return m_type; 50 | } 51 | 52 | bool Segment::isDynamic() const 53 | { 54 | return m_isDynamic; 55 | } 56 | -------------------------------------------------------------------------------- /src/segment_types/comment_segment.hpp: -------------------------------------------------------------------------------- 1 | #ifndef COMMENT_SEGMENT_HPP 2 | #define COMMENT_SEGMENT_HPP 3 | 4 | #include "segment_type.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /*! 11 | * The comment segment. Holds pretty generic information. Example of the 12 | * contents of a comment segment: 13 | * "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3" 14 | */ 15 | class CommentSegment : public SegmentType 16 | { 17 | public: 18 | 19 | /*! 20 | * puts the comment into m_comment 21 | * p_start the start of the binary 22 | * p_offset the offset to this segment 23 | * p_size the size of this segment 24 | * p_type elf::k_progbits 25 | */ 26 | CommentSegment(const char* p_start, boost::uint32_t p_offset, 27 | boost::uint32_t p_size, elf::section_type p_type); 28 | 29 | // nothing of note 30 | ~CommentSegment(); 31 | 32 | // return the string representation of the comment segment 33 | virtual std::string printToStdOut() const; 34 | 35 | private: 36 | 37 | // disable evil things 38 | CommentSegment(const CommentSegment& p_rhs); 39 | CommentSegment& operator=(const CommentSegment& p_rhs); 40 | 41 | // the strings that the comment holds 42 | std::string m_comment; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /home/mob/Documents/C-C/elfparser/lib/gtest-1.6.0 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Install shared libraries without execute permission? 31 | if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) 32 | set(CMAKE_INSTALL_SO_NO_EXE "1") 33 | endif() 34 | 35 | # Is this installation the result of a crosscompile? 36 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 37 | set(CMAKE_CROSSCOMPILING "FALSE") 38 | endif() 39 | 40 | -------------------------------------------------------------------------------- /src/abstract_symbol.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACT_SYMBOL_HPP 2 | #define ABSTRACT_SYMBOL_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace elf 8 | { 9 | namespace symbol 10 | { 11 | struct symtable_entry32; 12 | struct symtable_entry64; 13 | } 14 | } 15 | 16 | class AbstractSymbol 17 | { 18 | public: 19 | AbstractSymbol(const char* p_data, boost::uint32_t p_offset, 20 | bool p_is64, bool p_isLE); 21 | AbstractSymbol(const AbstractSymbol& p_rhs); 22 | ~AbstractSymbol(); 23 | 24 | boost::uint32_t getStructSize() const; 25 | boost::uint8_t getType() const; 26 | boost::uint8_t getInfo() const; 27 | std::string getTypeName() const; 28 | std::string getBinding() const; 29 | boost::uint64_t getValue() const; 30 | boost::uint32_t getNameIndex() const; 31 | const std::string& getName() const; 32 | boost::uint16_t getSectionIndex() const; 33 | 34 | void setName(const std::string& p_name); 35 | 36 | private: 37 | 38 | // disable evil things 39 | AbstractSymbol& operator=(const AbstractSymbol& p_rhs); 40 | 41 | private: 42 | 43 | const elf::symbol::symtable_entry32* m_symbol32; 44 | const elf::symbol::symtable_entry64* m_symbol64; 45 | std::string m_name; 46 | bool m_is64; 47 | bool m_isLE; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/endian.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __FINK_ENDIANDEV_PKG_ENDIAN_H__ 2 | #define __FINK_ENDIANDEV_PKG_ENDIAN_H__ 1 3 | 4 | /** compatibility header for endian.h 5 | * This is a simple compatibility shim to convert 6 | * BSD/Linux endian macros to the Mac OS X equivalents. 7 | * It is public domain. 8 | * */ 9 | 10 | #ifdef APPLE 11 | #include 12 | 13 | #define htobe16(x) OSSwapHostToBigInt16(x) 14 | #define htole16(x) OSSwapHostToLittleInt16(x) 15 | #define be16toh(x) OSSwapBigToHostInt16(x) 16 | #define le16toh(x) OSSwapLittleToHostInt16(x) 17 | 18 | #define htobe32(x) OSSwapHostToBigInt32(x) 19 | #define htole32(x) OSSwapHostToLittleInt32(x) 20 | #define be32toh(x) OSSwapBigToHostInt32(x) 21 | #define le32toh(x) OSSwapLittleToHostInt32(x) 22 | 23 | #define htobe64(x) OSSwapHostToBigInt64(x) 24 | #define htole64(x) OSSwapHostToLittleInt64(x) 25 | #define be64toh(x) OSSwapBigToHostInt64(x) 26 | #define le64toh(x) OSSwapLittleToHostInt64(x) 27 | #elif WINDOWS 28 | #include 29 | #include 30 | 31 | #define htons(x) _byteswap_ushort(x) 32 | #define ntohs(x) _byteswap_ushort(x) 33 | 34 | #define htonl(x) _byteswap_ulong(x) 35 | #define ntohl(x) _byteswap_ulong(x) 36 | 37 | #define htobe64(x) htonll(x) 38 | #define htole64(x) (x) 39 | #define be64toh(x) ntohll(x) 40 | #define le64toh(x) (x) 41 | #endif 42 | 43 | #endif /* __FINK_ENDIANDEV_PKG_ENDIAN_H__ */ 44 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Config/General.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // General.xcconfig 3 | // 4 | // These are General configuration settings for the gtest framework and 5 | // examples. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Build for PPC and Intel, 32- and 64-bit 11 | ARCHS = i386 x86_64 ppc ppc64 12 | 13 | // Zerolink prevents link warnings so turn it off 14 | ZERO_LINK = NO 15 | 16 | // Prebinding considered unhelpful in 10.3 and later 17 | PREBINDING = NO 18 | 19 | // Strictest warning policy 20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow 21 | 22 | // Work around Xcode bugs by using external strip. See: 23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html 24 | SEPARATE_STRIP = YES 25 | 26 | // Force C99 dialect 27 | GCC_C_LANGUAGE_STANDARD = c99 28 | 29 | // not sure why apple defaults this on, but it's pretty risky 30 | ALWAYS_SEARCH_USER_PATHS = NO 31 | 32 | // Turn on position dependent code for most cases (overridden where appropriate) 33 | GCC_DYNAMIC_NO_PIC = YES 34 | 35 | // Default SDK and minimum OS version is 10.4 36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk 37 | MACOSX_DEPLOYMENT_TARGET = 10.4 38 | GCC_VERSION = 4.0 39 | 40 | // VERSIONING BUILD SETTINGS (used in Info.plist) 41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc. 42 | -------------------------------------------------------------------------------- /src/structures/symtable_entry.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SYMTABLE_ENTRY_HPP 2 | #define SYMTABLE_ENTRY_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace elf 9 | { 10 | namespace symbol 11 | { 12 | #pragma pack(push, 1) 13 | struct symtable_entry32 14 | { 15 | boost::uint32_t m_name; 16 | boost::uint32_t m_address; 17 | boost::uint32_t m_size; 18 | boost::uint8_t m_info; 19 | boost::uint8_t m_other; 20 | boost::uint16_t m_shndx; 21 | }; 22 | 23 | BOOST_STATIC_ASSERT(sizeof(symtable_entry32) == 16); 24 | 25 | struct symtable_entry64 26 | { 27 | boost::uint32_t m_name; 28 | boost::uint8_t m_info; 29 | boost::uint8_t m_other; 30 | boost::uint16_t m_shndx; 31 | boost::uint64_t m_address; 32 | boost::uint64_t m_size; 33 | }; 34 | 35 | BOOST_STATIC_ASSERT(sizeof(symtable_entry64) == 24); 36 | #pragma pack(pop) 37 | 38 | enum binding 39 | { 40 | k_local = 0, 41 | k_global, 42 | k_weak 43 | }; 44 | 45 | enum type 46 | { 47 | k_notype = 0, 48 | k_object, 49 | k_function, 50 | k_section, 51 | k_file, 52 | k_common, 53 | k_tls 54 | }; 55 | } 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /src/datastructures/search_tree.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ELFPARSER_SEARCH_HPP 2 | #define ELFPARSER_SEARCH_HPP 3 | 4 | #include "search_node.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | /* 13 | * This is a basic automata implemenation. Used for efficient searching. 14 | */ 15 | class SearchTree 16 | { 17 | public: 18 | 19 | SearchTree(); 20 | ~SearchTree(); 21 | 22 | void addWord(const unsigned char* p_input, 23 | unsigned char p_length, void* p_storeData); 24 | void addWord(const char* p_input, unsigned char p_length, void* p_storeData); 25 | void addWord(const std::string& p_string, 26 | void* p_storeData); 27 | 28 | std::set findOffsets(const char* const p_inputString, 29 | const std::size_t p_inputLength); 30 | std::set search(const char* const p_inputString, 31 | const std::size_t p_inputLength); 32 | 33 | std::set search(const unsigned char* const p_inputString, 34 | const std::size_t p_inputLength); 35 | 36 | void compile(); 37 | 38 | private: 39 | 40 | void doAddWord(SearchNode* p_node, const unsigned char* p_input, 41 | unsigned char p_length, void* p_storeData); 42 | 43 | private: 44 | 45 | SearchNode m_rootNode; 46 | 47 | bool m_ready; 48 | 49 | boost::ptr_vector m_nodeVector; 50 | }; 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /src/structures/programheader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROGRAM_HEADER_HPP 2 | #define PROGRAM_HEADER_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace elf 8 | { 9 | struct program_header_32 10 | { 11 | boost::uint32_t m_type; 12 | boost::uint32_t m_offset; 13 | boost::uint32_t m_vaddr; 14 | boost::uint32_t m_paddr; 15 | boost::uint32_t m_filesz; 16 | boost::uint32_t m_memsz; 17 | boost::uint32_t m_flags; 18 | boost::uint32_t m_align; 19 | }; 20 | 21 | BOOST_STATIC_ASSERT(sizeof(program_header_32) == 32); 22 | 23 | struct program_header_64 24 | { 25 | boost::uint32_t m_type; 26 | boost::uint32_t m_flags; 27 | boost::uint64_t m_offset; 28 | boost::uint64_t m_vaddr; 29 | boost::uint64_t m_paddr; 30 | boost::uint64_t m_filesz; 31 | boost::uint64_t m_memsz; 32 | boost::uint64_t m_align; 33 | }; 34 | 35 | BOOST_STATIC_ASSERT(sizeof(program_header_64) == 56); 36 | 37 | enum programheader_type 38 | { 39 | k_pnull = 0, 40 | k_pload, 41 | k_pdynamic, 42 | k_pinterp, 43 | k_pnote, 44 | k_pshlib, 45 | k_pphdr, 46 | k_ptls, 47 | k_gnuEh = 0x6474e550, 48 | k_gnuStack = 0x6474e551, 49 | k_gnuRelRo = 0x6474e552, 50 | k_reginfo = 0x70000000, 51 | k_exidx = 0x70000001 52 | }; 53 | 54 | enum programheader_flags 55 | { 56 | k_pfexec = 1, 57 | k_pfwrite = 2, 58 | k_pfread = 4 59 | }; 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/segment_types/readonly_segment.hpp: -------------------------------------------------------------------------------- 1 | #ifndef READONLY_SEGMENT_HPP 2 | #define READONLY_SEGMENT_HPP 3 | 4 | #include "segment_type.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /*! 12 | * This segment parses the read only segment looking for ascii strings 13 | */ 14 | class ReadOnlySegment : public SegmentType 15 | { 16 | public: 17 | 18 | /*! 19 | * parses the read only segment looking for ascii strings 20 | * p_start the start of the image 21 | * p_offset the offset to this segment 22 | * p_size the size of this segment 23 | * p_type the type of this segment 24 | */ 25 | ReadOnlySegment(const char* p_start, boost::uint32_t p_offset, 26 | boost::uint32_t p_size, elf::section_type p_type); 27 | 28 | // nothing of note 29 | ~ReadOnlySegment(); 30 | 31 | /*! 32 | * Looks for "evil" strings and add them to the reasons vector 33 | * p_reasons the scoring vector to put the scores into 34 | * unused capabilties set 35 | */ 36 | void evaluate(std::vector >& p_reasons, 37 | std::map >&) const; 38 | 39 | // return the string representation of the read only segment 40 | virtual std::string printToStdOut() const; 41 | 42 | private: 43 | 44 | // disable evil things 45 | ReadOnlySegment(const ReadOnlySegment& p_rhs); 46 | ReadOnlySegment& operator=(const ReadOnlySegment& p_rhs); 47 | 48 | // the ascii strings in the read only segment 49 | std::set m_asciiStrings; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # elfparser-ng 2 | 3 | Multiplatform command-line and graphical tool to analyze (suspicious) ELF files. This is an authorized, maintained fork of the great [ELF Parser](https://elfparser.com). 4 | 5 | ## Features 6 | 7 | * File hashes (MD5, SHA-1, and SHA-256). 8 | * File entropy. 9 | * ELF headers, sections and segments parsing. 10 | * ELF symbols. 11 | * Hex Dump. 12 | * Capabilities detection. 13 | * Scoring system. 14 | 15 | ## Installing 16 | 17 | You can download a pre-compiled release from the [Releases](https://github.com/mentebinaria/elfparser-ng/releases) section and use it. 18 | 19 | ## Screnshots 20 | 21 | ### Main window 22 | 23 | ![main](assets/gui-win-main.png) 24 | 25 | ### Segments 26 | 27 | ![segments](assets/gui-win-segments.png) 28 | 29 | ### Capabilities 30 | 31 | ![capabilities](assets/gui-win-capabilities.png) 32 | 33 | ## Building 34 | 35 | If you want to build elfparser-ng yourself, here's an useful tutorial: 36 | 37 | [![asciicast](https://asciinema.org/a/444072.svg)](https://asciinema.org/a/444072) 38 | 39 | To build on Windows, set the `option(windows "Enable Windows build." OFF` to `ON` in [CMakeFiles](CMakeLists.txt) file. Then, download and install CMake - and all the dependencies - and compile it using Visual Studio. 40 | 41 | ### Compile Targets 42 | 43 | elfparser-ng has a number of compilation targets configurable in `CMakeLists.txt` file: 44 | 45 | * Unit tests 46 | * CLI build 47 | * GUI build 48 | 49 | ### Dependencies 50 | 51 | * Boost 52 | * Qt5 53 | 54 | In Debian-based Linux distros, you can install them with: 55 | 56 | apt-get install libboost-all-dev build-essential \ 57 | qtcreator qt5-default qtdeclarative5-dev 58 | -------------------------------------------------------------------------------- /src/segment_types/strtable_segment.hpp: -------------------------------------------------------------------------------- 1 | #ifndef STRINGTABLE_SEGMENT_HPP 2 | #define STRINGTABLE_SEGMENT_HPP 3 | 4 | #include "segment_type.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Holds all the strings in the string table 12 | */ 13 | class StringTableSegment : public SegmentType 14 | { 15 | public: 16 | 17 | /* 18 | * Parses the string table for strings and stores them in the m_strings set 19 | * p_start the start of the image 20 | * p_offset the offset to this segment 21 | * p_size the size of the segment 22 | * p_type the type of segment 23 | */ 24 | StringTableSegment(const char* p_start, boost::uint32_t p_offset, 25 | boost::uint32_t p_size, elf::section_type p_type); 26 | 27 | // nothing of note 28 | ~StringTableSegment(); 29 | 30 | // return the number of strings in m_strings 31 | std::size_t getSize() const; 32 | 33 | /* 34 | * looks up a string in the string table and demangles it (Linux only) 35 | * p_index the index of the string to look up 36 | * return the string in the table 37 | */ 38 | std::string stringLookup(std::size_t p_index) const; 39 | 40 | // return a string representation of the String Table 41 | virtual std::string printToStdOut() const; 42 | 43 | private: 44 | 45 | // disable evil things 46 | StringTableSegment(const StringTableSegment& p_rhs); 47 | StringTableSegment& operator=(const StringTableSegment& p_rhs); 48 | 49 | // A set of the strings in the segment 50 | std::set m_stringsSet; 51 | 52 | // the start of the segment 53 | const char* m_start; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/segment_types/note_segment.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NOTE_SEGMENT_HPP 2 | #define NOTE_SEGMENT_HPP 3 | 4 | #include "segment_type.hpp" 5 | 6 | #include 7 | #include 8 | 9 | namespace elf 10 | { 11 | struct note; 12 | } 13 | 14 | /*! 15 | * Parses the note segment and tries to interpret the contents. Some parsed 16 | * examples: 17 | * "Name="GNU, Type=1, Type String="NT_GNU_ABI_TAG", Description="OS Linux 2.6.24"" 18 | * "Name="GNU", Type=3, Type String="NT_GNU_BUILD_ID", Description="f21bf131b6da48c9bfe35b117c5b15a687174362"" 19 | */ 20 | class NoteSegment : public SegmentType 21 | { 22 | public: 23 | 24 | /* 25 | * Parses the note and stores the values into the member variables 26 | * p_start the start of the binary 27 | * p_offset the offset to this segment 28 | * p_size the size of this segment 29 | * p_type elf::k_note 30 | */ 31 | NoteSegment(const char* start, boost::uint32_t p_offset, 32 | boost::uint32_t p_size, elf::section_type p_type); 33 | 34 | //nothing of note (lol) 35 | ~NoteSegment(); 36 | 37 | // return the string representation of the note segment 38 | virtual std::string printToStdOut() const; 39 | 40 | private: 41 | 42 | // disable evil things 43 | NoteSegment(const NoteSegment& p_rhs); 44 | NoteSegment& operator=(const NoteSegment& p_rhs); 45 | 46 | // A pointer to the start of the note structure 47 | const elf::note* m_note; 48 | 49 | // The name of the note 50 | std::string m_name; 51 | 52 | // The interpreted type of the note 53 | std::string m_noteType; 54 | 55 | // The interpreted description of the note 56 | std::string m_description; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/segment.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SEGMENT_HPP 2 | #define SEGMENT_HPP 3 | 4 | #include 5 | #include 6 | 7 | #define CEXIT_SUCCESS " "; 8 | 9 | class Segment 10 | { 11 | private: 12 | //! disable evil things 13 | //Segment& operator=(const Segment& p_rhs); 14 | 15 | //! the name of this segment 16 | std::string m_name; 17 | 18 | //! the type of this segment 19 | std::string m_type; 20 | 21 | //! the file offset to this segment 22 | boost::uint64_t m_physOffset; 23 | 24 | //! the virtual address of this segment 25 | boost::uint64_t m_virtAddress; 26 | 27 | //! size on file 28 | boost::uint64_t m_size; 29 | 30 | //! the link to another table that may exist 31 | boost::uint32_t m_link; 32 | 33 | //! indicates if the area is executable 34 | bool m_executable; 35 | 36 | //! indicates if this area is writable 37 | bool m_writable; 38 | 39 | //! indicates if this is the dynamic section 40 | bool m_isDynamic; 41 | 42 | public: 43 | Segment(const std::string& p_name, const std::string& p_type, boost::uint64_t p_physOffset, boost::uint64_t p_virtAddress, 44 | boost::uint64_t p_size, boost::uint32_t p_link, bool p_executable, bool p_writable, bool p_isDynamic); 45 | ~Segment(); 46 | 47 | boost::uint64_t getVirtAddress() const; 48 | boost::uint64_t getSize() const; 49 | boost::uint64_t getPhysOffset() const; 50 | boost::uint32_t getLink() const; 51 | const std::string& getName() const; 52 | const std::string& getType() const; 53 | bool isDynamic() const; 54 | 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/structures/dynamicstruct.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DYNAMICSTRUCT_HPP 2 | #define DYNAMICSTRUCT_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace elf 10 | { 11 | namespace dynamic 12 | { 13 | struct dynamic_32 14 | { 15 | boost::uint32_t m_tag; 16 | union 17 | { 18 | boost::uint32_t m_val; 19 | boost::uint32_t m_ptr; 20 | }; 21 | }; 22 | 23 | BOOST_STATIC_ASSERT(8 == sizeof(dynamic_32)); 24 | 25 | struct dynamic_64 26 | { 27 | boost::uint64_t m_tag; 28 | union 29 | { 30 | boost::uint64_t m_val; 31 | boost::uint64_t m_ptr; 32 | }; 33 | }; 34 | 35 | BOOST_STATIC_ASSERT(16 == sizeof(dynamic_64)); 36 | 37 | enum tag 38 | { 39 | k_needed = 1, 40 | k_pltrelsz, 41 | k_pltgot, 42 | k_hash, 43 | k_strtab, 44 | k_symtab, 45 | k_rela, 46 | k_relasz, 47 | k_relaent, 48 | k_strsz, 49 | k_syment, 50 | k_init, 51 | k_fini, 52 | k_soname, 53 | k_rpath, 54 | k_symbolic, 55 | k_rel, 56 | k_relsz, 57 | k_relent, 58 | k_pltrel, 59 | k_debug, 60 | k_textrel, 61 | k_jmprel, 62 | k_bindnow, 63 | k_initarray, 64 | k_finiarray, 65 | k_init_arraysz, 66 | k_fini_arraysz, 67 | k_gnuhash = 0x6ffffef5 68 | }; 69 | } 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/structures/sectionheader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SECTION_HEADER_HPP 2 | #define SECTION_HEADER_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace elf 8 | { 9 | struct section_header_32 10 | { 11 | boost::uint32_t m_name; 12 | boost::uint32_t m_type; 13 | boost::uint32_t m_flags; 14 | boost::uint32_t m_addr; 15 | boost::uint32_t m_offset; 16 | boost::uint32_t m_size; 17 | boost::uint32_t m_link; 18 | boost::uint32_t m_info; 19 | boost::uint32_t m_addralign; 20 | boost::uint32_t m_entsize; 21 | }; 22 | 23 | BOOST_STATIC_ASSERT(sizeof(section_header_32) == 40); 24 | 25 | struct section_header_64 26 | { 27 | boost::uint32_t m_name; 28 | boost::uint32_t m_type; 29 | boost::uint64_t m_flags; 30 | boost::uint64_t m_addr; 31 | boost::uint64_t m_offset; 32 | boost::uint64_t m_size; 33 | boost::uint32_t m_link; 34 | boost::uint32_t m_info; 35 | boost::uint64_t m_addralign; 36 | boost::uint64_t m_entsize; 37 | }; 38 | 39 | BOOST_STATIC_ASSERT(sizeof(section_header_64) == 64); 40 | 41 | enum section_type 42 | { 43 | k_null = 0, 44 | k_progbits, 45 | k_symtab, 46 | k_strtab, 47 | k_rela, 48 | k_hash, 49 | k_dynamic, 50 | k_note, 51 | k_nobits, 52 | k_rel, 53 | k_shlib, 54 | k_dynsym, 55 | k_initArray = 14, 56 | k_finiArray = 15, 57 | k_gnuHash = 0x6ffffff6, 58 | k_gnuVersionR = 0x6ffffffe, 59 | k_gnuVersion = 0x6fffffff 60 | }; 61 | 62 | enum section_flags 63 | { 64 | k_shwrite = 1, 65 | k_shalloc = 2, 66 | k_shexec = 4 67 | }; 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "production.h" 35 | 36 | PrivateCode::PrivateCode() : x_(0) {} 37 | -------------------------------------------------------------------------------- /src/segment_types/readonly_segment.cpp: -------------------------------------------------------------------------------- 1 | #include "readonly_segment.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | ReadOnlySegment::ReadOnlySegment(const char* start, boost::uint32_t p_offset, 8 | boost::uint32_t p_size, elf::section_type p_type) : 9 | SegmentType(start, p_offset, p_size, p_type), 10 | m_asciiStrings() 11 | { 12 | std::string current; 13 | const char* readOnly = start + p_offset; 14 | for (boost::uint32_t i = 0; i < p_size; ++i) 15 | { 16 | if (isprint(static_cast(readOnly[i]))) 17 | { 18 | current.push_back(readOnly[i]); 19 | } 20 | else 21 | { 22 | if (current.size() > 7) 23 | { 24 | m_asciiStrings.insert(current); 25 | } 26 | current.clear(); 27 | } 28 | } 29 | } 30 | 31 | ReadOnlySegment::~ReadOnlySegment() 32 | { 33 | } 34 | 35 | std::string ReadOnlySegment::printToStdOut() const 36 | { 37 | std::stringstream return_value; 38 | return_value << "Read Only Segment (offset= 0x" << std::hex << m_offset 39 | << ", size= " << std::dec << m_size << ", strings= " 40 | << m_asciiStrings.size() << ")\n\t"; 41 | 42 | BOOST_FOREACH(const std::string& p_ascii, m_asciiStrings) 43 | { 44 | return_value << "String= " << p_ascii << "\t" << std::endl; 45 | } 46 | return return_value.str(); 47 | } 48 | 49 | void ReadOnlySegment::evaluate(std::vector >& p_reasons, 50 | std::map >&) const 51 | { 52 | if (m_asciiStrings.empty()) 53 | { 54 | p_reasons.push_back(std::make_pair(5, std::string("No ascii strings in the read only section."))); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | std::cout << "Running main() from gtest_main.cc\n"; 36 | 37 | testing::InitGoogleTest(&argc, argv); 38 | return RUN_ALL_TESTS(); 39 | } 40 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/fused-src/gtest/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) 35 | { 36 | std::cout << "Running main() from gtest_main.cc\n"; 37 | 38 | testing::InitGoogleTest(&argc, argv); 39 | return RUN_ALL_TESTS(); 40 | } 41 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/codegear/gtest_all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // C++Builder's IDE cannot build a static library from files with hyphens 35 | // in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 . 36 | // This file serves as a workaround. 37 | 38 | #include "src/gtest-all.cc" 39 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/scripts/test/Makefile: -------------------------------------------------------------------------------- 1 | # A Makefile for fusing Google Test and building a sample test against it. 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything. 6 | # make TARGET - makes the given target. 7 | # make check - makes everything and runs the built sample test. 8 | # make clean - removes all files generated by make. 9 | 10 | # Points to the root of fused Google Test, relative to where this file is. 11 | FUSED_GTEST_DIR = output 12 | 13 | # Paths to the fused gtest files. 14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h 15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 16 | 17 | # Where to find the sample test. 18 | SAMPLE_DIR = ../../samples 19 | 20 | # Where to find gtest_main.cc. 21 | GTEST_MAIN_CC = ../../src/gtest_main.cc 22 | 23 | # Flags passed to the preprocessor. 24 | # We have no idea here whether pthreads is available in the system, so 25 | # disable its use. 26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0 27 | 28 | # Flags passed to the C++ compiler. 29 | CXXFLAGS += -g 30 | 31 | all : sample1_unittest 32 | 33 | check : all 34 | ./sample1_unittest 35 | 36 | clean : 37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o 38 | 39 | $(FUSED_GTEST_H) : 40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 41 | 42 | $(FUSED_GTEST_ALL_CC) : 43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 44 | 45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC) 46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 47 | 48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC) 49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC) 50 | 51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h 52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc 53 | 54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \ 55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H) 56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc 57 | 58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o 59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ 60 | -------------------------------------------------------------------------------- /lib/hash-lib/md5.hpp: -------------------------------------------------------------------------------- 1 | // ////////////////////////////////////////////////////////// 2 | // md5.h 3 | // Copyright (c) 2014 Stephan Brumme. All rights reserved. 4 | // see http://create.stephan-brumme.com/disclaimer.html 5 | // 6 | 7 | #pragma once 8 | 9 | //#include "hash.h" 10 | #include 11 | 12 | // define fixed size integer types 13 | #ifdef _MSC_VER 14 | // Windows 15 | typedef unsigned __int8 uint8_t; 16 | typedef unsigned __int32 uint32_t; 17 | typedef unsigned __int64 uint64_t; 18 | #else 19 | // GCC 20 | #include 21 | #endif 22 | 23 | 24 | /// compute MD5 hash 25 | /** Usage: 26 | MD5 md5; 27 | std::string myHash = md5("Hello World"); // std::string 28 | std::string myHash2 = md5("How are you", 11); // arbitrary data, 11 bytes 29 | 30 | // or in a streaming fashion: 31 | 32 | MD5 md5; 33 | while (more data available) 34 | md5.add(pointer to fresh data, number of new bytes); 35 | std::string myHash3 = md5.getHash(); 36 | */ 37 | class MD5 //: public Hash 38 | { 39 | public: 40 | /// same as reset() 41 | MD5(); 42 | 43 | /// compute MD5 of a memory block 44 | std::string operator()(const void* data, size_t numBytes); 45 | /// compute MD5 of a string, excluding final zero 46 | std::string operator()(const std::string& text); 47 | 48 | /// add arbitrary number of bytes 49 | void add(const void* data, size_t numBytes); 50 | 51 | /// return latest hash as 16 hex characters 52 | std::string getHash(); 53 | 54 | /// restart 55 | void reset(); 56 | 57 | private: 58 | /// process 64 bytes 59 | void processBlock(const void* data); 60 | /// process everything left in the internal buffer 61 | void processBuffer(); 62 | 63 | /// split into 64 byte blocks (=> 512 bits) 64 | enum { BlockSize = 512 / 8 }; 65 | 66 | /// size of processed data in bytes 67 | uint64_t m_numBytes; 68 | /// valid bytes in m_buffer 69 | size_t m_bufferSize; 70 | /// bytes not processed yet 71 | uint8_t m_buffer[BlockSize]; 72 | /// hash, stored as integers 73 | uint32_t m_hash[4]; 74 | }; 75 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | // Tests that we don't have to define main() when we link to 35 | // gtest_main instead of gtest. 36 | 37 | namespace { 38 | 39 | TEST(GTestMainTest, ShouldSucceed) { 40 | } 41 | 42 | } // namespace 43 | 44 | // We are using the main() function defined in src/gtest_main.cc, so 45 | // we don't define it here. 46 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/samples/sample4_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | #include "sample4.h" 34 | 35 | // Tests the Increment() method. 36 | TEST(Counter, Increment) { 37 | Counter c; 38 | 39 | // EXPECT_EQ() evaluates its arguments exactly once, so they 40 | // can have side effects. 41 | 42 | EXPECT_EQ(0, c.Increment()); 43 | EXPECT_EQ(1, c.Increment()); 44 | EXPECT_EQ(2, c.Increment()); 45 | } 46 | -------------------------------------------------------------------------------- /lib/hash-lib/sha1.hpp: -------------------------------------------------------------------------------- 1 | // ////////////////////////////////////////////////////////// 2 | // sha1.h 3 | // Copyright (c) 2014 Stephan Brumme. All rights reserved. 4 | // see http://create.stephan-brumme.com/disclaimer.html 5 | // 6 | 7 | #pragma once 8 | 9 | //#include "hash.h" 10 | #include 11 | 12 | // define fixed size integer types 13 | #ifdef _MSC_VER 14 | // Windows 15 | typedef unsigned __int8 uint8_t; 16 | typedef unsigned __int32 uint32_t; 17 | typedef unsigned __int64 uint64_t; 18 | #else 19 | // GCC 20 | #include 21 | #endif 22 | 23 | 24 | /// compute SHA1 hash 25 | /** Usage: 26 | SHA1 sha1; 27 | std::string myHash = sha1("Hello World"); // std::string 28 | std::string myHash2 = sha1("How are you", 11); // arbitrary data, 11 bytes 29 | 30 | // or in a streaming fashion: 31 | 32 | SHA1 sha1; 33 | while (more data available) 34 | sha1.add(pointer to fresh data, number of new bytes); 35 | std::string myHash3 = sha1.getHash(); 36 | */ 37 | class SHA1 //: public Hash 38 | { 39 | public: 40 | /// same as reset() 41 | SHA1(); 42 | 43 | /// compute SHA1 of a memory block 44 | std::string operator()(const void* data, size_t numBytes); 45 | /// compute SHA1 of a string, excluding final zero 46 | std::string operator()(const std::string& text); 47 | 48 | /// add arbitrary number of bytes 49 | void add(const void* data, size_t numBytes); 50 | 51 | /// return latest hash as 16 hex characters 52 | std::string getHash(); 53 | 54 | /// restart 55 | void reset(); 56 | 57 | private: 58 | /// process 64 bytes 59 | void processBlock(const void* data); 60 | /// process everything left in the internal buffer 61 | void processBuffer(); 62 | 63 | /// split into 64 byte blocks (=> 512 bits) 64 | enum { BlockSize = 512 / 8, HashValues = 5 }; 65 | 66 | /// size of processed data in bytes 67 | uint64_t m_numBytes; 68 | /// valid bytes in m_buffer 69 | size_t m_bufferSize; 70 | /// bytes not processed yet 71 | uint8_t m_buffer[BlockSize]; 72 | /// hash, stored as integers 73 | uint32_t m_hash[HashValues]; 74 | }; 75 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE1_H_ 35 | #define GTEST_SAMPLES_SAMPLE1_H_ 36 | 37 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 38 | int Factorial(int n); 39 | 40 | // Returns true iff n is a prime number. 41 | bool IsPrime(int n); 42 | 43 | #endif // GTEST_SAMPLES_SAMPLE1_H_ 44 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_uninitialized_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | TEST(DummyTest, Dummy) { 35 | // This test doesn't verify anything. We just need it to create a 36 | // realistic stage for testing the behavior of Google Test when 37 | // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being 38 | // called first. 39 | } 40 | 41 | int main() { 42 | return RUN_ALL_TESTS(); 43 | } 44 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/samples/sample4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include 35 | 36 | #include "sample4.h" 37 | 38 | // Returns the current counter value, and increments it. 39 | int Counter::Increment() { 40 | return counter_++; 41 | } 42 | 43 | // Prints the current counter value to STDOUT. 44 | void Counter::Print() const { 45 | printf("%d", counter_); 46 | } 47 | -------------------------------------------------------------------------------- /lib/hash-lib/sha256.hpp: -------------------------------------------------------------------------------- 1 | // ////////////////////////////////////////////////////////// 2 | // sha256.h 3 | // Copyright (c) 2014 Stephan Brumme. All rights reserved. 4 | // see http://create.stephan-brumme.com/disclaimer.html 5 | // 6 | 7 | #pragma once 8 | 9 | //#include "hash.h" 10 | #include 11 | 12 | // define fixed size integer types 13 | #ifdef _MSC_VER 14 | // Windows 15 | typedef unsigned __int8 uint8_t; 16 | typedef unsigned __int32 uint32_t; 17 | typedef unsigned __int64 uint64_t; 18 | #else 19 | // GCC 20 | #include 21 | #endif 22 | 23 | 24 | /// compute SHA256 hash 25 | /** Usage: 26 | SHA256 sha256; 27 | std::string myHash = sha256("Hello World"); // std::string 28 | std::string myHash2 = sha256("How are you", 11); // arbitrary data, 11 bytes 29 | 30 | // or in a streaming fashion: 31 | 32 | SHA256 sha256; 33 | while (more data available) 34 | sha256.add(pointer to fresh data, number of new bytes); 35 | std::string myHash3 = sha256.getHash(); 36 | */ 37 | class SHA256 //: public Hash 38 | { 39 | public: 40 | /// same as reset() 41 | SHA256(); 42 | 43 | /// compute SHA256 of a memory block 44 | std::string operator()(const void* data, size_t numBytes); 45 | /// compute SHA256 of a string, excluding final zero 46 | std::string operator()(const std::string& text); 47 | 48 | /// add arbitrary number of bytes 49 | void add(const void* data, size_t numBytes); 50 | 51 | /// return latest hash as 16 hex characters 52 | std::string getHash(); 53 | 54 | /// restart 55 | void reset(); 56 | 57 | private: 58 | /// process 64 bytes 59 | void processBlock(const void* data); 60 | /// process everything left in the internal buffer 61 | void processBuffer(); 62 | 63 | /// split into 64 byte blocks (=> 512 bits) 64 | enum { BlockSize = 512 / 8, HashValues = 8 }; 65 | 66 | /// size of processed data in bytes 67 | uint64_t m_numBytes; 68 | /// valid bytes in m_buffer 69 | size_t m_bufferSize; 70 | /// bytes not processed yet 71 | uint8_t m_buffer[BlockSize]; 72 | /// hash, stored as integers 73 | uint32_t m_hash[8]; 74 | }; 75 | -------------------------------------------------------------------------------- /src/initarray.cpp: -------------------------------------------------------------------------------- 1 | #include "initarray.hpp" 2 | #include 3 | #include 4 | 5 | #if WINDOWS || __APPLE__ 6 | #include "endian.hpp" 7 | #else 8 | #include 9 | #endif 10 | 11 | InitArray::InitArray(const std::string& p_name) : m_name(p_name), 12 | m_offset(0) 13 | { 14 | } 15 | 16 | InitArray::~InitArray() 17 | { } 18 | 19 | void InitArray::set(const char* p_data, boost::uint32_t p_size, 20 | boost::uint32_t p_offset, boost::uint32_t p_entries, 21 | bool is64, bool isLE) 22 | { 23 | const char* offset = p_data + p_offset; 24 | const char* end = p_data + p_offset; 25 | m_offset = p_offset; 26 | boost::uint32_t size = (is64) ? 8 : 4; 27 | 28 | end += (size * p_entries); 29 | 30 | for ( ; offset <= end; offset += size) 31 | { 32 | if (is64) 33 | { 34 | boost::uint64_t address = *reinterpret_cast(offset); 35 | if (!isLE) 36 | { 37 | address = htobe64(address); 38 | } 39 | m_entries.push_back(std::make_pair(address, "")); 40 | } 41 | else 42 | { 43 | boost::uint32_t address = *reinterpret_cast(offset); 44 | if (!isLE) 45 | { 46 | address = ntohl(address); 47 | } 48 | m_entries.push_back(std::make_pair(address, "")); 49 | } 50 | } 51 | } 52 | 53 | boost::uint32_t InitArray::getOffset() const 54 | { 55 | return m_offset; 56 | } 57 | 58 | std::vector >& InitArray::getEntries() 59 | { 60 | return m_entries; 61 | } 62 | 63 | std::string InitArray::printToStd() const 64 | { 65 | std::stringstream returnValue; 66 | returnValue << m_name << " (" << m_entries.size() << ") " << std::endl; 67 | for (std::size_t i = 0; i < m_entries.size(); ++i) 68 | { 69 | returnValue << "Entry addess=0x" << std::hex << m_entries[i].first << " name=" << m_entries[i].second << std::endl; 70 | } 71 | 72 | return returnValue.str(); 73 | } 74 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/build-aux/config.h.in: -------------------------------------------------------------------------------- 1 | /* build-aux/config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define if you have POSIX threads libraries and header files. */ 13 | #undef HAVE_PTHREAD 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDINT_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDLIB_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRINGS_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRING_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_STAT_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_TYPES_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_UNISTD_H 35 | 36 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 37 | */ 38 | #undef LT_OBJDIR 39 | 40 | /* Name of package */ 41 | #undef PACKAGE 42 | 43 | /* Define to the address where bug reports for this package should be sent. */ 44 | #undef PACKAGE_BUGREPORT 45 | 46 | /* Define to the full name of this package. */ 47 | #undef PACKAGE_NAME 48 | 49 | /* Define to the full name and version of this package. */ 50 | #undef PACKAGE_STRING 51 | 52 | /* Define to the one symbol short name of this package. */ 53 | #undef PACKAGE_TARNAME 54 | 55 | /* Define to the home page for this package. */ 56 | #undef PACKAGE_URL 57 | 58 | /* Define to the version of this package. */ 59 | #undef PACKAGE_VERSION 60 | 61 | /* Define to necessary symbol if this constant uses a non-standard name on 62 | your system. */ 63 | #undef PTHREAD_CREATE_JOINABLE 64 | 65 | /* Define to 1 if you have the ANSI C header files. */ 66 | #undef STDC_HEADERS 67 | 68 | /* Version number of package */ 69 | #undef VERSION 70 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/codegear/gtest_link.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Links gtest.lib and gtest_main.lib into the current project in C++Builder. 35 | // This means that these libraries can't be renamed, but it's the only way to 36 | // ensure that Debug versus Release test builds are linked against the 37 | // appropriate Debug or Release build of the libraries. 38 | 39 | #pragma link "gtest.lib" 40 | #pragma link "gtest_main.lib" 41 | -------------------------------------------------------------------------------- /src/symbols.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SYMBOLS_HPP 2 | #define SYMBOLS_HPP 3 | 4 | #ifdef UNIT_TESTS 5 | #include 6 | #endif 7 | 8 | #define CEXIT_SUCCESS " "; 9 | 10 | #include "abstract_symbol.hpp" 11 | #include "structures/capabilities.hpp" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | class AbstractSegments; 19 | 20 | class Symbols 21 | { 22 | public: 23 | Symbols(); 24 | ~Symbols(); 25 | 26 | void createSymbols(const char *p_data, boost::uint64_t p_dataSize, boost::uint64_t p_symTabOffset, 27 | boost::uint32_t p_symTabSize, boost::uint64_t p_strTabOffset, boost::uint64_t p_strTableSize, 28 | const AbstractSegments &p_segments, bool p_is64, bool p_isLE, bool p_isDY); 29 | 30 | const std::vector &getSymbols() const; 31 | 32 | // find a symbol based on a passed in address 33 | std::string findSymbol(boost::uint64_t p_address) const; 34 | 35 | // return the set of files found in the symbols 36 | std::set getFiles() const; 37 | 38 | /* 39 | * calls into the various segments for evaluation / scoring information. 40 | * p_reasons stores the scoring and reasons 41 | * p_capabilities stores information about what the binary does 42 | */ 43 | void evaluate(std::vector> &p_reasons, 44 | std::map> &p_capabilities) const; 45 | 46 | std::string printToStdOut() const; 47 | 48 | private: 49 | #ifdef UNIT_TESTS 50 | FRIEND_TEST(LSTest, Sixtyfour_Intel_ls); 51 | FRIEND_TEST(LSTest, Thirtytwo_Intel_ls); 52 | FRIEND_TEST(LSTest, Thirtytwo_Arm_ls); 53 | #endif 54 | 55 | //! indicates if the executable is an executable 56 | bool m_isDY; 57 | 58 | //! Contains a vector 59 | std::vector m_symbols; 60 | 61 | //! Contains the file names listed in the symbols 62 | std::set m_files; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_xml_outfile1_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyOne : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 1); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 1); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyOne, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 1); 49 | } 50 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_xml_outfile2_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyTwo : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 2); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 2); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyTwo, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 2); 49 | } 50 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/codegear/gtest.groupproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | {c1d923e0-6cba-4332-9b6f-3420acbf5091} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Default.Personality 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/abstract_programheader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACT_PROGRAM_HEADER_HPP 2 | #define ABSTRACT_PROGRAM_HEADER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace elf 9 | { 10 | struct program_header_32; 11 | struct program_header_64; 12 | } 13 | 14 | class AbstractProgramHeader 15 | { 16 | private: 17 | 18 | // disable evil things 19 | //AbstractProgramHeader& operator=(const AbstractProgramHeader& p_rhs); 20 | 21 | //! This program header in 32 bit format 22 | const elf::program_header_32* m_program_header32; 23 | 24 | //! This program header in 64 bit format 25 | const elf::program_header_64* m_program_header64; 26 | 27 | //! Indicates if the binary is 64 bit or not 28 | bool m_is64; 29 | 30 | //! Indicates if the bnary is LE or not 31 | bool m_isLE; 32 | 33 | public: 34 | 35 | /* 36 | * stores the program information in a way that is hidden from aller 37 | * p_data a pointer to the first entry 38 | * p_count the number of expected entries 39 | * p_size the expected size of a single entry 40 | * p_is64 indicates if the binary is 64 bit or 32 bit 41 | * p_isLE indicates if the binary is little endian 42 | */ 43 | AbstractProgramHeader(const char* p_data, boost::uint16_t p_size, bool p_is64, bool p_isLE); 44 | ~AbstractProgramHeader(); 45 | AbstractProgramHeader(const AbstractProgramHeader& p_rhs); 46 | 47 | bool is64() const; 48 | bool isLE() const; 49 | bool isExecutable() const; 50 | bool isWritable() const; 51 | std::string getFlagsString() const; 52 | std::string getName() const; 53 | boost::uint32_t getType() const; 54 | boost::uint64_t getOffset() const; 55 | boost::uint64_t getVirtualAddress() const; 56 | std::string getVirtualAddressString() const; 57 | boost::uint64_t getPhysicalAddress() const; 58 | std::string getPhysicalAddressString() const; 59 | boost::uint64_t getFileSize() const; 60 | boost::uint64_t getMemorySize() const; 61 | boost::uint32_t getFlags() const; 62 | 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/segment_types/strtable_segment.cpp: -------------------------------------------------------------------------------- 1 | #include "strtable_segment.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifndef WINDOWS 8 | #include 9 | #endif 10 | 11 | StringTableSegment::StringTableSegment(const char* start, 12 | boost::uint32_t p_offset, 13 | boost::uint32_t p_size, 14 | elf::section_type p_type) : 15 | SegmentType(start, p_offset, p_size, p_type), 16 | m_stringsSet(), 17 | m_start(start + p_offset) 18 | { 19 | const char* import_function = start + p_offset + 1; 20 | for (size_t i = 0; i < p_size; ) 21 | { 22 | std::size_t length = strlen(import_function); 23 | if ((i + length) > p_size) 24 | { 25 | break; 26 | } 27 | std::string imported(import_function, length); 28 | m_stringsSet.insert(imported); 29 | i += length + 1; 30 | import_function += length + 1; 31 | } 32 | } 33 | 34 | StringTableSegment::~StringTableSegment() 35 | { 36 | } 37 | 38 | std::size_t StringTableSegment::getSize() const 39 | { 40 | return m_stringsSet.size(); 41 | } 42 | 43 | std::string StringTableSegment::stringLookup(std::size_t p_index) const 44 | { 45 | #ifndef WINDOWS 46 | char* unmangled = NULL; 47 | size_t length = 0; 48 | int status = 0; 49 | unmangled = abi::__cxa_demangle(m_start + p_index, unmangled, 50 | &length, &status); 51 | if (unmangled != NULL) 52 | { 53 | std::string fixed(unmangled); 54 | free(unmangled); 55 | return fixed; 56 | } 57 | #endif 58 | return std::string(m_start + p_index); 59 | } 60 | 61 | std::string StringTableSegment::printToStdOut() const 62 | { 63 | std::stringstream return_value; 64 | return_value << "String Table (offset= 0x" << std::hex << m_offset 65 | << ", size= " << std::dec << m_size << ", entries= " << m_stringsSet.size() << std::endl; 66 | 67 | BOOST_FOREACH(const std::string& p_ascii, m_stringsSet) 68 | { 69 | return_value << "String= " << p_ascii << std::endl; 70 | } 71 | 72 | return return_value.str(); 73 | } 74 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include 33 | 34 | #include "test/gtest-typed-test_test.h" 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | // Tests that the same type-parameterized test case can be 40 | // instantiated in different translation units linked together. 41 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 42 | INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest, 43 | testing::Types >); 44 | 45 | #endif // GTEST_HAS_TYPED_TEST_P 46 | -------------------------------------------------------------------------------- /src/ui/QHexView-ng.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file QHexView.cpp 3 | * @author VitorMob 2022 4 | * @date 15 Mar 2022 5 | * @copyright 2022 VitorMob, 2015 virinext 6 | * @brief simple hex view / editor 7 | */ 8 | 9 | #ifdef QT_GUI 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | // config colors 19 | #if _WIN32 || _WIN64 20 | // config font 21 | #define FONT "Courier" 22 | #define SIZE_FONT 10 23 | #define COLOR_CHARACTERS Qt::black 24 | #define COLOR_SELECTION 98, 114, 164, 0xff 25 | #define COLOR_ADDRESS 240, 240, 240, 0xff 26 | #else 27 | // config font 28 | #define FONT "Courier" 29 | #define SIZE_FONT 12 30 | #define COLOR_SELECTION 98, 114, 164, 0xff 31 | #define COLOR_ADDRESS 30, 30, 30, 0xff 32 | #define COLOR_CHARACTERS Qt::white 33 | #endif 34 | 35 | // config lines 36 | #define MIN_HEXCHARS_IN_LINE 47 37 | #define GAP_ADR_HEX 10 38 | #define GAP_HEX_ASCII 16 39 | #define MIN_BYTES_PER_LINE 16 40 | #define ADR_LENGTH 10 41 | 42 | 43 | class QHexView: public QAbstractScrollArea 44 | 45 | { 46 | Q_OBJECT 47 | public: 48 | QHexView ( QWidget *parent = nullptr ); 49 | ~QHexView(); 50 | 51 | 52 | protected: 53 | void paintEvent ( QPaintEvent *event ); 54 | void keyPressEvent ( QKeyEvent *event ); 55 | void mouseMoveEvent ( QMouseEvent *event ); 56 | void mousePressEvent ( QMouseEvent *event ); 57 | 58 | private: 59 | QByteArray m_pdata; 60 | 61 | int m_posAddr, 62 | m_posHex, 63 | m_posAscii, 64 | m_charWidth, 65 | m_charHeight, 66 | m_selectBegin, 67 | m_selectEnd, 68 | m_selectInit, 69 | m_cursorPos, 70 | m_bytesPerLine; 71 | 72 | QSize fullSize() const; 73 | void updatePositions(); 74 | void resetSelection(); 75 | void resetSelection ( int pos ); 76 | void setSelection ( int pos ); 77 | void ensureVisible(); 78 | void setCursorPos ( int pos ); 79 | int cursorPos ( const QPoint &position ); 80 | void confScrollBar(); 81 | QByteArray getData ( int position, int length ); 82 | 83 | public slots: 84 | int loadFile ( QString p_file ); 85 | void clear(); 86 | void showFromOffset ( int offset ); 87 | void setSelected ( int offset, int length ); 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /src/ui/mainwindow.hpp: -------------------------------------------------------------------------------- 1 | #ifdef QT_GUI 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "QHexView-ng.hpp" 18 | 19 | namespace Ui 20 | { 21 | class MainWindow; 22 | } 23 | 24 | class ELFParser; 25 | class QTableWidgetItem; 26 | class QTreeWidgetItem; 27 | 28 | class MainWindow : public QMainWindow 29 | { 30 | Q_OBJECT 31 | 32 | private: 33 | // The main window that is created by mainwindow.ui 34 | Ui::MainWindow *m_ui; 35 | 36 | // The dialog window 37 | boost::scoped_ptr m_dialog; 38 | 39 | // All the allocated Table values 40 | boost::ptr_vector m_tableItems; 41 | 42 | // All the allocated Tree values 43 | boost::ptr_vector m_treeItems; 44 | 45 | // The reusable copy action 46 | boost::scoped_ptr m_copyAction; 47 | 48 | // The reusable ELF parser 49 | boost::scoped_ptr m_parser; 50 | 51 | // The resuable Editor Hex 52 | QHexView *m_HexEditor; 53 | 54 | // split window 55 | QVBoxLayout *m_layout; 56 | 57 | // path name 58 | QString m_FileName; 59 | 60 | // entropy config 61 | double m_Entropy; 62 | double m_VEntropy; 63 | public: 64 | explicit MainWindow ( QWidget *parent = 0 ); 65 | ~MainWindow(); 66 | 67 | 68 | public slots: 69 | void openFile(); 70 | void parser ( QString filename ); 71 | 72 | void sectionSelected ( QTableWidgetItem *, QTableWidgetItem * ); 73 | void programSelected ( QTableWidgetItem *, QTableWidgetItem * ); 74 | 75 | void on_gotoOffsetButton_triggered(); 76 | void overviewToClipboard(); 77 | void on_aboutButton_triggered(); 78 | void on_reparseButton_triggered(); 79 | void on_FullScreenButton_triggered(); 80 | void conf_buttons(); 81 | void conf_tables(); 82 | void on_openButton_triggered(); 83 | void on_EntroyLimitButton_triggered(); 84 | void on_reportButton_triggered(); 85 | void on_newButton_triggered(); 86 | void on_helpButton_triggered(); 87 | 88 | }; 89 | 90 | #endif //! QT_GUI -------------------------------------------------------------------------------- /lib/gtest-1.6.0/samples/sample4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE4_H_ 35 | #define GTEST_SAMPLES_SAMPLE4_H_ 36 | 37 | // A simple monotonic counter. 38 | class Counter { 39 | private: 40 | int counter_; 41 | 42 | public: 43 | // Creates a counter that starts at 0. 44 | Counter() : counter_(0) {} 45 | 46 | // Returns the current counter value, and increments it. 47 | int Increment(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GTEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_help_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | // This program is meant to be run by gtest_help_test.py. Do not run 33 | // it directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | // When a help flag is specified, this program should skip the tests 38 | // and exit with 0; otherwise the following test will be executed, 39 | // causing this program to exit with a non-zero code. 40 | TEST(HelpFlagTest, ShouldNotBeRun) { 41 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 42 | } 43 | 44 | #if GTEST_HAS_DEATH_TEST 45 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 46 | #endif 47 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build Google Test by compiling a single file. 35 | // This file serves this purpose. 36 | 37 | // This line ensures that gtest.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gtest/gtest.h" 40 | 41 | // The following lines pull in the real gtest *.cc files. 42 | #include "src/gtest.cc" 43 | #include "src/gtest-death-test.cc" 44 | #include "src/gtest-filepath.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | -------------------------------------------------------------------------------- /src/programheaders.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROGRAM_HEADERS_HPP 2 | #define PROGRAM_HEADERS_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef UNIT_TESTS 9 | #include 10 | #endif 11 | 12 | class AbstractSegments; 13 | class AbstractProgramHeader; 14 | 15 | /*! 16 | * Parses the program header and contains the list of headers. 17 | * Passes information to AbstractSegments in order to create segments. 18 | */ 19 | class ProgramHeaders 20 | { 21 | public: 22 | 23 | //! Default initialize the member variables 24 | ProgramHeaders(); 25 | 26 | //! Nothing of note 27 | ~ProgramHeaders(); 28 | 29 | /*! 30 | * Parses the program header and stores entries in the program headers vector. 31 | * \param[in] p_data a pointer to the first entry 32 | * \param[in] p_count the number of expected entries 33 | * \param[in] p_size the expected size of a single entry 34 | * \param[in] p_is64 indicates if the binary is 64 bit or 32 bit 35 | * \param[in] p_isLE indicates if we are operating on a LE binary 36 | */ 37 | void setHeaders(const char* p_data, boost::uint16_t p_count, 38 | boost::uint16_t p_size, bool p_is64, bool p_isLE); 39 | 40 | /*! 41 | * Passes program header information into AbstractSegments for segment creation 42 | * \param[in,out] p_segments the segment object we'll pass info to 43 | */ 44 | void extractSegments(AbstractSegments& p_segments); 45 | 46 | /*! 47 | * Scores the binary based on the entries that we expect to see 48 | * and the entries that are actually present. 49 | * \param[in,out] p_reasons store score / reason here 50 | */ 51 | void evaluate(std::vector >& p_reasons) const; 52 | 53 | //! \return the program header vector 54 | const std::vector& getProgramHeaders() const; 55 | 56 | //! \return a string representation of the program header 57 | std::string printToStdOut() const; 58 | 59 | private: 60 | 61 | // disable evil things 62 | ProgramHeaders(const ProgramHeaders& p_rhs); 63 | ProgramHeaders& operator=(const ProgramHeaders& p_rhs); 64 | 65 | private: 66 | 67 | //! A list of the entries in the program header 68 | std::vector m_programHeaders; 69 | }; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/production.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #ifndef GTEST_TEST_PRODUCTION_H_ 35 | #define GTEST_TEST_PRODUCTION_H_ 36 | 37 | #include "gtest/gtest_prod.h" 38 | 39 | class PrivateCode { 40 | public: 41 | // Declares a friend test that does not use a fixture. 42 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 43 | 44 | // Declares a friend test that uses a fixture. 45 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 46 | 47 | PrivateCode(); 48 | 49 | int x() const { return x_; } 50 | private: 51 | void set_x(int an_x) { x_ = an_x; } 52 | int x_; 53 | }; 54 | 55 | #endif // GTEST_TEST_PRODUCTION_H_ 56 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Tests for Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build most of Google Test's own tests 35 | // by compiling a single file. This file serves this purpose. 36 | #include "test/gtest-filepath_test.cc" 37 | #include "test/gtest-linked_ptr_test.cc" 38 | #include "test/gtest-message_test.cc" 39 | #include "test/gtest-options_test.cc" 40 | #include "test/gtest-port_test.cc" 41 | #include "test/gtest_pred_impl_unittest.cc" 42 | #include "test/gtest_prod_test.cc" 43 | #include "test/gtest-test-part_test.cc" 44 | #include "test/gtest-typed-test_test.cc" 45 | #include "test/gtest-typed-test2_test.cc" 46 | #include "test/gtest_unittest.cc" 47 | #include "test/production.cc" 48 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_prod_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "gtest/gtest.h" 35 | #include "test/production.h" 36 | 37 | // Tests that private members can be accessed from a TEST declared as 38 | // a friend of the class. 39 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 40 | PrivateCode a; 41 | EXPECT_EQ(0, a.x_); 42 | 43 | a.set_x(1); 44 | EXPECT_EQ(1, a.x_); 45 | } 46 | 47 | typedef testing::Test PrivateCodeFixtureTest; 48 | 49 | // Tests that private members can be accessed from a TEST_F declared 50 | // as a friend of the class. 51 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 52 | PrivateCode a; 53 | EXPECT_EQ(0, a.x_); 54 | 55 | a.set_x(2); 56 | EXPECT_EQ(2, a.x_); 57 | } 58 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_sole_header_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // This test verifies that it's possible to use Google Test by including 33 | // the gtest.h header file alone. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | void Subroutine() { 40 | EXPECT_EQ(42, 42); 41 | } 42 | 43 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 44 | EXPECT_NO_FATAL_FAILURE(;); 45 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 46 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 47 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 48 | } 49 | 50 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 51 | ASSERT_NO_FATAL_FAILURE(;); 52 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 53 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 54 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 55 | } 56 | 57 | } // namespace 58 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/samples/sample2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample2.h" 35 | 36 | #include 37 | 38 | // Clones a 0-terminated C string, allocating memory using new. 39 | const char* MyString::CloneCString(const char* a_c_string) { 40 | if (a_c_string == NULL) return NULL; 41 | 42 | const size_t len = strlen(a_c_string); 43 | char* const clone = new char[ len + 1 ]; 44 | memcpy(clone, a_c_string, len + 1); 45 | 46 | return clone; 47 | } 48 | 49 | // Sets the 0-terminated C string this MyString object 50 | // represents. 51 | void MyString::Set(const char* a_c_string) { 52 | // Makes sure this works when c_string == c_string_ 53 | const char* const temp = MyString::CloneCString(a_c_string); 54 | delete[] c_string_; 55 | c_string_ = temp; 56 | } 57 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Samples/FrameworkSample/widget.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.h 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest. It 37 | // simply stores two values a string and an integer, which are returned via 38 | // public accessors in multiple forms. 39 | 40 | #import 41 | 42 | class Widget { 43 | public: 44 | Widget(int number, const std::string& name); 45 | ~Widget(); 46 | 47 | // Public accessors to number data 48 | float GetFloatValue() const; 49 | int GetIntValue() const; 50 | 51 | // Public accessors to the string data 52 | std::string GetStringValue() const; 53 | void GetCharPtrValue(char* buffer, size_t max_size) const; 54 | 55 | private: 56 | // Data members 57 | float number_; 58 | std::string name_; 59 | }; 60 | -------------------------------------------------------------------------------- /src/segment_types/segment_type.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SEGMENTTYPE_HPP 2 | #define SEGMENTTYPE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../structures/sectionheader.hpp" 11 | #include "../structures/capabilities.hpp" 12 | 13 | /* 14 | * the segment pure virtual base class. abstracts away some basic things like 15 | * size and offset. future uses includes entropy and hashing. 16 | */ 17 | class SegmentType 18 | { 19 | protected: 20 | // The type of underlying segment 21 | elf::section_type m_type; 22 | 23 | // The offset to this segment 24 | boost::uint32_t m_offset; 25 | 26 | // The size of this segment 27 | boost::uint32_t m_size; 28 | 29 | // A pointer to a string segment 30 | SegmentType *m_strings; 31 | 32 | public: 33 | /* 34 | * initializes the member variables 35 | * p_start a pointer to the start of the mmaped file 36 | * p_offset the offset to this segment 37 | * p_size the size of this segment 38 | * p_type the type of segment being created 39 | * p_start is currently not used, but is there for future use 40 | */ 41 | SegmentType(const char *p_start, boost::uint32_t p_offset, 42 | boost::uint32_t p_size, elf::section_type p_type); 43 | 44 | virtual ~SegmentType(); 45 | 46 | // return the type of this segment 47 | elf::section_type getType() const; 48 | 49 | // return the offset to this segment 50 | boost::uint32_t getOffset() const; 51 | 52 | /* 53 | * stores this segments corresponding string table if one exists and the 54 | * segment needs to make use of it 55 | * p_strSegment a pointer to a StringTableSegment 56 | */ 57 | void setStrSegment(SegmentType *p_strSegment); 58 | 59 | /*! 60 | * The default evaluate function. Segments that wish to contribute to the 61 | * scoring override this 62 | * unused the reasons vector 63 | * unused the capabilities vector 64 | */ 65 | virtual void evaluate(std::vector> &, 66 | std::map> &) const 67 | { 68 | } 69 | 70 | //! Every segment must have a function that creates a string representation 71 | virtual std::string printToStdOut() const = 0; 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/msvc/gtest.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "gtest.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main", "gtest_main.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862032}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest", "gtest_unittest.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test", "gtest_prod_test.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32 32 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32 33 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32 34 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32 35 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32 36 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32 37 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32 38 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32 39 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Testing Framework definitions useful in production code. 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void MyMethod(); 44 | // FRIEND_TEST(MyClassTest, MyMethod); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, MyMethod) { 52 | // // Can call MyClass::MyMethod() here. 53 | // } 54 | 55 | #define FRIEND_TEST(test_case_name, test_name)\ 56 | friend class test_case_name##_##test_name##_Test 57 | 58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 59 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest-param-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Authors: vladl@google.com (Vlad Losev) 31 | // 32 | // The Google C++ Testing Framework (Google Test) 33 | // 34 | // This header file provides classes and functions used internally 35 | // for testing Google Test itself. 36 | 37 | #ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 38 | #define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 39 | 40 | #include "gtest/gtest.h" 41 | 42 | #if GTEST_HAS_PARAM_TEST 43 | 44 | // Test fixture for testing definition and instantiation of a test 45 | // in separate translation units. 46 | class ExternalInstantiationTest : public ::testing::TestWithParam {}; 47 | 48 | // Test fixture for testing instantiation of a test in multiple 49 | // translation units. 50 | class InstantiationInMultipleTranslaionUnitsTest 51 | : public ::testing::TestWithParam {}; 52 | 53 | #endif // GTEST_HAS_PARAM_TEST 54 | 55 | #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 56 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/msvc/gtest-md.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-md", "gtest-md.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main-md", "gtest_main-md.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862033}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test-md", "gtest_prod_test-md.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest-md", "gtest_unittest-md.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.Build.0 = Release|Win32 32 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.ActiveCfg = Debug|Win32 33 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.Build.0 = Debug|Win32 34 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.ActiveCfg = Release|Win32 35 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.Build.0 = Release|Win32 36 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.ActiveCfg = Debug|Win32 37 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.Build.0 = Debug|Win32 38 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.ActiveCfg = Release|Win32 39 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Samples/FrameworkSample/widget.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.cc 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest 37 | 38 | #include "widget.h" 39 | 40 | Widget::Widget(int number, const std::string& name) 41 | : number_(number), 42 | name_(name) {} 43 | 44 | Widget::~Widget() {} 45 | 46 | float Widget::GetFloatValue() const { 47 | return number_; 48 | } 49 | 50 | int Widget::GetIntValue() const { 51 | return static_cast(number_); 52 | } 53 | 54 | std::string Widget::GetStringValue() const { 55 | return name_; 56 | } 57 | 58 | void Widget::GetCharPtrValue(char* buffer, size_t max_size) const { 59 | // Copy the char* representation of name_ into buffer, up to max_size. 60 | strncpy(buffer, name_.c_str(), max_size-1); 61 | buffer[max_size-1] = '\0'; 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Samples/FrameworkSample/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=$@ 40 | 41 | # Now execute each one in turn keeping track of how many succeeded and failed. 42 | succeeded=0 43 | failed=0 44 | failed_list=() 45 | for test in ${test_executables[*]}; do 46 | "$test" 47 | result=$? 48 | if [ $result -eq 0 ]; then 49 | succeeded=$(( $succeeded + 1 )) 50 | else 51 | failed=$(( failed + 1 )) 52 | failed_list="$failed_list $test" 53 | fi 54 | done 55 | 56 | # Report the successes and failures to the console. 57 | echo "Tests complete with $succeeded successes and $failed failures." 58 | if [ $failed -ne 0 ]; then 59 | echo "The following tests failed:" 60 | echo $failed_list 61 | fi 62 | exit $failed 63 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_no_test_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Tests that a Google Test program that has no test defined can run 31 | // successfully. 32 | // 33 | // Author: wan@google.com (Zhanyong Wan) 34 | 35 | #include "gtest/gtest.h" 36 | 37 | 38 | int main(int argc, char **argv) { 39 | testing::InitGoogleTest(&argc, argv); 40 | 41 | // An ad-hoc assertion outside of all tests. 42 | // 43 | // This serves three purposes: 44 | // 45 | // 1. It verifies that an ad-hoc assertion can be executed even if 46 | // no test is defined. 47 | // 2. It verifies that a failed ad-hoc assertion causes the test 48 | // program to fail. 49 | // 3. We had a bug where the XML output won't be generated if an 50 | // assertion is executed before RUN_ALL_TESTS() is called, even 51 | // though --gtest_output=xml is specified. This makes sure the 52 | // bug is fixed and doesn't regress. 53 | EXPECT_EQ(1, 2); 54 | 55 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero. 56 | return RUN_ALL_TESTS() ? 0 : 1; 57 | } 58 | -------------------------------------------------------------------------------- /src/dynamicsection.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DYNAMICSECTION_HPP 2 | #define DYNAMICSECTION_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "abstract_dynamic.hpp" 11 | #include "structures/capabilities.hpp" 12 | 13 | namespace elf 14 | { 15 | namespace dynamic 16 | { 17 | struct dynamic_32; 18 | struct dynamic_64; 19 | } 20 | } 21 | 22 | class AbstractSegments; 23 | 24 | class DynamicSection 25 | { 26 | public: 27 | DynamicSection(); 28 | ~DynamicSection(); 29 | 30 | void createDynamic(const char* p_start, boost::uint32_t p_offset, 31 | boost::uint32_t p_size, boost::uint64_t p_baseAddress, 32 | bool p_is64, bool p_isLE, const AbstractSegments& p_segments); 33 | 34 | boost::uint64_t getOffset() const; 35 | boost::uint64_t getSymbolTableVirtAddress() const; 36 | boost::uint64_t getStringTableVirtualAddress() const; 37 | boost::uint64_t getStringTableSize() const; 38 | boost::uint32_t getSymbolTableSize() const; 39 | boost::uint64_t getInitArray() const; 40 | boost::uint32_t getInitArrayEntries() const; 41 | 42 | /*! 43 | * Calls into the various segments for evaluation / scoring information. 44 | * \param[in,out] p_reasons stores the scoring and reasons 45 | * \param[in,out] p_capabilities stores information about what the binary does 46 | */ 47 | void evaluate(std::vector >& p_reasons, 48 | std::map >& p_capabilities) const; 49 | 50 | std::string printToStdOut() const; 51 | 52 | private: 53 | 54 | void doDynamic64(const elf::dynamic::dynamic_64* p_dynamic, 55 | const char* p_start, const char* p_end, 56 | boost::uint64_t p_baseAddress, bool p_isLE); 57 | void doDynamic32(const elf::dynamic::dynamic_32* p_dynamic, 58 | const char* p_start, const char* p_end, 59 | boost::uint64_t p_baseAddress, bool p_isLE); 60 | 61 | private: 62 | 63 | //! Disable evil things 64 | DynamicSection(const DynamicSection& p_rhs); 65 | DynamicSection& operator=(const DynamicSection& p_rhs); 66 | 67 | private: 68 | 69 | boost::uint64_t m_offset; 70 | boost::uint64_t m_symbolTableVirtAddress; 71 | boost::uint64_t m_stringTableVirtAddress; 72 | boost::uint64_t m_stringTableSize; 73 | boost::uint32_t m_symbolTableSize; 74 | boost::uint64_t m_initArrayVirtAddress; 75 | boost::uint32_t m_initArrayEntries; 76 | std::vector m_entries; 77 | uint32_t m_fileSize; 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest-typed-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 33 | #define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 34 | 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | using testing::Test; 40 | 41 | // For testing that the same type-parameterized test case can be 42 | // instantiated in different translation units linked together. 43 | // ContainerTest will be instantiated in both gtest-typed-test_test.cc 44 | // and gtest-typed-test2_test.cc. 45 | 46 | template 47 | class ContainerTest : public Test { 48 | }; 49 | 50 | TYPED_TEST_CASE_P(ContainerTest); 51 | 52 | TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) { 53 | TypeParam container; 54 | } 55 | 56 | TYPED_TEST_P(ContainerTest, InitialSizeIsZero) { 57 | TypeParam container; 58 | EXPECT_EQ(0U, container.size()); 59 | } 60 | 61 | REGISTER_TYPED_TEST_CASE_P(ContainerTest, 62 | CanBeDefaultConstructed, InitialSizeIsZero); 63 | 64 | #endif // GTEST_HAS_TYPED_TEST_P 65 | 66 | #endif // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 67 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/samples/sample1.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample1.h" 35 | 36 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 37 | int Factorial(int n) { 38 | int result = 1; 39 | for (int i = 1; i <= n; i++) { 40 | result *= i; 41 | } 42 | 43 | return result; 44 | } 45 | 46 | // Returns true iff n is a prime number. 47 | bool IsPrime(int n) { 48 | // Trivial case 1: small numbers 49 | if (n <= 1) return false; 50 | 51 | // Trivial case 2: even numbers 52 | if (n % 2 == 0) return n == 2; 53 | 54 | // Now, we have that n is odd and n >= 3. 55 | 56 | // Try to divide n by every odd number i, starting from 3 57 | for (int i = 3; ; i += 2) { 58 | // We only have to try i up to the squre root of n 59 | if (i > n/i) break; 60 | 61 | // Now, we have i <= n/i < n. 62 | // If n is divisible by i, n is not prime. 63 | if (n % i == 0) return false; 64 | } 65 | 66 | // n has no integer factor in the range (1, n), and thus is prime. 67 | return true; 68 | } 69 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_throw_on_failure_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | // Tests Google Test's throw-on-failure mode with exceptions disabled. 33 | // 34 | // This program must be compiled with exceptions disabled. It will be 35 | // invoked by gtest_throw_on_failure_test.py, and is expected to exit 36 | // with non-zero in the throw-on-failure mode or 0 otherwise. 37 | 38 | #include "gtest/gtest.h" 39 | 40 | int main(int argc, char** argv) { 41 | testing::InitGoogleTest(&argc, argv); 42 | 43 | // We want to ensure that people can use Google Test assertions in 44 | // other testing frameworks, as long as they initialize Google Test 45 | // properly and set the thrown-on-failure mode. Therefore, we don't 46 | // use Google Test's constructs for defining and running tests 47 | // (e.g. TEST and RUN_ALL_TESTS) here. 48 | 49 | // In the throw-on-failure mode with exceptions disabled, this 50 | // assertion will cause the program to exit with a non-zero code. 51 | EXPECT_EQ(2, 3); 52 | 53 | // When not in the throw-on-failure mode, the control will reach 54 | // here. 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_uninitialized_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | """Verifies that Google Test warns the user when not initialized properly.""" 33 | 34 | __author__ = 'wan@google.com (Zhanyong Wan)' 35 | 36 | import gtest_test_utils 37 | 38 | 39 | COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_') 40 | 41 | 42 | def Assert(condition): 43 | if not condition: 44 | raise AssertionError 45 | 46 | 47 | def AssertEq(expected, actual): 48 | if expected != actual: 49 | print 'Expected: %s' % (expected,) 50 | print ' Actual: %s' % (actual,) 51 | raise AssertionError 52 | 53 | 54 | def TestExitCodeAndOutput(command): 55 | """Runs the given command and verifies its exit code and output.""" 56 | 57 | # Verifies that 'command' exits with code 1. 58 | p = gtest_test_utils.Subprocess(command) 59 | Assert(p.exited) 60 | AssertEq(1, p.exit_code) 61 | Assert('InitGoogleTest' in p.output) 62 | 63 | 64 | class GTestUninitializedTest(gtest_test_utils.TestCase): 65 | def testExitCodeAndOutput(self): 66 | TestExitCodeAndOutput(COMMAND) 67 | 68 | 69 | if __name__ == '__main__': 70 | gtest_test_utils.Main() 71 | -------------------------------------------------------------------------------- /src/abstract_sectionheader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACT_SECTION_HEADER_HPP 2 | #define ABSTRACT_SECTION_HEADER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef UNIT_TESTS 9 | #include 10 | #endif 11 | 12 | namespace elf 13 | { 14 | struct section_header_32; 15 | struct section_header_64; 16 | } 17 | 18 | // abstracts away the BE vs LE and 32 bit vs 64 bit stuff 19 | class AbstractSectionHeader 20 | { 21 | private: 22 | 23 | // a reference to the list of section headers 24 | const std::vector& m_sections; 25 | 26 | // this section header in 32 bit format 27 | const elf::section_header_32* m_section_header32; 28 | 29 | // this section header in 64 bit format 30 | const elf::section_header_64* m_section_header64; 31 | 32 | // the start of the file in memory 33 | const char* m_fileStart; 34 | 35 | // the size of the file in memory 36 | boost::uint64_t m_size; 37 | 38 | // index of the string table 39 | boost::uint8_t m_strIndex; 40 | 41 | // indicates if the binary is 64 bit or not 42 | bool m_is64; 43 | 44 | // indicates if the bnary is LE or not 45 | bool m_isLE; 46 | 47 | #ifdef UNIT_TESTS 48 | FRIEND_TEST(LSTest, Sixtyfour_Intel_ls); 49 | FRIEND_TEST(LSTest, Thirtytwo_Intel_ls); 50 | FRIEND_TEST(LSTest, Thirtytwo_Arm_ls); 51 | #endif 52 | 53 | public: 54 | 55 | AbstractSectionHeader(const char* p_data, boost::uint16_t p_size, 56 | const char* p_file, boost::uint64_t p_fileSize, 57 | boost::uint8_t p_strIndex, 58 | const std::vector& p_sections, 59 | bool p_is64, bool p_isLE); 60 | AbstractSectionHeader(const AbstractSectionHeader& p_rhs); 61 | 62 | // nothing of note 63 | ~AbstractSectionHeader(); 64 | 65 | bool is64() const; 66 | bool isLE() const; 67 | bool isExecutable() const; 68 | bool isWritable() const; 69 | std::string getName() const; 70 | std::string getTypeString() const; 71 | std::string getFlagsString() const; 72 | boost::uint32_t getType() const; 73 | boost::uint64_t getFlags() const; 74 | boost::uint64_t getVirtAddress() const; 75 | std::string getVirtAddressString() const; 76 | boost::uint64_t getPhysOffset() const; 77 | boost::uint64_t getSize() const; 78 | boost::uint32_t getLink() const; 79 | boost::uint32_t getInfo() const; 80 | boost::uint64_t getAddrAlign() const; 81 | boost::uint64_t getEntSize() const; 82 | 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_list_tests_unittest_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: phanna@google.com (Patrick Hanna) 31 | 32 | // Unit test for Google Test's --gtest_list_tests flag. 33 | // 34 | // A user can ask Google Test to list all tests that will run 35 | // so that when using a filter, a user will know what 36 | // tests to look for. The tests will not be run after listing. 37 | // 38 | // This program will be invoked from a Python unit test. 39 | // Don't run it directly. 40 | 41 | #include "gtest/gtest.h" 42 | 43 | namespace { 44 | 45 | // Several different test cases and tests that will be listed. 46 | TEST(Foo, Bar1) { 47 | } 48 | 49 | TEST(Foo, Bar2) { 50 | } 51 | 52 | TEST(Foo, DISABLED_Bar3) { 53 | } 54 | 55 | TEST(Abc, Xyz) { 56 | } 57 | 58 | TEST(Abc, Def) { 59 | } 60 | 61 | TEST(FooBar, Baz) { 62 | } 63 | 64 | class FooTest : public testing::Test { 65 | }; 66 | 67 | TEST_F(FooTest, Test1) { 68 | } 69 | 70 | TEST_F(FooTest, DISABLED_Test2) { 71 | } 72 | 73 | TEST_F(FooTest, Test3) { 74 | } 75 | 76 | TEST(FooDeathTest, Test1) { 77 | } 78 | 79 | } // namespace 80 | 81 | int main(int argc, char **argv) { 82 | ::testing::InitGoogleTest(&argc, argv); 83 | 84 | return RUN_ALL_TESTS(); 85 | } 86 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/configure.ac: -------------------------------------------------------------------------------- 1 | m4_include(m4/acx_pthread.m4) 2 | 3 | # At this point, the Xcode project assumes the version string will be three 4 | # integers separated by periods and surrounded by square brackets (e.g. 5 | # "[1.0.1]"). It also asumes that there won't be any closing parenthesis 6 | # between "AC_INIT(" and the closing ")" including comments and strings. 7 | AC_INIT([Google C++ Testing Framework], 8 | [1.6.0], 9 | [googletestframework@googlegroups.com], 10 | [gtest]) 11 | 12 | # Provide various options to initialize the Autoconf and configure processes. 13 | AC_PREREQ([2.59]) 14 | AC_CONFIG_SRCDIR([./COPYING]) 15 | AC_CONFIG_MACRO_DIR([m4]) 16 | AC_CONFIG_AUX_DIR([build-aux]) 17 | AC_CONFIG_HEADERS([build-aux/config.h]) 18 | AC_CONFIG_FILES([Makefile]) 19 | AC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config]) 20 | 21 | # Initialize Automake with various options. We require at least v1.9, prevent 22 | # pedantic complaints about package files, and enable various distribution 23 | # targets. 24 | AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects]) 25 | 26 | # Check for programs used in building Google Test. 27 | AC_PROG_CC 28 | AC_PROG_CXX 29 | AC_LANG([C++]) 30 | AC_PROG_LIBTOOL 31 | 32 | # TODO(chandlerc@google.com): Currently we aren't running the Python tests 33 | # against the interpreter detected by AM_PATH_PYTHON, and so we condition 34 | # HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's 35 | # version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env" 36 | # hashbang. 37 | PYTHON= # We *do not* allow the user to specify a python interpreter 38 | AC_PATH_PROG([PYTHON],[python],[:]) 39 | AS_IF([test "$PYTHON" != ":"], 40 | [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])]) 41 | AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"]) 42 | 43 | # Configure pthreads. 44 | AC_ARG_WITH([pthreads], 45 | [AS_HELP_STRING([--with-pthreads], 46 | [use pthreads (default is yes)])], 47 | [with_pthreads=$withval], 48 | [with_pthreads=check]) 49 | 50 | have_pthreads=no 51 | AS_IF([test "x$with_pthreads" != "xno"], 52 | [ACX_PTHREAD( 53 | [], 54 | [AS_IF([test "x$with_pthreads" != "xcheck"], 55 | [AC_MSG_FAILURE( 56 | [--with-pthreads was specified, but unable to be used])])]) 57 | have_pthreads="$acx_pthread_ok"]) 58 | AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" == "xyes"]) 59 | AC_SUBST(PTHREAD_CFLAGS) 60 | AC_SUBST(PTHREAD_LIBS) 61 | 62 | # TODO(chandlerc@google.com) Check for the necessary system headers. 63 | 64 | # TODO(chandlerc@google.com) Check the types, structures, and other compiler 65 | # and architecture characteristics. 66 | 67 | # Output the generated files. No further autoconf macros may be used. 68 | AC_OUTPUT 69 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Scripts/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=("$BUILT_PRODUCTS_DIR/gtest_unittest-framework" 40 | "$BUILT_PRODUCTS_DIR/gtest_unittest" 41 | "$BUILT_PRODUCTS_DIR/sample1_unittest-framework" 42 | "$BUILT_PRODUCTS_DIR/sample1_unittest-static") 43 | 44 | # Now execute each one in turn keeping track of how many succeeded and failed. 45 | succeeded=0 46 | failed=0 47 | failed_list=() 48 | for test in ${test_executables[*]}; do 49 | "$test" 50 | result=$? 51 | if [ $result -eq 0 ]; then 52 | succeeded=$(( $succeeded + 1 )) 53 | else 54 | failed=$(( failed + 1 )) 55 | failed_list="$failed_list $test" 56 | fi 57 | done 58 | 59 | # Report the successes and failures to the console. 60 | echo "Tests complete with $succeeded successes and $failed failures." 61 | if [ $failed -ne 0 ]; then 62 | echo "The following tests failed:" 63 | echo $failed_list 64 | fi 65 | exit $failed 66 | -------------------------------------------------------------------------------- /src/programheaders.cpp: -------------------------------------------------------------------------------- 1 | #include "programheaders.hpp" 2 | #include "abstract_segments.hpp" 3 | #include "abstract_programheader.hpp" 4 | #include "structures/programheader.hpp" 5 | 6 | #include 7 | #include 8 | 9 | ProgramHeaders::ProgramHeaders() : m_programHeaders() 10 | { 11 | } 12 | 13 | ProgramHeaders::~ProgramHeaders() 14 | { 15 | } 16 | 17 | void ProgramHeaders::setHeaders(const char *p_data, boost::uint16_t p_count, 18 | boost::uint16_t p_size, bool p_is64, bool p_isLE) 19 | { 20 | if (p_size == 0) 21 | exit(EXIT_FAILURE); 22 | 23 | for (std::size_t i = 0; i < p_count; ++i, p_data += p_size) 24 | m_programHeaders.emplace_back(p_data, p_size, p_is64, p_isLE); 25 | } 26 | 27 | void ProgramHeaders::extractSegments(AbstractSegments &p_segments) 28 | { 29 | BOOST_FOREACH (auto &header, m_programHeaders) 30 | p_segments.makeSegmentFromProgramHeader(header); 31 | } 32 | 33 | const std::vector &ProgramHeaders::getProgramHeaders() const 34 | { 35 | return m_programHeaders; 36 | } 37 | 38 | std::string ProgramHeaders::printToStdOut() const 39 | { 40 | std::stringstream returnValue; 41 | std::size_t size = m_programHeaders.size(); 42 | if (size > 0) 43 | { 44 | returnValue << "Program Header (count = " << size << ")\n"; 45 | 46 | BOOST_FOREACH (auto &header, m_programHeaders) 47 | { 48 | returnValue << "\t Entry type=" << header.getName() 49 | << "\t flags=" << std::dec << header.getFlags() 50 | << "\t offset=0x" << std::hex << header.getOffset() 51 | << "\t vaddr=0x" << header.getVirtualAddress() 52 | << "\t paddr=0x" << header.getPhysicalAddress() 53 | << "\t filesz=0x" << header.getFileSize() 54 | << "\t memsz=0x" << header.getMemorySize() 55 | << std::dec << std::endl; 56 | } 57 | } 58 | 59 | return returnValue.str(); 60 | } 61 | 62 | void ProgramHeaders::evaluate(std::vector> &p_reasons) const 63 | { 64 | bool found_load = false; 65 | std::size_t entry_count = 0; 66 | std::size_t load_count = 0; 67 | 68 | BOOST_FOREACH (auto &header, m_programHeaders) 69 | { 70 | if (header.getType() == elf::k_pload) 71 | { 72 | ++load_count; 73 | found_load = true; 74 | } 75 | ++entry_count; 76 | } 77 | 78 | if (load_count > 2) 79 | p_reasons.push_back(std::make_pair(30, std::string("Found 2+ PT_LOAD. Possible post-compilation addition of code (cryptor or packer)"))); 80 | 81 | if (entry_count > 0 && !found_load) 82 | p_reasons.push_back(std::make_pair(5, std::string("Didn't find PT_LOAD in the program headers"))); 83 | } 84 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/make/Makefile: -------------------------------------------------------------------------------- 1 | # A sample Makefile for building Google Test and using it in user 2 | # tests. Please tweak it to suit your environment and project. You 3 | # may want to move it to your project's root directory. 4 | # 5 | # SYNOPSIS: 6 | # 7 | # make [all] - makes everything. 8 | # make TARGET - makes the given target. 9 | # make clean - removes all files generated by make. 10 | 11 | # Please tweak the following variable definitions as needed by your 12 | # project, except GTEST_HEADERS, which you can use in your own targets 13 | # but shouldn't modify. 14 | 15 | # Points to the root of Google Test, relative to where this file is. 16 | # Remember to tweak this if you move this file. 17 | GTEST_DIR = .. 18 | 19 | # Where to find user code. 20 | USER_DIR = ../samples 21 | 22 | # Flags passed to the preprocessor. 23 | CPPFLAGS += -I$(GTEST_DIR)/include 24 | 25 | # Flags passed to the C++ compiler. 26 | CXXFLAGS += -g -Wall -Wextra 27 | 28 | # All tests produced by this Makefile. Remember to add new tests you 29 | # created to the list. 30 | TESTS = sample1_unittest 31 | 32 | # All Google Test headers. Usually you shouldn't change this 33 | # definition. 34 | GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ 35 | $(GTEST_DIR)/include/gtest/internal/*.h 36 | 37 | # House-keeping build targets. 38 | 39 | all : $(TESTS) 40 | 41 | clean : 42 | rm -f $(TESTS) gtest.a gtest_main.a *.o 43 | 44 | # Builds gtest.a and gtest_main.a. 45 | 46 | # Usually you shouldn't tweak such internal variables, indicated by a 47 | # trailing _. 48 | GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) 49 | 50 | # For simplicity and to avoid depending on Google Test's 51 | # implementation details, the dependencies specified below are 52 | # conservative and not optimized. This is fine as Google Test 53 | # compiles fast and for ordinary users its source rarely changes. 54 | gtest-all.o : $(GTEST_SRCS_) 55 | $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ 56 | $(GTEST_DIR)/src/gtest-all.cc 57 | 58 | gtest_main.o : $(GTEST_SRCS_) 59 | $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ 60 | $(GTEST_DIR)/src/gtest_main.cc 61 | 62 | gtest.a : gtest-all.o 63 | $(AR) $(ARFLAGS) $@ $^ 64 | 65 | gtest_main.a : gtest-all.o gtest_main.o 66 | $(AR) $(ARFLAGS) $@ $^ 67 | 68 | # Builds a sample test. A test should link with either gtest.a or 69 | # gtest_main.a, depending on whether it defines its own main() 70 | # function. 71 | 72 | sample1.o : $(USER_DIR)/sample1.cc $(USER_DIR)/sample1.h $(GTEST_HEADERS) 73 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1.cc 74 | 75 | sample1_unittest.o : $(USER_DIR)/sample1_unittest.cc \ 76 | $(USER_DIR)/sample1.h $(GTEST_HEADERS) 77 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1_unittest.cc 78 | 79 | sample1_unittest : sample1.o sample1_unittest.o gtest_main.a 80 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ 81 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/xcode/Samples/FrameworkSample/widget_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget_test.cc 34 | // 35 | 36 | // This is a simple test file for the Widget class in the Widget.framework 37 | 38 | #include 39 | #include "gtest/gtest.h" 40 | 41 | #include 42 | 43 | // This test verifies that the constructor sets the internal state of the 44 | // Widget class correctly. 45 | TEST(WidgetInitializerTest, TestConstructor) { 46 | Widget widget(1.0f, "name"); 47 | EXPECT_FLOAT_EQ(1.0f, widget.GetFloatValue()); 48 | EXPECT_EQ(std::string("name"), widget.GetStringValue()); 49 | } 50 | 51 | // This test verifies the conversion of the float and string values to int and 52 | // char*, respectively. 53 | TEST(WidgetInitializerTest, TestConversion) { 54 | Widget widget(1.0f, "name"); 55 | EXPECT_EQ(1, widget.GetIntValue()); 56 | 57 | size_t max_size = 128; 58 | char buffer[max_size]; 59 | widget.GetCharPtrValue(buffer, max_size); 60 | EXPECT_STREQ("name", buffer); 61 | } 62 | 63 | // Use the Google Test main that is linked into the framework. It does something 64 | // like this: 65 | // int main(int argc, char** argv) { 66 | // testing::InitGoogleTest(&argc, argv); 67 | // return RUN_ALL_TESTS(); 68 | // } 69 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest-param-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: vladl@google.com (Vlad Losev) 31 | // 32 | // Tests for Google Test itself. This verifies that the basic constructs of 33 | // Google Test work. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | #include "test/gtest-param-test_test.h" 38 | 39 | #if GTEST_HAS_PARAM_TEST 40 | 41 | using ::testing::Values; 42 | using ::testing::internal::ParamGenerator; 43 | 44 | // Tests that generators defined in a different translation unit 45 | // are functional. The test using extern_gen is defined 46 | // in gtest-param-test_test.cc. 47 | ParamGenerator extern_gen = Values(33); 48 | 49 | // Tests that a parameterized test case can be defined in one translation unit 50 | // and instantiated in another. The test is defined in gtest-param-test_test.cc 51 | // and ExternalInstantiationTest fixture class is defined in 52 | // gtest-param-test_test.h. 53 | INSTANTIATE_TEST_CASE_P(MultiplesOf33, 54 | ExternalInstantiationTest, 55 | Values(33, 66)); 56 | 57 | // Tests that a parameterized test case can be instantiated 58 | // in multiple translation units. Another instantiation is defined 59 | // in gtest-param-test_test.cc and InstantiationInMultipleTranslaionUnitsTest 60 | // fixture is defined in gtest-param-test_test.h 61 | INSTANTIATE_TEST_CASE_P(Sequence2, 62 | InstantiationInMultipleTranslaionUnitsTest, 63 | Values(42*3, 42*4, 42*5)); 64 | 65 | #endif // GTEST_HAS_PARAM_TEST 66 | -------------------------------------------------------------------------------- /src/sectionheaders.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SECTIONHEADERS_HPP 2 | #define SECTIONHEADERS_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "structures/capabilities.hpp" 12 | 13 | class AbstractSegments; 14 | class AbstractSectionHeader; 15 | 16 | /*! 17 | * Parses the section header and contains the list of headers. 18 | * Passes information to AbstractSegments in order to create segments. 19 | */ 20 | class SectionHeaders 21 | { 22 | private: 23 | //! disable evil things 24 | SectionHeaders(const SectionHeaders &p_rhs); 25 | SectionHeaders &operator=(const SectionHeaders &p_rhs); 26 | 27 | //! A list of the entries in the program header 28 | std::vector m_sectionHeaders; 29 | 30 | //! Total size of the binary 31 | boost::uint64_t m_totalSize; 32 | 33 | //! The index of the strings in the sections 34 | boost::uint32_t m_stringIndex; 35 | 36 | public: 37 | // default initialize the member variables 38 | SectionHeaders(); 39 | 40 | // nothing of note 41 | ~SectionHeaders(); 42 | 43 | /* 44 | * parses the section header and pushes the various entries into the 45 | * headers vector. 46 | * p_data a pointer to the first section entry 47 | * p_start a pointer to the start of the file 48 | * p_total_size the total size of the file 49 | * p_count the number of entries expected in the header 50 | * p_size the size of section header entry 51 | * p_stringIndex the index of the section header string table 52 | * p_is64 indicates if the binary is 32 bit or 64 bit 53 | * p_isLE indicates if the binary is LE or BE 54 | * p_reasons scoring reasons 55 | */ 56 | void setHeaders(const char* p_data, uint32_t p_offset, const char* p_start, 57 | boost::uint64_t p_total_size, boost::uint16_t p_count, 58 | boost::uint32_t p_size, std::uint32_t p_stringIndex, 59 | bool p_is64, bool p_isLE, 60 | std::map >& p_capabilities); 61 | 62 | /*! 63 | * passes section header information into AbstractSegments for segment creation 64 | * p_segments the segment object we'll pass info to 65 | */ 66 | void extractSegments(AbstractSegments &p_segments); 67 | 68 | /* 69 | * calls into the various segments for evaluation / scoring information. 70 | * p_reasons stores the scoring and reasons 71 | * p_capabilities stores information about what the binary does 72 | */ 73 | void evaluate(std::vector> &p_reasons, 74 | std::map> &p_capabilities) const; 75 | 76 | // the section headers 77 | const std::vector &getSections() const; 78 | 79 | // the string table index 80 | boost::uint32_t getStringTableIndex() const; 81 | 82 | // string representation of the section headers 83 | std::string printToStdOut() const; 84 | }; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/test/gtest_color_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | // A helper program for testing how Google Test determines whether to use 33 | // colors in the output. It prints "YES" and returns 1 if Google Test 34 | // decides to use colors, and prints "NO" and returns 0 otherwise. 35 | 36 | #include 37 | 38 | #include "gtest/gtest.h" 39 | 40 | // Indicates that this translation unit is part of Google Test's 41 | // implementation. It must come before gtest-internal-inl.h is 42 | // included, or there will be a compiler error. This trick is to 43 | // prevent a user from accidentally including gtest-internal-inl.h in 44 | // his code. 45 | #define GTEST_IMPLEMENTATION_ 1 46 | #include "src/gtest-internal-inl.h" 47 | #undef GTEST_IMPLEMENTATION_ 48 | 49 | using testing::internal::ShouldUseColor; 50 | 51 | // The purpose of this is to ensure that the UnitTest singleton is 52 | // created before main() is entered, and thus that ShouldUseColor() 53 | // works the same way as in a real Google-Test-based test. We don't actual 54 | // run the TEST itself. 55 | TEST(GTestColorTest, Dummy) { 56 | } 57 | 58 | int main(int argc, char** argv) { 59 | testing::InitGoogleTest(&argc, argv); 60 | 61 | if (ShouldUseColor(true)) { 62 | // Google Test decides to use colors in the output (assuming it 63 | // goes to a TTY). 64 | printf("YES\n"); 65 | return 1; 66 | } else { 67 | // Google Test decides not to use colors in the output. 68 | printf("NO\n"); 69 | return 0; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/tests/tiny_tests.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "../elfparser.hpp" 3 | #include "../abstract_programheader.hpp" 4 | #include "../abstract_sectionheader.hpp" 5 | #include "../abstract_segments.hpp" 6 | #include "../structures/sectionheader.hpp" 7 | #include "../segment_types/segment_type.hpp" 8 | #include "../dynamicsection.hpp" 9 | #include "../symbols.hpp" 10 | 11 | #include 12 | 13 | class TinyTest : public testing::Test 14 | { 15 | protected: 16 | 17 | virtual void SetUp(){ } 18 | 19 | ELFParser m_parser; 20 | }; 21 | 22 | /* 23 | * the true.asm binary from muppet labs. 24 | */ 25 | TEST_F(TinyTest, true_binary) 26 | { 27 | m_parser.parse("../src/tests/test_files/true"); 28 | EXPECT_FALSE(m_parser.getElfHeader().is64()); 29 | EXPECT_TRUE(m_parser.getElfHeader().isLE()); 30 | EXPECT_STREQ("7f 45 4c 46", m_parser.getElfHeader().getMagic().c_str()); 31 | EXPECT_EQ(0x2549001a, m_parser.getElfHeader().getEntryPoint()); 32 | EXPECT_EQ("0x2549001a", m_parser.getElfHeader().getEntryPointString()); 33 | EXPECT_EQ(4, m_parser.getElfHeader().getProgramOffset()); 34 | EXPECT_EQ(0xAEF25F5B, m_parser.getElfHeader().getSectionOffset()); 35 | EXPECT_EQ(32, m_parser.getElfHeader().getProgramSize()); 36 | EXPECT_EQ(1, m_parser.getElfHeader().getProgramCount()); 37 | EXPECT_EQ(0, m_parser.getElfHeader().getSectionSize()); 38 | EXPECT_EQ(0, m_parser.getElfHeader().getSectionCount()); 39 | EXPECT_EQ(0, m_parser.getElfHeader().getStringTableIndex()); 40 | EXPECT_EQ(1, m_parser.getProgramHeaders().getProgramHeaders().size()); 41 | EXPECT_EQ(0, m_parser.getSectionHeaders().getSections().size()); 42 | EXPECT_EQ(0, m_parser.getSectionHeaders().getStringTableIndex()); 43 | EXPECT_STREQ(m_parser.getProgramHeaders().getProgramHeaders()[0].getName().c_str(),"PT_LOAD"); 44 | EXPECT_EQ(m_parser.getProgramHeaders().getProgramHeaders()[0].getVirtualAddress(), 0x25490000); 45 | } 46 | 47 | /* 48 | * the bf.asm binary from muppet labs. 49 | */ 50 | TEST_F(TinyTest, bf_binary) 51 | { 52 | m_parser.parse("../src/tests/test_files/bf"); 53 | EXPECT_FALSE(m_parser.getElfHeader().is64()); 54 | EXPECT_TRUE(m_parser.getElfHeader().isLE()); 55 | EXPECT_STREQ("7f 45 4c 46", m_parser.getElfHeader().getMagic().c_str()); 56 | EXPECT_EQ(0x45e9b095, m_parser.getElfHeader().getEntryPoint()); 57 | EXPECT_EQ("0x45e9b095", m_parser.getElfHeader().getEntryPointString()); 58 | EXPECT_EQ(44, m_parser.getElfHeader().getProgramOffset()); 59 | EXPECT_EQ(693735845, m_parser.getElfHeader().getSectionOffset()); 60 | EXPECT_EQ(32, m_parser.getElfHeader().getProgramSize()); 61 | EXPECT_EQ(1, m_parser.getElfHeader().getProgramCount()); 62 | EXPECT_EQ(0, m_parser.getElfHeader().getSectionSize()); 63 | EXPECT_EQ(0, m_parser.getElfHeader().getSectionCount()); 64 | EXPECT_EQ(0, m_parser.getElfHeader().getStringTableIndex()); 65 | EXPECT_EQ(1, m_parser.getProgramHeaders().getProgramHeaders().size()); 66 | EXPECT_EQ(0, m_parser.getSectionHeaders().getSections().size()); 67 | EXPECT_EQ(0, m_parser.getSectionHeaders().getStringTableIndex()); 68 | EXPECT_STREQ(m_parser.getProgramHeaders().getProgramHeaders()[0].getName().c_str(),"PT_LOAD"); 69 | EXPECT_EQ(m_parser.getProgramHeaders().getProgramHeaders()[0].getVirtualAddress(), 0x45e9b000); 70 | } 71 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/samples/sample2.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE2_H_ 35 | #define GTEST_SAMPLES_SAMPLE2_H_ 36 | 37 | #include 38 | 39 | 40 | // A simple string class. 41 | class MyString { 42 | private: 43 | const char* c_string_; 44 | const MyString& operator=(const MyString& rhs); 45 | 46 | public: 47 | 48 | // Clones a 0-terminated C string, allocating memory using new. 49 | static const char* CloneCString(const char* a_c_string); 50 | 51 | //////////////////////////////////////////////////////////// 52 | // 53 | // C'tors 54 | 55 | // The default c'tor constructs a NULL string. 56 | MyString() : c_string_(NULL) {} 57 | 58 | // Constructs a MyString by cloning a 0-terminated C string. 59 | explicit MyString(const char* a_c_string) : c_string_(NULL) { 60 | Set(a_c_string); 61 | } 62 | 63 | // Copy c'tor 64 | MyString(const MyString& string) : c_string_(NULL) { 65 | Set(string.c_string_); 66 | } 67 | 68 | //////////////////////////////////////////////////////////// 69 | // 70 | // D'tor. MyString is intended to be a final class, so the d'tor 71 | // doesn't need to be virtual. 72 | ~MyString() { delete[] c_string_; } 73 | 74 | // Gets the 0-terminated C string this MyString object represents. 75 | const char* c_string() const { return c_string_; } 76 | 77 | size_t Length() const { 78 | return c_string_ == NULL ? 0 : strlen(c_string_); 79 | } 80 | 81 | // Sets the 0-terminated C string this MyString object represents. 82 | void Set(const char* c_string); 83 | }; 84 | 85 | 86 | #endif // GTEST_SAMPLES_SAMPLE2_H_ 87 | -------------------------------------------------------------------------------- /src/structures/elfheader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ELF_HEADER_HPP 2 | #define ELF_HEADER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace elf 9 | { 10 | enum elf_class 11 | { 12 | k_32 = 1, 13 | k_64 = 2 14 | }; 15 | 16 | enum elf_encoding 17 | { 18 | k_littleEndian = 1, 19 | k_bigEndian = 2 20 | }; 21 | 22 | enum elf_type 23 | { 24 | k_etnone = 0, 25 | k_etrel, 26 | k_etexec, 27 | k_etdyn, 28 | k_etcore 29 | }; 30 | 31 | enum elf_machine 32 | { 33 | k_emnone = 0, 34 | k_emM32, 35 | k_emSPARC, 36 | k_em386 = 3, 37 | k_emMIPS = 8, 38 | k_emSPARC32PLUS = 18, 39 | k_emPPC = 20, 40 | k_emPPC64, 41 | k_emARM = 40, 42 | 43 | k_emx8664 = 62 44 | 45 | }; 46 | 47 | #pragma pack(push, 1) 48 | struct elf_header_32 49 | { 50 | union 51 | { 52 | boost::uint8_t m_ident[16]; 53 | struct 54 | { 55 | boost::uint8_t m_magic0; 56 | boost::uint8_t m_magic1; 57 | boost::uint8_t m_magic2; 58 | boost::uint8_t m_magic3; 59 | boost::uint8_t m_class; 60 | boost::uint8_t m_encoding; 61 | boost::uint8_t m_fileversion; 62 | boost::uint8_t m_os; 63 | boost::uint8_t m_abi; 64 | }; 65 | }; 66 | boost::uint16_t m_type; 67 | boost::uint16_t m_machine; 68 | boost::uint32_t m_version; 69 | boost::uint32_t m_entry; 70 | boost::uint32_t m_phoff; 71 | boost::uint32_t m_shoff; 72 | boost::uint32_t m_flags; 73 | boost::uint16_t m_ehsize; 74 | boost::uint16_t m_phentsize; 75 | boost::uint16_t m_phnum; 76 | boost::uint16_t m_shentsize; 77 | boost::uint16_t m_shnum; 78 | boost::uint16_t m_shtrndx; 79 | }; 80 | 81 | BOOST_STATIC_ASSERT(sizeof(elf_header_32) == 52); 82 | 83 | struct elf_header_64 84 | { 85 | union 86 | { 87 | boost::uint8_t m_ident[16]; 88 | struct 89 | { 90 | boost::uint8_t m_magic0; 91 | boost::uint8_t m_magic1; 92 | boost::uint8_t m_magic2; 93 | boost::uint8_t m_magic3; 94 | boost::uint8_t m_class; 95 | boost::uint8_t m_encoding; 96 | boost::uint8_t m_fileversion; 97 | boost::uint8_t m_os; 98 | boost::uint8_t m_abi; 99 | }; 100 | }; 101 | boost::uint16_t m_type; 102 | boost::uint16_t m_machine; 103 | boost::uint32_t m_version; 104 | boost::uint64_t m_entry; 105 | boost::uint64_t m_phoff; 106 | boost::uint64_t m_shoff; 107 | boost::uint32_t m_flags; 108 | boost::uint16_t m_ehsize; 109 | boost::uint16_t m_phentsize; 110 | boost::uint16_t m_phnum; 111 | boost::uint16_t m_shentsize; 112 | boost::uint16_t m_shnum; 113 | boost::uint16_t m_shtrndx; 114 | }; 115 | 116 | BOOST_STATIC_ASSERT(sizeof(elf_header_64) == 64); 117 | #pragma pack(pop) 118 | } 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /lib/gtest-1.6.0/m4/gtest.m4: -------------------------------------------------------------------------------- 1 | dnl GTEST_LIB_CHECK([minimum version [, 2 | dnl action if found [,action if not found]]]) 3 | dnl 4 | dnl Check for the presence of the Google Test library, optionally at a minimum 5 | dnl version, and indicate a viable version with the HAVE_GTEST flag. It defines 6 | dnl standard variables for substitution including GTEST_CPPFLAGS, 7 | dnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines 8 | dnl GTEST_VERSION as the version of Google Test found. Finally, it provides 9 | dnl optional custom action slots in the event GTEST is found or not. 10 | AC_DEFUN([GTEST_LIB_CHECK], 11 | [ 12 | dnl Provide a flag to enable or disable Google Test usage. 13 | AC_ARG_ENABLE([gtest], 14 | [AS_HELP_STRING([--enable-gtest], 15 | [Enable tests using the Google C++ Testing Framework. 16 | (Default is enabled.)])], 17 | [], 18 | [enable_gtest=]) 19 | AC_ARG_VAR([GTEST_CONFIG], 20 | [The exact path of Google Test's 'gtest-config' script.]) 21 | AC_ARG_VAR([GTEST_CPPFLAGS], 22 | [C-like preprocessor flags for Google Test.]) 23 | AC_ARG_VAR([GTEST_CXXFLAGS], 24 | [C++ compile flags for Google Test.]) 25 | AC_ARG_VAR([GTEST_LDFLAGS], 26 | [Linker path and option flags for Google Test.]) 27 | AC_ARG_VAR([GTEST_LIBS], 28 | [Library linking flags for Google Test.]) 29 | AC_ARG_VAR([GTEST_VERSION], 30 | [The version of Google Test available.]) 31 | HAVE_GTEST="no" 32 | AS_IF([test "x${enable_gtest}" != "xno"], 33 | [AC_MSG_CHECKING([for 'gtest-config']) 34 | AS_IF([test "x${enable_gtest}" != "xyes"], 35 | [AS_IF([test -x "${enable_gtest}/scripts/gtest-config"], 36 | [GTEST_CONFIG="${enable_gtest}/scripts/gtest-config"], 37 | [GTEST_CONFIG="${enable_gtest}/bin/gtest-config"]) 38 | AS_IF([test -x "${GTEST_CONFIG}"], [], 39 | [AC_MSG_RESULT([no]) 40 | AC_MSG_ERROR([dnl 41 | Unable to locate either a built or installed Google Test. 42 | The specific location '${enable_gtest}' was provided for a built or installed 43 | Google Test, but no 'gtest-config' script could be found at this location.]) 44 | ])], 45 | [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])]) 46 | AS_IF([test -x "${GTEST_CONFIG}"], 47 | [AC_MSG_RESULT([${GTEST_CONFIG}]) 48 | m4_ifval([$1], 49 | [_gtest_min_version="--min-version=$1" 50 | AC_MSG_CHECKING([for Google Test at least version >= $1])], 51 | [_gtest_min_version="--min-version=0" 52 | AC_MSG_CHECKING([for Google Test])]) 53 | AS_IF([${GTEST_CONFIG} ${_gtest_min_version}], 54 | [AC_MSG_RESULT([yes]) 55 | HAVE_GTEST='yes'], 56 | [AC_MSG_RESULT([no])])], 57 | [AC_MSG_RESULT([no])]) 58 | AS_IF([test "x${HAVE_GTEST}" = "xyes"], 59 | [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags` 60 | GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags` 61 | GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags` 62 | GTEST_LIBS=`${GTEST_CONFIG} --libs` 63 | GTEST_VERSION=`${GTEST_CONFIG} --version` 64 | AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])], 65 | [AS_IF([test "x${enable_gtest}" = "xyes"], 66 | [AC_MSG_ERROR([dnl 67 | Google Test was enabled, but no viable version could be found.]) 68 | ])])]) 69 | AC_SUBST([HAVE_GTEST]) 70 | AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"]) 71 | AS_IF([test "x$HAVE_GTEST" = "xyes"], 72 | [m4_ifval([$2], [$2])], 73 | [m4_ifval([$3], [$3])]) 74 | ]) 75 | --------------------------------------------------------------------------------