26
FILE FORMATS
134
26
File Formats
26.1
ELF
26.2
PRX (PSP Relocation eXecutable?)
Sony’s PRX (PSP Relocation eXecutable?) format is a relocation executable based on the standard ELF format. It is distinguised from
a normal ELF file by having customised Program Headers, Non-standard MIPS relocation sections and a unique ELF type.
26.2.1
Program Headers
A valid PRX must have at least one program header in order to be loadable, due to the way the relocation entries work. In all program
headers the Physical address is not used in the way it is described in the ELF documentation. In the first program header in the list the
physical address is actually set to the offset of the .rodata.sceModuleInfo in the PRX file. It is not the load address in memory. In any
subsequent program headers the physical address is set to 0. Just to slightly complicate matters if the PRX file is a kernel module then
the most significant bit must be set in the phsyical address of the first program header.
As a side note the data referenced by the Program Headers must at least be aligned to 16 byte boundaries otherwise the kernel ELF
loader will fail (tested on v1.0 and v1.5).
26.2.2
Custom Relocation Format
The first customisation is the section type of the PRX relocation entries differ from that used in standard ELFs. In standard ELFs a
relocation section is of type 9, in a PRX they are of type 0x700000A0. The second customisation is in the entries themselves. Each
entry is 2 32bit words, the first word is the offset field of the relocation, the second is a compound structure consisting of the standard
MIPS relcocation type and a custom base selection field.
This is represented in C like this:
// Defines for the r_info field
#define ELF32_R_ADDR_BASE(i) (((i)> >16) & 0xFF)
#define ELF32_R_OFS_BASE(i) (((i)> >8) & 0xFF)
#define ELF32_R_TYPE(i) (i&0xFF)
typedef struct {
Elf32_Addr r_offset;
Elf32_Word r_info;
} Elf32_Rel;
// MIPS Reloc Entry Types
#define R_MIPS_NONE 0
#define R_MIPS_16 1
#define R_MIPS_32 2
#define R_MIPS_REL32 3
#define R_MIPS_26 4
#define R_MIPS_HI16 5
#define R_MIPS_LO16 6
#define R_MIPS_GPREL16 7
#define R_MIPS_LITERAL 8
#define R_MIPS_GOT16 9
#define R_MIPS_PC16 10
#define R_MIPS_CALL16 11
#define R_MIPS_GPREL32 12
OFS_BASE determines which program header the r_offset field is based from. So if r_offset is 0x100 and OFS_BASE is 0 (which
is a PH starting at address 0) then the address to read is at 0x100.
ADDR_BASE determines which program header the current address value in memory should be relocated from. So for example if
ADDR_BASE was 1, program header 1 is loaded to 0x1000 and the current address stored in the ELF is 0xF0 then the resulting address
is 0x10F0.
Содержание PlayStationPortable
Страница 114: ...12 AUDIO PROCESSING 114 12 Audio Processing 12 1 Overview 44100 Hz Sample Frequency ...
Страница 116: ...14 WLAN 116 14 WLAN ...
Страница 117: ...15 USB PORT 117 15 USB Port ...
Страница 118: ...16 UMD 118 16 UMD ...
Страница 119: ...17 MEMORY STICK 119 17 Memory Stick ...
Страница 128: ...21 FLASH MEMORY STRUCTURE FLASH1 128 21 Flash Memory Structure flash1 DIC REGISTRY VSH THEME ...
Страница 141: ...28 IPL 141 28 IPL ...