/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
-/*
-LIBGOBLIN_ELF_EXTERN
-LibGoblin_SectionInfo *
- LibGoblin_Elf_GetSectionInfo(
- LibGoblin_BinaryInfo *p_binfo,
- Byte b_secid )
-{
- LibGoblin_SectionInfo *p_secinfo;
-
- if( LIBGOBLIN_ELF_SEC_ID_MAX <= b_secid ) { return NULL; }
-
- p_secinfo = &(p_binfo->t_section[b_secid]);
-
- return p_secinfo;
-}
-*/
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-/*
-LIBGOBLIN_ELF_EXTERN
-LibGoblin_SectionInfo *
- LibGoblin_Elf_GetSectionInfo_fid(
- LibGoblin_BinaryInfo *p_binfo,
- Byte b_secid,
- int i_analyzefid )
-{
- LibGoblin_BinaryFile *p_bfile;
- LibGoblin_SectionInfo *p_secinfo;
-
- assert( NULL != p_binfo );
- p_bfile = &(p_binfo->t_binfile[ i_analyzefid ]);
-
- if( LIBGOBLIN_ELF_SEC_ID_MAX <= b_secid ) { return NULL; }
-
- p_secinfo = &(p_bfile->t_section[b_secid]);
-
- return p_secinfo;
-}
-*/
-
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-/*
-LIBGOBLIN_ELF_EXTERN
-Word
- LibGoblin_Elf_GetSectionID_fromSectionNumber_inElf(
- LibGoblin_BinaryInfo *p_binfo,
- int i_analyzefid,
- Word w_secnumber )
-{
- Byte b_secid;
- Word w_result = LIBGOBLIN_ELF_SEC_ID_INVALID;
- LibGoblin_BinaryFile *p_bfile;
- LibGoblin_SectionInfo *p_secinfo;
-
- assert( NULL != p_binfo );
-
- // Through out input value when w_secnumber is not Section Index Value.
- if( LIBGOBLIN_ELF_SEC_ID_DEFAULT_MAX <= w_secnumber ) {
- return w_secnumber;
- }
-
- p_bfile = &(p_binfo->t_binfile[i_analyzefid]);
-
- for( b_secid = 0; b_secid < LIBGOBLIN_ELF_SEC_ID_MAX; b_secid++ ) {
- p_secinfo = &(p_bfile->t_section[ b_secid ]);
-
- if( NULL == p_secinfo->pb_sechdr ) {
- w_result = LIBGOBLIN_ELF_SEC_ID_INVALID;
- break;
- }
-
- if( p_secinfo->i_fid == (int)w_secnumber ) {
- w_result = (Word)b_secid;
- break;
- }
- }
-
- return w_result;
-}
-*/
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-/*
-LIBGOBLIN_ELF_EXTERN
-int
- LibGoblin_Elf_ReadSymtabSection_toWorkTable(
- LibGoblin_BinaryInfo *p_binfo,
- int i_analyzefid,
- LibGoblin_SymbolWorkTable *p_symwork )
-{
- Byte *pb_symtab;
- int i_result = 0x00;
- DWord dw_symbols;
- DWord dw_cnt;
- Elf32_Shdr *p_shdr32;
- Elf64_Shdr *p_shdr64;
- Elf32_Sym *p_sym32 = NULL;
- Elf64_Sym *p_sym64 = NULL;
- LibGoblin_SectionInfo *p_secinfo;
-
- assert( NULL != p_binfo );
-
- // Check BinaryInfo & Get SymbolEntires
- p_secinfo = LibGoblin_Elf_GetSectionInfo_fid(
- p_binfo, LIBGOBLIN_ELF_SEC_ID_SYMTAB, i_analyzefid );
- if( NULL == p_secinfo ) {
- return -0x01;
- }
-
- if( IsBinfoType_Elf64( p_binfo ) ) {
- p_shdr64 = (Elf64_Shdr *)(p_secinfo->pb_sechdr);
- if( 0 == p_shdr64->sh_entsize ) {
- return -0x02;
- }
- dw_symbols = (DWord)p_shdr64->sh_size / (DWord)p_shdr64->sh_entsize;
- pb_symtab = p_secinfo->pb_data;
- }
- else {
- p_shdr32 = (Elf32_Shdr *)(p_secinfo->pb_sechdr);
- if( 0 == p_shdr32->sh_entsize ) {
- return -0x02;
- }
- dw_symbols = (DWord)p_shdr32->sh_size / (DWord)p_shdr32->sh_entsize;
- pb_symtab = p_secinfo->pb_data;
- }
-
- // Create & Alloc SymbolWorkTable
- i_result = LibGoblin_SymWork_AllocSymbolWorkTable( p_symwork, dw_symbols );
- if( 0x00 != i_result ) {
- return -0x03;
- }
-
- // Read SymbolSection to SymbolWorkTable
- if( IsBinfoType_Elf64( p_binfo ) ) {
- p_sym64 = (Elf64_Sym *)pb_symtab;
-
- for( dw_cnt = 0; ((dw_cnt < dw_symbols) && (0x00 == i_result)); dw_cnt++, p_sym64++ ) {
- i_result = LibGoblin_SymWork_AddSymbolWorkInfo(
- p_symwork, (Ptr)p_sym64->st_value, (Byte *)p_sym64,
- LIBGOBLIN_SYMWORKINFO_TYPE_SYMTAB );
- }
- }
- else {
- p_sym32= (Elf32_Sym *)pb_symtab;
-
- for( dw_cnt = 0; ((dw_cnt < dw_symbols) && (0x00 == i_result)); dw_cnt++, p_sym32++ ) {
- i_result = LibGoblin_SymWork_AddSymbolWorkInfo(
- p_symwork, (Ptr)p_sym32->st_value, (Byte *)p_sym32,
- LIBGOBLIN_SYMWORKINFO_TYPE_SYMTAB );
- }
- }
- if( 0x00 != i_result ) {
- return -0x04;
- }
-
- // Sort WorkTable
- LibGoblin_SymWork_SortSymbolWorkTable( p_symwork );
-
- return 0x00;
-}
-*/
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
LIBGOBLIN_ELF_EXTERN
int
LibGoblin_AnalyzeElf(
#define LIBGOBLIN_ELF_EXTERN extern
#endif
-/*
-#ifdef DRD64_SRC_LIBGOBLIN_ELF
- char *gstr_elf_section_name[LIBGOBLIN_ELF_SEC_ID_MAX] = {
- LIBGOBLIN_ELF_SEC_STR_TEXT,
- LIBGOBLIN_ELF_SEC_STR_TEXT_INIT,
- LIBGOBLIN_ELF_SEC_STR_TEXT_FINI,
- LIBGOBLIN_ELF_SEC_STR_DATA,
- LIBGOBLIN_ELF_SEC_STR_BSS,
- LIBGOBLIN_ELF_SEC_STR_GOT,
- LIBGOBLIN_ELF_SEC_STR_GOT_PLT,
- LIBGOBLIN_ELF_SEC_STR_PLT,
- LIBGOBLIN_ELF_SEC_STR_REL_PLT,
- LIBGOBLIN_ELF_SEC_STR_RELA_PLT,
- LIBGOBLIN_ELF_SEC_STR_SHSTRTAB,
- LIBGOBLIN_ELF_SEC_STR_STRTAB,
- LIBGOBLIN_ELF_SEC_STR_SYMTAB,
- LIBGOBLIN_ELF_SEC_STR_DTORS,
- LIBGOBLIN_ELF_SEC_STR_CTORS,
- LIBGOBLIN_ELF_SEC_STR_DYNAMIC,
- LIBGOBLIN_ELF_SEC_STR_DYNSTR,
- LIBGOBLIN_ELF_SEC_STR_DYNSYM,
- LIBGOBLIN_ELF_SEC_STR_EH_FRAME,
- LIBGOBLIN_ELF_SEC_STR_EH_FRAME_HDR,
- LIBGOBLIN_ELF_SEC_STR_COMMENT,
- LIBGOBLIN_ELF_SEC_STR_GNU_VERSION,
- LIBGOBLIN_ELF_SEC_STR_GNU_VERSION_R,
- LIBGOBLIN_ELF_SEC_STR_RODATA,
- LIBGOBLIN_ELF_SEC_STR_NOTE_ABI_TAG,
- LIBGOBLIN_ELF_SEC_STR_HASH,
- LIBGOBLIN_ELF_SEC_STR_INTERP,
- LIBGOBLIN_ELF_SEC_STR_JCR,
- LIBGOBLIN_ELF_SEC_STR_DEBUG_ABBREV,
- LIBGOBLIN_ELF_SEC_STR_DEBUG_INFO,
- LIBGOBLIN_ELF_SEC_STR_DEBUG_LINE,
- LIBGOBLIN_ELF_SEC_STR_DEBUG_ARANGES,
- LIBGOBLIN_ELF_SEC_STR_DEBUG_FRAME,
- LIBGOBLIN_ELF_SEC_STR_DEBUG_LOC,
- LIBGOBLIN_ELF_SEC_STR_DEBUG_PUBNAMES
- };
-#else
- extern char *gstr_elf_section_name[LIBGOBLIN_ELF_SEC_ID_MAX];
-#endif
-*/
LIBGOBLIN_ELF_EXTERN
int LibGoblin_IsElf( Byte *p_data );
LIBGOBLIN_ELF_EXTERN
Byte *LibGoblin_Elf_GetSection(
QWord *qw_secsize, LibGoblin_BinaryInfo *p_bin, int i_analyzefid, Byte b_secid );
-/*
-LIBGOBLIN_ELF_EXTERN
- LibGoblin_SectionInfo *LibGoblin_Elf_GetSectionInfo_fid(
- LibGoblin_BinaryInfo *p_binfo, Byte b_secid, int i_analyzefid );
-LIBGOBLIN_ELF_EXTERN
- LibGoblin_SectionInfo *LibGoblin_Elf_GetSectionInfo(
- LibGoblin_BinaryInfo *p_binfo, Byte b_secid );
-LIBGOBLIN_ELF_EXTERN
- LibGoblin_SectionInfo *LibGoblin_Elf_GetSectionInfo_fid(
- LibGoblin_BinaryInfo *p_binfo, Byte b_secid, int i_analyzefid );
-LIBGOBLIN_ELF_EXTERN
- Word LibGoblin_Elf_GetSectionID_fromSectionNumber_inElf(
- LibGoblin_BinaryInfo *p_binfo, int i_analyzefid, Word w_secnumber );
-*/
LIBGOBLIN_ELF_EXTERN
int LibGoblin_AnalyzeElf(
LibGoblin_BinaryInfo *p_binfo, int i_analyzefid );