orl_return ELFENTRY ElfSecScanReloc( elf_sec_handle elf_sec_hnd, orl_reloc_return_func return_func ) { int index; elf_sec_handle reloc_sec_hnd; orl_reloc * reloc; orl_return return_val; if( elf_sec_hnd->type != ORL_SEC_TYPE_PROG_BITS ) { return( ORL_ERROR ); } else if ( !(elf_sec_hnd->assoc.normal.reloc_sec) ) { return( ORL_FALSE ); } reloc_sec_hnd = elf_sec_hnd->assoc.normal.reloc_sec; if( reloc_sec_hnd->assoc.reloc.relocs == NULL ) { return_val = ElfCreateRelocs( elf_sec_hnd, reloc_sec_hnd ); if( return_val != ORL_OKAY ) return( return_val ); } reloc = reloc_sec_hnd->assoc.reloc.relocs; return_val = ORL_FALSE; for( index = 0; index < reloc_sec_hnd->size; index += reloc_sec_hnd->entsize ) { return_val = return_func( reloc ); if( return_val != ORL_OKAY ) return( return_val ); reloc++; } return( ORL_TRUE ); }
orl_return ELFENTRY ElfSecQueryReloc( elf_sec_handle elf_sec_hnd, elf_sec_offset sec_offset, orl_reloc_return_func return_func ) { unsigned index; elf_sec_handle reloc_sec_hnd; orl_reloc * reloc; orl_return return_val; if( elf_sec_hnd->type != ORL_SEC_TYPE_PROG_BITS ) return( ORL_ERROR ); reloc_sec_hnd = elf_sec_hnd->assoc.normal.reloc_sec; if( reloc_sec_hnd == NULL ) return( ORL_FALSE ); if( reloc_sec_hnd->assoc.reloc.relocs == NULL ) { return_val = ElfCreateRelocs( elf_sec_hnd, reloc_sec_hnd ); if( return_val != ORL_OKAY ) { return( return_val ); } } reloc = reloc_sec_hnd->assoc.reloc.relocs; return_val = ORL_FALSE; for( index = 0; index < reloc_sec_hnd->size; index += reloc_sec_hnd->entsize ) { if( reloc->offset == sec_offset ) { return_val = return_func( reloc ); if( return_val != ORL_OKAY ) { return( return_val ); } } reloc++; } return( return_val ); }
orl_return ELFENTRY ElfRelocSecScan( elf_sec_handle elf_sec_hnd, orl_reloc_return_func return_func ) { int index; orl_reloc * reloc; orl_return return_val; if( elf_sec_hnd->type != ORL_SEC_TYPE_RELOCS && elf_sec_hnd->type != ORL_SEC_TYPE_RELOCS_EXPADD ) return( ORL_ERROR ); if( elf_sec_hnd->assoc.reloc.relocs == NULL ) { return_val = ElfCreateRelocs( elf_sec_hnd->assoc.reloc.orig_sec, elf_sec_hnd ); if( return_val != ORL_OKAY ) return( return_val ); } reloc = elf_sec_hnd->assoc.reloc.relocs; return_val = ORL_FALSE; for( index = 0; index < elf_sec_hnd->size; index += elf_sec_hnd->entsize ) { return_val = return_func( reloc ); if( return_val != ORL_OKAY ) return( return_val ); reloc++; } return( ORL_TRUE ); }