orl_return ELFENTRY ElfFileScan( elf_file_handle elf_file_hnd, char *desired, orl_sec_return_func return_func ) { orl_hash_data_struct * data_struct; int loop; orl_return error; if( !desired ) { /* global request */ for( loop = 0; loop < elf_file_hnd->num_sections; loop++ ) { error = return_func( (orl_sec_handle) elf_file_hnd->elf_sec_hnd[loop] ); if( error != ORL_OKAY ) return( error ); } } else { if( !(elf_file_hnd->sec_name_hash_table) ) { error = ElfBuildSecNameHashTable( elf_file_hnd ); if( error != ORL_OKAY ) return( error ); } data_struct = ORLHashTableQuery( elf_file_hnd->sec_name_hash_table, desired ); while( data_struct != NULL ) { error = return_func( (orl_sec_handle) data_struct->data ); if( error != ORL_OKAY ) return( error ); data_struct = data_struct->next; } } return( ORL_OKAY ); }
static omf_symbol_handle findExtDefSym( omf_file_handle ofh, omf_idx ext ) { omf_sec_handle sh; omf_string_struct *extname; orl_hash_data_struct *hd; omf_symbol_handle sym; assert( ofh ); if( !ofh->extdefs ) return( NULL ); sh = ofh->extdefs; if( !ext || ( ext > sh->assoc.string.num ) ) return( NULL ); assert( sh->assoc.string.strings ); extname = sh->assoc.string.strings[ext - 1]; if( extname == NULL ) return( NULL ); for( hd = ORLHashTableQuery( ofh->symbol_table->assoc.sym.hash_tab, extname->string ); hd != NULL; hd = hd->next ) { sym = (omf_symbol_handle)( hd->data ); if( sym != NULL ) { if( sym->typ & ( ORL_SYM_TYPE_UNDEFINED | ORL_SYM_TYPE_COMMON ) ) { return( sym ); } } } return( NULL ); }
orl_return OMFENTRY OmfFileScan( omf_file_handle ofh, char *desired, orl_sec_return_func func ) { orl_hash_data_struct *ds; omf_sec_handle sh; omf_symbol_handle sym; orl_return err; assert( ofh ); assert( func ); if( desired == NULL ) { /* global request */ sh = ofh->first_sec; while( sh ) { // string tables are internal sections which are not seen by // the user code if( sh->type != ORL_SEC_TYPE_STR_TABLE ) { err = func( (orl_sec_handle)sh ); if( err != ORL_OKAY ) return( err ); } sh = sh->next; } } else if( ofh->symbol_table ) { assert( ofh->symbol_table->assoc.sym.hash_tab ); ds = ORLHashTableQuery( ofh->symbol_table->assoc.sym.hash_tab, desired ); while( ds != NULL ) { sym = ds->data; if( ( sym->typ == ORL_SYM_TYPE_SECTION ) && !( sym->flags & OMF_SYM_FLAGS_GRPDEF ) ) { err = func( (orl_sec_handle) sym->section ); if( err != ORL_OKAY ) return( err ); } ds = ds->next; } } return( ORL_OKAY ); }