1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #define DRD64_SRC_LIBGOBLIN_ELF
38 #include"drd64_libgoblin.h"
41 /*----------------------------------------------------------------------
42 ----------------------------------------------------------------------*/
49 assert( NULL != p_data );
50 if( ( ELFMAG0 == *(p_data + EI_MAG0) )
51 && ( ELFMAG1 == *(p_data + EI_MAG1) )
52 && ( ELFMAG2 == *(p_data + EI_MAG2) )
53 && ( ELFMAG3 == *(p_data + EI_MAG3) ) )
60 /*----------------------------------------------------------------------
61 Will Deprecate Functions!!! - Not Use!
62 ----------------------------------------------------------------------*/
67 LibGoblin_BinaryInfo *p_binfo,
71 LibGoblin_BinaryFile *p_bfile;
72 LibGoblin_SectionInfo *p_sectbl;
74 assert( NULL != p_binfo );
75 p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
81 if( LIBGOBLIN_SECTION_ID_DEFAULT_MAX <= b_secid ) { return NULL; }
83 p_sectbl = &(p_bfile->t_section[b_secid]);
84 if( NULL != p_sectbl->pb_sechdr ) {
85 pb_data = p_sectbl->pb_data;
86 *qw_secsize = p_sectbl->qw_size;
93 /*----------------------------------------------------------------------
94 ----------------------------------------------------------------------*/
98 LibGoblin_BinaryInfo *p_binfo )
102 assert( NULL != p_binfo );
104 /* ReCheck ELF Header -------------------*/
105 i_result = LibGoblin_CheckBinary( p_binfo );
106 if( 0x00 != i_result ) {
110 /* Analyze ELF Basical Struct & data -----*/
111 if( LIBGOBLIN_BINFO_TYPE_ELF64 == p_binfo->b_type ) {
112 i_result = LibGoblin_Elf64_SetSectionInfo( p_binfo );
114 else if( LIBGOBLIN_BINFO_TYPE_ELF32 == p_binfo->b_type ) {
117 if( 0x00 != i_result ) {
121 i_result = LibGoblin_Elf_DynVer_ReadDynamicSection( p_binfo );
122 if( 0x00 > i_result ) {
130 /*----------------------------------------------------------------------
131 ----------------------------------------------------------------------*/
135 LibGoblin_BinaryInfo *p_binfo )
139 LibGoblin_BinaryFile *p_bfile;
140 LibGoblin_SymbolWorkTable t_symwork;
142 assert( NULL != p_binfo );
143 p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
144 pb_data = p_bfile->pb_binary;
145 assert( NULL != pb_data );
147 /* Create Symbol-Table ------------------*/
149 i_result = LibGoblin_Section_ReadSymtabSection_toWorkTable(
150 p_binfo, &t_symwork );
151 if( 0x00 != i_result ) {
156 LibGoblin_Debug_SymWork_PrintWorkTable( &t_symwork, 0x02 );
159 /* Analyze Dwarf-Debug Info. */
161 if( 0x00 != LibGoblin_IsDwarf( p_binfo ) ) {
162 LibGoblin_AnalyzeDwarf( p_binfo );
166 LibGoblin_SymWork_FreeSymbolWorkTable( &t_symwork );
173 /* EOF of drd64_.c ----------------------------------- */