static orl_return sectionInit( orl_sec_handle shnd ) { section_type type; return_val error = OKAY; type = IdentifySec( shnd ); switch( type ) { case SECTION_TYPE_SYM_TABLE: symbolTable = shnd; // Might have a label or relocation in symbol section error = registerSec( shnd, type ); if( error == OKAY ) { error = createLabelList( shnd ); } break; case SECTION_TYPE_DYN_SYM_TABLE: dynSymTable = shnd; // Might have a label or relocation in dynsym section error = registerSec( shnd, type ); if( error == OKAY ) { error = createLabelList( shnd ); } break; case SECTION_TYPE_DRECTVE: if( GetFormat() == ORL_OMF ) { drectveSection = shnd; break; } // else fall through case SECTION_TYPE_BSS: error = registerSec( shnd, type ); if( error == OKAY ) { error = createLabelList( shnd ); } break; case SECTION_TYPE_RELOCS: // Ignore OMF relocs section break; case SECTION_TYPE_LINES: debugHnd = shnd; type = SECTION_TYPE_DATA; // fall through case SECTION_TYPE_TEXT: case SECTION_TYPE_PDATA: case SECTION_TYPE_DATA: default: // Just in case we get a label or relocation in these sections error = registerSec( shnd, type ); if( error == OKAY ) { error = textOrDataSectionInit( shnd ); } break; } switch( error ) { case OUT_OF_MEMORY: return( ORL_OUT_OF_MEMORY ); case ERROR: return( ORL_ERROR ); } return( ORL_OKAY ); }
static return_val textOrDataSectionInit( orl_sec_handle shnd ) { return_val error; orl_sec_handle reloc_sec; error = createLabelList( shnd ); if( error == RC_OKAY ) { error = createRefList( shnd ); if( error == RC_OKAY ) { reloc_sec = ORLSecGetRelocTable( shnd ); if( reloc_sec != ORL_NULL_HANDLE ) { error = addRelocSection( reloc_sec ); } } } return( error ); }
static return_val initSectionTables( void ) { return_val error; orl_return o_error; section_ptr sec; // list for references to external functions, etc. error = createLabelList( 0 ); if( error == OKAY ) { o_error = ORLFileScan( ObjFileHnd, NULL, §ionInit ); if( o_error == ORL_OKAY && symbolTable ) { o_error = DealWithSymbolSection( symbolTable ); if( o_error == ORL_OKAY && dynSymTable ) { o_error = DealWithSymbolSection( dynSymTable ); } if( o_error == ORL_OKAY ) { sec = relocSections.first; while( sec ) { o_error = DealWithRelocSection( sec->shnd ); if( o_error != ORL_OKAY ) { if( o_error == ORL_OUT_OF_MEMORY ) { return( OUT_OF_MEMORY ); } else { return( ERROR ); } } relocSections.first = sec->next; MemFree( sec ); sec = relocSections.first; } error = processDrectveSection( drectveSection ); } else { if( o_error == ORL_OUT_OF_MEMORY ) { return( OUT_OF_MEMORY ); } else { return( ERROR ); } } } } return( error ); }