SELF: Difference between revisions

From Vita Development Wiki
Jump to navigation Jump to search
 
Line 11: Line 11:


== Relocations ==
== Relocations ==
Relocations are stored within the PT_SCE_RELA segment.


Relocation entry format can be one of 10 types which is determined by the first 4 bits.
=== Format 0 ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Offset !! Size !! Description
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 0
|-
| 4 || 7 || Symbol segment index
|-
| 8 || 15 || Relocation type
|-
|-
| 0x0 || 0x4 || Relocation Type
| 16 || 19 || Patch segment index
|-
|-
| 0x4 || 0x4 || Long entry: Addend
| 20 || 27 || Second relocation type
|-
|-
| 0x4 || 0x4 || Short entry: 0-19 = Bits 10-29 of offset, 20-31 = addend
| 28 || 31 || Distance from offset (used for second relocation)
|-
|-
| 0x8 || 0x4 || Long entry: Offset
| 32 || 63 || Addend
|-
| 64 || 95 || Offset
|-
|-
|}
|}


Relocations can be of two types: 8 byte "short" entries or 12 byte "long" entries. The relocation code is the same as ARM ELF format.
=== Format 1 ===
{| class="wikitable"
|-
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 1
|-
| 4 || 7 || Symbol segment index
|-
| 8 || 15 || Relocation type
|-
| 16 || 19 || Patch segment index
|-
| 20 || 41 || Offset
|-
| 42 || 63 || Addend
|-
|}


=== Format 2 ===
{| class="wikitable"
|-
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 2
|-
| 4 || 7 || Symbol segment index
|-
| 8 || 15 || Relocation type
|-
| 16 || 31 || Offset
|-
| 32 || 64 || Addend
|}


Segment start = Buffer address of segment indexed at "Patch segment"
=== Format 3 ===
{| class="wikitable"
|-
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 3
|-
| 4 || 7 || Symbol segment index
|-
| 8 || 8 || Mode (ARM = 0, THUMB = 1)
|-
| 9 || 26 || Offset
|-
| 27 || 31 || Distance from offset
|-
| 32 || 64 || Addend
|-
|}


Symbol start = Buffer address of segment indexed at "Symbol segment"
=== Format 4 ===
{| class="wikitable"
|-
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 4
|-
| 4 || 26 || Offset
|-
| 27 || 31 || Distance from offset
|-
|}


Address to patch = segment start + offset
=== Format 5 ===
{| class="wikitable"
|-
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 5
|-
| 4 || 12 || Distance 1
|-
| 13 || 17 || Distance 2
|-
| 18 || 26 || Distance 3
|-
| 27 || 31 || Distance 4
|-
|}


P = address to patch
=== Format 6 ===
{| class="wikitable"
|-
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 6
|-
| 4 || 31 || Offset
|-
|}


S = "Symbol segment" == 15 ? 0 : symbol start
=== Format 7 ===
{| class="wikitable"
|-
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 7
|-
| 4 || 10 || Offset 1
|-
| 11 || 17 || Offset 2
|-
| 18 || 24 || Offset 3
|-
| 25 || 31 || Offset 4
|-
|}


A = addend
=== Format 8 ===
 
{| class="wikitable"
=== Relocation Type ===
|-
! Start !! End !! Description
|-
| 0 || 3 || Entry format type set to 8
|-
| 4 || 7 || Offset 1
|-
| 8 || 11 || Offset 2
|-
| 12 || 15 || Offset 3
|-
| 16 || 19 || Offset 4
|-
| 20 || 23 || Offset 5
|-
| 24 || 27 || Offset 6
|-
| 28 || 31 || Offset 7
|-
|}


=== Format 9 ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Start !! End !! Description
! Start !! End !! Description
|-
|-
| 0 || 3 || Short entry if set
| 0 || 3 || Entry format type set to 9
|-
| 4 || 5 || Offset 1
|-
| 6 || 7 || Offset 2
|-
| 8 || 9 || Offset 3
|-
| 10 || 11 || Offset 4
|-
| 12 || 13 || Offset 5
|-
| 14 || 15 || Offset 6
|-
| 16 || 17 || Offset 7
|-
| 18 || 19 || Offset 8
|-
|-
| 4 || 7 || Symbol segment
| 20 || 21 || Offset 9
|-
|-
| 8 || 15 || Relocation code
| 22 || 23 || Offset 10
|-
|-
| 16 || 19 || Patch segment
| 24 || 25 || Offset 11
|-
|-
| 20 || 27 || Long entry: Optional relocation code 2
| 26 || 27 || Offset 12
|-
|-
| 28 || 31 || Long entry: Optional distance 2
| 28 || 29 || Offset 13
|-
|-
| 20 || 31 || Short entry: Lower 12 bits of offset
| 30 || 31 || Offset 14
|-
|-
|}
|}


=== Supported Relocation Codes (1.69) ===
=== Supported Relocation Codes (3.60) ===


{| class="wikitable"
{| class="wikitable"

Revision as of 12:42, 26 February 2018

SELF files are a wrapper around encrypted ELF files. The encrypted header contains keys to decrypt each encrypted ELF program, which are decrypted and loaded individually. Because of this, a copy of the ELF headers and ELF program headers are stored in plain text next to the SCE header.

Authentication ID

Offset 0x80 in the SELF header. SceWebCore has 0x8000 set; the only system app with that flag set.

sceAppMgrConvertVs0UserDrivePath checks the authentication id to limit mount points.

0x2800000000008003 seen used by SceWebCore can only access vs0:data/external/cert/ and vs0:data/external/webcore/

0x2800000000008004 seen used by games and 0x210000101CD20007 seen used by PSM can only access vs0:data/external and vs0:sys/external

Relocations

Relocations are stored within the PT_SCE_RELA segment.

Relocation entry format can be one of 10 types which is determined by the first 4 bits.

Format 0

Start End Description
0 3 Entry format type set to 0
4 7 Symbol segment index
8 15 Relocation type
16 19 Patch segment index
20 27 Second relocation type
28 31 Distance from offset (used for second relocation)
32 63 Addend
64 95 Offset

Format 1

Start End Description
0 3 Entry format type set to 1
4 7 Symbol segment index
8 15 Relocation type
16 19 Patch segment index
20 41 Offset
42 63 Addend

Format 2

Start End Description
0 3 Entry format type set to 2
4 7 Symbol segment index
8 15 Relocation type
16 31 Offset
32 64 Addend

Format 3

Start End Description
0 3 Entry format type set to 3
4 7 Symbol segment index
8 8 Mode (ARM = 0, THUMB = 1)
9 26 Offset
27 31 Distance from offset
32 64 Addend

Format 4

Start End Description
0 3 Entry format type set to 4
4 26 Offset
27 31 Distance from offset

Format 5

Start End Description
0 3 Entry format type set to 5
4 12 Distance 1
13 17 Distance 2
18 26 Distance 3
27 31 Distance 4

Format 6

Start End Description
0 3 Entry format type set to 6
4 31 Offset

Format 7

Start End Description
0 3 Entry format type set to 7
4 10 Offset 1
11 17 Offset 2
18 24 Offset 3
25 31 Offset 4

Format 8

Start End Description
0 3 Entry format type set to 8
4 7 Offset 1
8 11 Offset 2
12 15 Offset 3
16 19 Offset 4
20 23 Offset 5
24 27 Offset 6
28 31 Offset 7

Format 9

Start End Description
0 3 Entry format type set to 9
4 5 Offset 1
6 7 Offset 2
8 9 Offset 3
10 11 Offset 4
12 13 Offset 5
14 15 Offset 6
16 17 Offset 7
18 19 Offset 8
20 21 Offset 9
22 23 Offset 10
24 25 Offset 11
26 27 Offset 12
28 29 Offset 13
30 31 Offset 14

Supported Relocation Codes (3.60)

Code Description
0 R_ARM_NONE
2 R_ARM_ABS32
3 R_ARM_REL32
10 R_ARM_THM_CALL
28 R_ARM_CALL
29 R_ARM_JUMP24
38 R_ARM_TARGET1 (same as R_ARM_ABS32)
40 R_ARM_V4BX (same as R_ARM_NONE)
41 R_ARM_TARGET2 (same as R_ARM_REL32)
42 R_ARM_PREL31
43 R_ARM_MOVW_ABS_NC
44 R_ARM_MOVT_ABS
47 R_ARM_THM_MOVW_ABS_NC
48 R_ARM_THM_MOVT_ABS