int i_analyzefid )
{
int i_cnt;
+ int i_globid;
int i_secnum;
int i_index;
int i_user_section;
Elf64_Ehdr *p_elfhdr;
Elf64_Shdr *p_sechdr;
Elf64_Shdr *p_secstrhdr;
+ LibGoblin_BinaryFile *p_bfile;
LibGoblin_SectionInfo *p_sectbl;
+ LibGoblin_SectionInfo *p_globsec;
assert( NULL != p_binfo );
- pb_data = p_binfo->t_binfile[i_analyzefid].pb_binary;
+ p_bfile = &(p_binfo->t_binfile[i_analyzefid]);
+ pb_data = p_bfile->pb_binary;
assert( NULL != pb_data );
p_elfhdr = (Elf64_Ehdr *)pb_data;
if( !strncmp( pstr_secname,
gstr_elf_section_name[i_index], 20 )) {
- p_sectbl = &(p_binfo->t_section[i_index]);
+ 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);
}
if( LIBGOBLIN_ELF_SEC_ID_DEFAULT_MAX == i_index ) {
- p_sectbl = &(p_binfo->t_section[i_index]);
+ 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);
}
}
+
+ /* Update Global SectionTable ---*/
+ for( i_cnt = 0; i_cnt < LIBGOBLIN_ELF_SEC_ID_DEFAULT_MAX; i_cnt++ ) {
+ p_globsec = &(p_binfo->t_section[i_cnt]);
+ p_sectbl = &(p_bfile->t_section[i_cnt]);
+
+ if( NULL == p_globsec->pb_sechdr ) {
+ p_globsec->pb_sechdr = p_sectbl->pb_sechdr;
+ p_globsec->pb_data = p_sectbl->pb_data;
+ p_globsec->pstr_secname = p_sectbl->pstr_secname;
+ p_globsec->qw_size = p_sectbl->qw_size;
+ p_globsec->i_fid = p_sectbl->i_fid;
+ }
+
+ }
+
+ for( i_cnt = LIBGOBLIN_ELF_SEC_ID_DEFAULT_MAX;
+ i_cnt < LIBGOBLIN_ELF_SEC_ID_MAX; i_cnt++ ) {
+
+ p_sectbl = &(p_bfile->t_section[i_cnt]);
+ if( NULL == p_sectbl->pb_sechdr ) { break; }
+
+ for( i_globid = LIBGOBLIN_ELF_SEC_ID_DEFAULT_MAX;
+ i_globid < LIBGOBLIN_ELF_SEC_ID_MAX; i_globid++ ) {
+
+ p_globsec = &(p_binfo->t_section[i_globid]);
+ if( NULL == p_globsec->pb_sechdr ) { break; }
+
+ if( !strncmp( p_globsec->pstr_secname,
+ p_sectbl->pstr_secname, 20 )) { break; }
+ }
+
+ p_globsec->pb_sechdr = p_sectbl->pb_sechdr;
+ p_globsec->pb_data = p_sectbl->pb_data;
+ p_globsec->pstr_secname = p_sectbl->pstr_secname;
+ p_globsec->qw_size = p_sectbl->qw_size;
+ p_globsec->i_fid = p_sectbl->i_fid;
+ }
return 0x00;
}
/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
LIBGOBLIN_SYMINFO_EXTERN
-int
- LibGoblin_SymInfo_Create(
- LibGoblin_BinaryInfo *p_binfo )
+DWord
+ LibGoblin_SymInfo_CreateWorkTable(
+ LibGoblin_BinaryInfo *p_binfo,
+ int i_analyzefid )
{
Byte *pb_symtab;
QWord qw_size;
assert( NULL != p_binfo );
// Check BinaryInfo & Get SymbolEntires
+ // XXX
p_secinfo = LibGoblin_Elf_GetSectionInfo( p_binfo, 0, LIBGOBLIN_ELF_SEC_ID_SYMTAB );
if( NULL == p_secinfo ) {
return 0x01;
#define LIBGOBLIN_ELF_SEC_ID_DEBUG_PUBNAMES 0x22
#define LIBGOBLIN_ELF_SEC_ID_DEFAULT_MAX 0x22
-#define LIBGOBLIN_ELF_SEC_ID_MAX 0xff
+#define LIBGOBLIN_ELF_SEC_ID_MAX 0x3f
#define LIBGOBLIN_ELF_SEC_STR_TEXT ".text"
#define LIBGOBLIN_ELF_SEC_STR_TEXT_INIT ".init"
/*=====================================================================*/
typedef struct {
+ Byte *pb_sechdr;
+ Byte *pb_data;
+ char *pstr_secname;
+ QWord qw_size;
+ int i_fid;
+} LibGoblin_SectionInfo;
+
+/*=====================================================================*/
+typedef struct {
/* Binary-File Info. */
int i_fd;
DWord dw_flag;
/* Binary-Format Depending Info. (ELF)*/
void *p_elf;
-} LibGoblin_BinaryFile;
-/*=====================================================================*/
-typedef struct {
- Byte *pb_sechdr;
- Byte *pb_data;
- char *pstr_secname;
- QWord qw_size;
- int i_fid;
-} LibGoblin_SectionInfo;
+ LibGoblin_SectionInfo t_section[LIBGOBLIN_ELF_SEC_ID_MAX];
+} LibGoblin_BinaryFile;
/*=====================================================================*/
typedef struct {