sce-elf.h (3788B)
1 #ifndef SCE_ELF_H 2 #define SCE_ELF_H 3 4 #include "vita-elf.h" 5 6 /* SCE-specific definitions for e_type: */ 7 #define ET_SCE_EXEC 0xFE00 /* SCE Executable file */ 8 #define ET_SCE_RELEXEC 0xFE04 /* SCE Relocatable file */ 9 #define ET_SCE_STUBLIB 0xFE0C /* SCE SDK Stubs */ 10 #define ET_SCE_DYNAMIC 0xFE18 /* Unused */ 11 #define ET_SCE_PSPRELEXEC 0xFFA0 /* Unused (PSP ELF only) */ 12 #define ET_SCE_PPURELEXEC 0xFFA4 /* Unused (SPU ELF only) */ 13 #define ET_SCE_UNK 0xFFA5 /* Unknown */ 14 15 /* SCE-specific definitions for sh_type: */ 16 #define SHT_SCE_RELA 0x60000000 /* SCE Relocations */ 17 #define SHT_SCENID 0x61000001 /* Unused (PSP ELF only) */ 18 #define SHT_SCE_PSPRELA 0x700000A0 /* Unused (PSP ELF only) */ 19 #define SHT_SCE_ARMRELA 0x700000A4 /* Unused (PSP ELF only) */ 20 21 /* SCE-specific definitions for p_type: */ 22 #define PT_SCE_RELA 0x60000000 /* SCE Relocations */ 23 #define PT_SCE_COMMENT 0x6FFFFF00 /* Unused */ 24 #define PT_SCE_VERSION 0x6FFFFF01 /* Unused */ 25 #define PT_SCE_UNK 0x70000001 /* Unknown */ 26 #define PT_SCE_PSPRELA 0x700000A0 /* Unused (PSP ELF only) */ 27 #define PT_SCE_PPURELA 0x700000A4 /* Unused (SPU ELF only) */ 28 29 #define NID_MODULE_STOP 0x79F8E492 30 #define NID_MODULE_EXIT 0x913482A9 31 #define NID_MODULE_START 0x935CD196 32 #define NID_MODULE_INFO 0x6C2224BA 33 #define NID_PROCESS_PARAM 0x70FBA1E7 34 35 typedef union { 36 Elf32_Word r_short : 4; 37 struct { 38 Elf32_Word r_short : 4; 39 Elf32_Word r_symseg : 4; 40 Elf32_Word r_code : 8; 41 Elf32_Word r_datseg : 4; 42 Elf32_Word r_offset_lo : 12; 43 Elf32_Word r_offset_hi : 20; 44 Elf32_Word r_addend : 12; 45 } r_short_entry; 46 struct { 47 Elf32_Word r_short : 4; 48 Elf32_Word r_symseg : 4; 49 Elf32_Word r_code : 8; 50 Elf32_Word r_datseg : 4; 51 Elf32_Word r_code2 : 8; 52 Elf32_Word r_dist2 : 4; 53 Elf32_Word r_addend; 54 Elf32_Word r_offset; 55 } r_long_entry; 56 struct { 57 Elf32_Word r_word1; 58 Elf32_Word r_word2; 59 Elf32_Word r_word3; 60 } r_raw_entry; 61 } SCE_Rel; 62 63 #define SCE_ELF_DEFS_HOST 64 #include "sce-elf-defs.h" 65 #undef SCE_ELF_DEFS_HOST 66 67 #define SCE_ELF_DEFS_TARGET 68 #include "sce-elf-defs.h" 69 #undef SCE_ELF_DEFS_TARGET 70 71 /* This struct must only contain Elf32_Words, because we use it as an array in sce-elf.c */ 72 typedef struct { 73 Elf32_Word sceModuleInfo_rodata; /* The sce_module_info structure */ 74 Elf32_Word sceLib_ent; /* All sce_module_exports structures */ 75 Elf32_Word sceExport_rodata; /* The tables referenced by sce_module_exports */ 76 Elf32_Word sceLib_stubs; /* All sce_module_imports structures */ 77 Elf32_Word sceImport_rodata; /* Misc data referenced by sce_module_imports */ 78 Elf32_Word sceFNID_rodata; /* The imported function NID arrays */ 79 Elf32_Word sceFStub_rodata; /* The imported function pointer arrays */ 80 Elf32_Word sceVNID_rodata; /* The imported function NID arrays */ 81 Elf32_Word sceVStub_rodata; /* The imported function NID arrays */ 82 } sce_section_sizes_t; 83 84 sce_module_info_t *sce_elf_module_info_create(vita_elf_t *ve, vita_export_t *exports); 85 86 int sce_elf_module_info_get_size(sce_module_info_t *module_info, sce_section_sizes_t *sizes); 87 88 void sce_elf_module_info_free(sce_module_info_t *module_info); 89 90 void *sce_elf_module_info_encode( 91 const sce_module_info_t *module_info, const vita_elf_t *ve, const sce_section_sizes_t *sizes, 92 vita_elf_rela_table_t *rtable); 93 94 int sce_elf_write_module_info( 95 Elf *dest, const vita_elf_t *ve, const sce_section_sizes_t *sizes, void *module_info); 96 97 int sce_elf_discard_invalid_relocs(const vita_elf_t *ve, vita_elf_rela_table_t *rtable); 98 99 int sce_elf_write_rela_sections( 100 Elf *dest, const vita_elf_t *ve, const vita_elf_rela_table_t *rtable); 101 102 int sce_elf_rewrite_stubs(Elf *dest, const vita_elf_t *ve); 103 104 int sce_elf_set_headers(FILE *outfile, const vita_elf_t *ve); 105 106 const uint32_t sce_elf_stub_func[3]; 107 108 #endif