Editing SELF File Format

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
#REDIRECT [https://www.psdevwiki.com/ps3/SELF_-_SPRX]
[[Category:Software]]<noinclude>[[Category:Main]]</noinclude>
 
= File Format =
 
== ELF Header ==
 
=== Struct ===
 
<source lang="C">
  typedef struct {
    uint8_t e_ident[16];              /* ELF identification */
    uint16_t e_type;                  /* object file type */
    uint16_t e_machine;              /* machine type */
    uint32_t e_version;              /* object file version */
    uint32_t e_entry;                /* entry point address */
    uint32_t e_phoff;                /* program header offset */
    uint32_t e_shoff;                /* section header offset */
    uint32_t e_flags;                /* processor-specific flags */
    uint16_t e_ehsize;                /* ELF header size */
    uint16_t e_phentsize;            /* size of program header entry */
    uint16_t e_phnum;                /* number of program header entries */
    uint16_t e_shentsize;            /* size of section header entry */
    uint16_t e_shnum;                /* number of section header entries */
    uint16_t e_shstrndx;              /* section name string table index */
  } __attribute__((packed)) ELF;
</source>
 
=== Table ===
 
{| class="wikitable sortable"
! Name of the variable !! Offset !! Size !! Notes
|-
| e_ident[0..3] || elf_offset+(0,1,2,3) || 4 || Magic
|-
| e_ident[4] || elf_offset+4 || 1 || Class Type must be [ELFCLASS32 = 0x01]
|-
| e_ident[5] || elf_offset+5 || 1 || Data Type must be [ELFDATA2LSB (i.e. le) = 0x01]
|-
| e_ident[6] || elf_offset+6 || 1 || File version (must be 0x1)
|-
| e_ident[7..15] || elf_offset+(6->15) || 1 || unused
|-
| e_type || elf_offset+0x10 || 2 || [[SELF_File_Format#SCE-specific_e_type|SCE-specific e_type]]
|-
| e_machine || elf_offset+0x12 || 2 || Machine type must be [EM_ARM = 0x0028]
|-
| e_version || elf_offset+0x14 || 4 || elf version (must be 0x00000001)
|-
| e_entry || elf_offset+0x18 ||    4 || Address to jump to in order to start program
|-
| e_phoff || elf_offset+0x1c ||    4 || boundary checked, but unused (already given by SELF header)
|-
| e_shoff || elf_offset+0x20 ||    4 || unused
|-
| e_flags || elf_offset+0x24 ||    4 || unused
|-
| e_ehsize || elf_offset+0x28 ||    2 || Must be sizeof(Elf32_Ehdr) = 0x0034
|-
| e_phentsize || elf_offset+0x2a ||    2 || Must be sizeof(Elf32_Phdr) = 0x0020
|-
| e_phnum || elf_offset+0x2c ||    2 || Count of Program Header in this elf
|-
| e_shentsize || elf_offset+0x2e ||    2 || unused
|-
| e_shnum || elf_offset+0x30 ||    2 || unused
|-
| e_shstrndx || elf_offset+0x32 ||    2 || unused
|}
 
== ELF Program Headers ==
 
=== Struct ===
 
<source lang="C">
  typedef struct {
    uint32_t p_type;                  /* type of segment */
    uint32_t p_flags;                /* segment attributes */
    uint64_t p_offset;                /* offset in file */
    uint64_t p_vaddr;                /* virtual address in memory */
    uint64_t p_paddr;                /* reserved */
    uint64_t p_filesz;                /* size of segment in file */
    uint64_t p_memsz;                /* size of segment in memory */
    uint64_t p_align;                /* alignment of segment */
  } __attribute__((packed)) ELF_PHDR;
</source>
 
=== Table ===
 
=== Comments ===
See Spec here: [http://www.sco.com/developers/gabi/latest/ch5.pheader.html ELF Program Headers]  
 
== ELF Section Headers ==
 
=== Struct ===
 
<source lang="C">
  typedef struct {
    uint32_t sh_name;                /* section name */
    uint32_t sh_type;                /* section type */
    uint64_t sh_flags;                /* section attributes */
    uint64_t sh_addr;                /* virtual address in memory */
    uint64_t sh_offset;              /* offset in file */
    uint64_t sh_size;                /* size of section */
    uint32_t sh_link;                /* link to other section */
    uint32_t sh_info;                /* miscellaneous information */
    uint64_t sh_addralign;            /* address alignment boundary */
    uint64_t sh_entsize;              /* size of entries, if section has table */
  } __attribute__((packed)) ELF_SHDR;
</source>
 
=== Table ===
 
=== Comments ===
Please note that all contributions to Vita Developer wiki are considered to be released under the GNU Free Documentation License 1.2 (see Vita Developer wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)