private void relocateFromHeaders(ByteBuffer f,SceModule module,int baseAddress,Elf32 elf,int elfOffset) throws IOException {
  int i=0;
  for (  Elf32ProgramHeader phdr : elf.getProgramHeaderList()) {
    if (phdr.getP_type() == 0x700000A0L) {
      int RelCount=phdr.getP_filesz() / Elf32Relocate.sizeof();
      if (log.isDebugEnabled()) {
        log.debug(String.format("PH#%d: relocating %d entries",i,RelCount));
      }
      f.position(elfOffset + phdr.getP_offset());
      relocateFromBuffer(f,module,baseAddress,elf,RelCount,true);
      return;
    }
 else     if (phdr.getP_type() == 0x700000A1L) {
      if (log.isDebugEnabled()) {
        log.debug(String.format("Type 0x700000A1 PH#%d: relocating A1 entries, size=0x%X",i,phdr.getP_filesz()));
      }
      f.position(elfOffset + phdr.getP_offset());
      relocateFromBufferA1(f,elf,baseAddress,i,phdr.getP_filesz());
      return;
    }
    i++;
  }
  for (  Elf32SectionHeader shdr : elf.getSectionHeaderList()) {
    if (mustRelocate(elf,shdr)) {
      int RelCount=shdr.getSh_size() / Elf32Relocate.sizeof();
      if (log.isDebugEnabled()) {
        log.debug(shdr.getSh_namez() + ": relocating " + RelCount+ " entries");
      }
      f.position(elfOffset + shdr.getSh_offset());
      relocateFromBuffer(f,module,baseAddress,elf,RelCount,shdr.getSh_type() != Elf32SectionHeader.SHT_REL);
    }
  }
}

private void relocateFromHeaders ( ByteBuffer f , SceModule module , int baseAddress , Elf32 elf , int elfOffset ) throws IOException { int i = 0 ; for ( Elf32ProgramHeader phdr : elf . getProgramHeaderList ( ) ) { if ( phdr . getP_type ( ) == 0x700000A0L ) { int RelCount = phdr . getP_filesz ( ) / Elf32Relocate . sizeof ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "PH#%d: relocating %d entries" , i , RelCount ) ) ; } f . position ( elfOffset + phdr . getP_offset ( ) ) ; relocateFromBuffer ( f , module , baseAddress , elf , RelCount , true ) ; return ; } else if ( phdr . getP_type ( ) == 0x700000A1L ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Type 0x700000A1 PH#%d: relocating A1 entries, size=0x%X" , i , phdr . getP_filesz ( ) ) ) ; } f . position ( elfOffset + phdr . getP_offset ( ) ) ; relocateFromBufferA1 ( f , elf , baseAddress , i , phdr . getP_filesz ( ) ) ; return ; } i ++ ; } for ( Elf32SectionHeader shdr : elf . getSectionHeaderList ( ) ) { if ( mustRelocate ( elf , shdr ) ) { int RelCount = shdr . getSh_size ( ) / Elf32Relocate . sizeof ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( shdr . getSh_namez ( ) + ": relocating " + RelCount + " entries" ) ; } f . position ( elfOffset + shdr . getSh_offset ( ) ) ; relocateFromBuffer ( f , module , baseAddress , elf , RelCount , shdr . getSh_type ( ) != Elf32SectionHeader . SHT_REL ) ; } } }
uses info from the elf program headers and elf section headers to relocate a prx .
