drd64_libgoblin_elf.o \
drd64_libgoblin_elf_dynver.o \
drd64_libgoblin_elf_symtab.o \
+ drd64_libgoblin_elf_proghdr.o \
drd64_libgoblin_elf64.o \
drd64_libgoblin_elf32.o \
drd64_libgoblin_dwarf.o \
drd64_libgoblin_elf.h \
drd64_libgoblin_elf_dynver.h \
drd64_libgoblin_elf_symtab.h \
+ drd64_libgoblin_elf_proghdr.h \
drd64_libgoblin_elf64.h \
drd64_libgoblin_elf32.h \
drd64_libgoblin_dwarf.h \
TESTPROG = ../testdata/dwarftest
+CALLGRAPH = CallGraph.txt
+
all: $(TARGET) test
-build: $(TARGET)
+build: $(TARGET) $(CALLGRAPH)
test: $(TEST_TARGET) $(TESTPROG)
./$(TEST_TARGET)
drd64_libgoblin_elf_symtab.o: drd64_libgoblin_elf_symtab.c $(HEADER)
$(CC) -c -o drd64_libgoblin_elf_symtab.o $(FLAGS_DEBUG) \
drd64_libgoblin_elf_symtab.c
+drd64_libgoblin_elf_proghdr.o: drd64_libgoblin_elf_proghdr.c $(HEADER)
+ $(CC) -c -o drd64_libgoblin_elf_proghdr.o $(FLAGS_DEBUG) \
+ drd64_libgoblin_elf_proghdr.c
drd64_libgoblin_elf64.o: drd64_libgoblin_elf64.c $(HEADER)
$(CC) -c -o drd64_libgoblin_elf64.o $(FLAGS_DEBUG) \
drd64_libgoblin_elf64.c
$(MAKE) -C ../testdata all clean
# $(MAKE) -C ../testpg/testpg02 all clean
+$(CALLGRAPH):
+ env CC=cc cflow -A -P -g -X -n drd64_*.c $(HEADER) > $(CALLGRAPH)
clean:
rm -f *.o
rm -f *.xml
rm -f *.core
+ rm -f $(CALLGRAPH)
rm -f $(TARGET)
rm -f $(TEST_TARGET)
#include"drd64_libgoblin_elf.h"
#include"drd64_libgoblin_elf_dynver.h"
#include"drd64_libgoblin_elf_symtab.h"
+#include"drd64_libgoblin_elf_proghdr.h"
#include"drd64_libgoblin_elf64.h"
#include"drd64_libgoblin_elf32.h"
#include"drd64_libgoblin_dwarf_common.h"
return -0x01;
}
- i_result = ELF_ReadELF_Phase2( p_pginfo->p_binfo[LIBGOBLIN_BINFO_FILE_EXEC] );
+ i_result = ELF_ReadELF_Phase2( p_pginfo, p_pginfo->p_binfo[LIBGOBLIN_BINFO_FILE_EXEC] );
if( 0x00 != i_result ) {
return -0x02;
}
LibGoblin_AllocProgInfo(
void )
{
+ int i_result;
LibGoblin_ProgramInfo *p_pginfo = NULL;
p_pginfo = ProgInfo_AllocProgInfo();
return -0x01;
}
+ i_result = ObjectInfo_Init( p_pginfo, 0 );
+ if( 0x00 != i_result ) {
+ ProgInfo_FreeProgInfo( p_pginfo ); // None use return value.
+ return -0x02;
+ }
+
return p_pginfo->i_id;
}
}
assert( p_pginfo->i_id == i_pgid );
+ ObjectInfo_Term( p_pginfo ); // None use retrun value.
+
i_result = ProgInfo_FreeProgInfo( p_pginfo );
if( 0x00 != i_result ) {
return -0x02;
LIBGOBLIN_ELF_EXTERN
int
ELF_ReadELF_Phase2(
+ LibGoblin_ProgramInfo *p_pginfo,
LibGoblin_BinaryInfo *p_binfo )
{
int i_result;
pb_data = p_bfile->pb_binary;
assert( NULL != pb_data );
- /* Create Symbol-Table ------------------*/
+ /* Read Program Header to ObjectInfo ------------------*/
+
+ /* Read Program Header to ObjectInfo ------------------*/
+ /* Read SymbolTable to ObjectInfo ---------------------*/
+
+ /* Create Symbol-Table ------------------*/
i_result = LibGoblin_Section_ReadSymtabSection_toWorkTable(
p_binfo, &t_symwork );
if( 0x00 != i_result ) {
LIBGOBLIN_ELF_EXTERN
int ELF_ReadELF_Phase1( LibGoblin_BinaryInfo *p_binfo );
LIBGOBLIN_ELF_EXTERN
- int ELF_ReadELF_Phase2( LibGoblin_BinaryInfo *p_binfo );
+ int ELF_ReadELF_Phase2( LibGoblin_ProgramInfo *p_pginfo, LibGoblin_BinaryInfo *p_binfo );
#endif /* DRD64_HEADER_LIBGOBLIN_BINFO */
--- /dev/null
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+ D r . D e a m o n 6 4
+ for INTEL64(R), AMD64(R)
+
+ Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function:
+Comment:
+----------------------------------------------------------------------*/
+
+#define DRD64_SRC_LIBGOBLIN_ELF_PROGHDR
+#include"drd64_libgoblin.h"
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_ELF_PROGHDR_EXTERN
+int
+ ELF_ProgramHeader_Read(
+ LibGoblin_ProgramInfo *p_pginfo,
+ LibGoblin_BinaryInfo *p_binfo )
+{
+ int i_cnt;
+ int i_secnum;
+ int i_index;
+ int i_user_section;
+ char *pstr_secname;
+ Byte *pb_data;
+ Elf64_Ehdr *p_elfhdr;
+ Elf64_Shdr *p_sechdr;
+ Elf64_Shdr *p_secstrhdr;
+ LibGoblin_BinaryFile *p_bfile;
+ LibGoblin_SectionInfo *p_sectbl;
+
+ assert( NULL != p_binfo );
+ p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
+ pb_data = p_bfile->pb_binary;
+ assert( NULL != pb_data );
+
+ p_elfhdr = (Elf64_Ehdr *)pb_data;
+ i_user_section = LIBGOBLIN_SECTION_ID_DEFAULT_MAX;
+
+ /* Get Section Header of the "Section-Name Section" */
+ p_secstrhdr = (Elf64_Shdr *)(pb_data + p_elfhdr->e_shoff
+ + (p_elfhdr->e_shentsize * p_elfhdr->e_shstrndx));
+
+ i_secnum = p_elfhdr->e_shnum;
+ for( i_cnt = 0; i_cnt < i_secnum; i_cnt++ ) {
+ p_sechdr = (Elf64_Shdr *)(pb_data + (p_elfhdr->e_shoff)
+ + (p_elfhdr->e_shentsize * i_cnt));
+
+ pstr_secname = (char *)pb_data + p_secstrhdr->sh_offset
+ + p_sechdr->sh_name;
+
+ for( i_index = 0;
+ i_index < LIBGOBLIN_SECTION_ID_DEFAULT_MAX; i_index++ ) {
+
+ if( !strncmp( pstr_secname,
+ gstr_section_name[i_index], 20 )) {
+
+ p_sectbl = &(p_bfile->t_section[i_index]);
+
+ p_sectbl->pb_sechdr = (Byte *)p_sechdr;
+ p_sectbl->pb_data = (Byte *)(pb_data + p_sechdr->sh_offset);
+ p_sectbl->pstr_secname = pstr_secname;
+ p_sectbl->qw_size = p_sechdr->sh_size;
+ p_sectbl->i_fid = p_binfo->i_filetype;
+ break;
+ }
+ }
+
+ if( LIBGOBLIN_SECTION_ID_DEFAULT_MAX == i_index ) {
+ p_sectbl = &(p_bfile->t_section[i_user_section]);
+
+ p_sectbl->pb_sechdr = (Byte *)p_sechdr;
+ p_sectbl->pb_data = (Byte *)(pb_data + p_sechdr->sh_offset);
+ p_sectbl->pstr_secname = pstr_secname;
+ p_sectbl->qw_size = p_sechdr->sh_size;
+ p_sectbl->i_fid = p_binfo->i_filetype;
+
+ i_user_section++;
+ }
+
+ }
+
+ /* Update Global SectionTable ---*/
+ if( 0 < p_binfo->i_pginfo ) {
+ //p_pginfo = ProgInfo_GetProgInfo( p_binfo->i_pginfo );
+ Section_UpdateSectionInfo_inProgInfo( p_pginfo, p_binfo );
+ }
+
+ return 0x00;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
--- /dev/null
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+ D r . D e a m o n 6 4
+ for INTEL64(R), AMD64(R)
+
+ Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header
+Comment:
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN_ELF_PROGHDR
+#define DRD64_HEADER_LIBGOBLIN_ELF_PROGHDR
+
+#include"drd64_libgoblin.h"
+
+#ifdef DRD64_SRC_LIBGOBLIN_ELF_PROGHDR
+ #define LIBGOBLIN_ELF_PROGHDR_EXTERN
+#else
+ #define LIBGOBLIN_ELF_PROGHDR_EXTERN extern
+#endif
+
+LIBGOBLIN_ELF_PROGHDR_EXTERN
+ int ELF_ProgramHeader_Read( LibGoblin_ProgramInfo *p_pginfo, LibGoblin_BinaryInfo *p_binfo );
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN_BINFO */
+
+/* EOF of drd64_.h ----------------------------------- */