5858#define BOOT_MAGIC_ELF_SIZE 3
5959#define VER_ELF_1 (1 << 0)
6060#define VER_ELF_2 (1 << 1)
61+ #define VER_ELF_4 (1 << 3)
6162
6263#define OUT_ELF (1 << 0) /* Same output format: ELF container */
6364#define OUT_AND (1 << 1) /* Different output format: standard Android container */
@@ -94,7 +95,7 @@ struct boot_img_hdr
9495 uint32_t id [8 ]; /* timestamp / checksum / sha1 / etc */
9596};
9697
97- struct boot_img_elf_hdr
98+ struct boot_img_elf_hdr_32
9899{
99100 /* Global structure of the Sony ELF header - Respective usual values: | 8960 | 8974 | */
100101 uint8_t magic [8 ]; /* .ELF (0x00 to 0x07) | .ELF... | .ELF... | */
@@ -114,12 +115,36 @@ struct boot_img_elf_hdr
114115 uint16_t shstrndx ; /* boot shstrndx (0x32 to 0x33) | 0x00 | 0x00 | */
115116};
116117
118+ struct __attribute__((packed )) boot_img_elf_hdr
119+ {
120+ /* Global structure of the Sony ELF header - Respective usual values: | 8996 | */
121+ uint8_t magic [8 ]; /* .ELF (0x00 to 0x07) | .ELF... | */
122+ uint8_t unused [8 ]; /* unused chars (0x08 to 0x0F) | 0x00 | */
123+ uint16_t type ; /* boot type (0x10 to 0x11) | 0x02 | */
124+ uint16_t machine ; /* boot machine (0x12 to 0x13) | 0x28 | */
125+ uint32_t version ; /* boot version (0x14 to 0x17) | 0x01 | */
126+ uint64_t entry_addr ; /* boot entry (0x18 to 0x1F) | 0x80080000 | */
127+ uint64_t phoff ; /* boot phoff (0x20 to 0x27) | 0x40 | */
128+ uint64_t shoff ; /* boot shoff (0x28 to 0x2F) | 0x0214.... | */
129+ uint32_t flags ; /* boot flags (0x30 to 0x33) | 0x00 | */
130+ uint16_t ehsize ; /* boot ehsize (0x34 to 0x35) | 0x40 | */
131+ uint16_t phentsize ; /* boot phentsize (0x36 to 0x37) | 0x38 | */
132+ uint16_t phnum ; /* boot phnum (0x38 to 0x39) | 0x03 | */
133+ uint16_t shentsize ; /* boot shentsize (0x3A to 0x3B) | 0x40 | */
134+ uint16_t shnum ; /* boot shnum (0x3C to 0x3D) | 0x01 | */
135+ uint16_t shstrndx ; /* boot shstrndx (0x3E to 0x3F) | 0x00 | */
136+ };
137+
117138struct boot_img_elf_info
118139{
119- struct boot_img_elf_hdr hdr ; /* The ELF file header. */
120- struct boot_img_elf_prog_hdr * prog ; /* The program header entries. */
121- struct boot_img_elf_sect_hdr * sect ; /* The section header entries. */
122- struct boot_img_elf_misc_hdr * misc ; /* Miscellaneous information found in some ELF versions. */
140+ struct boot_img_elf_hdr hdr ; /* The ELF file header (64 bits). */
141+ struct boot_img_elf_hdr_32 hdr_32 ; /* The ELF file header (32 bits). */
142+ struct boot_img_elf_prog_hdr * prog ; /* The program header entries (64 bits). */
143+ struct boot_img_elf_prog_hdr_32 * prog_32 ; /* The program header entries (32 bits). */
144+ struct boot_img_elf_sect_hdr * sect ; /* The section header entries (64 bits). */
145+ struct boot_img_elf_sect_hdr_32 * sect_32 ; /* The section header entries (32 bits). */
146+ struct boot_img_elf_misc_hdr * misc ; /* Miscellaneous information found in some ELF versions. */
147+ uint8_t elf_architecture ;
123148 uint8_t elf_version ;
124149 uint8_t elf_out_format ;
125150 uint32_t cmdline_size ;
@@ -129,7 +154,7 @@ struct boot_img_elf_info
129154 uint32_t cmdline_signature_cnt ;
130155};
131156
132- struct boot_img_elf_prog_hdr
157+ struct boot_img_elf_prog_hdr_32
133158{
134159 uint32_t type ; /* type (position + 0x0 to 0x3) */
135160 uint32_t offset ; /* offset (position + 0x4 to 0x7) */
@@ -141,7 +166,19 @@ struct boot_img_elf_prog_hdr
141166 uint32_t align ; /* alignment (position + 0x1C to 0x1F)*/
142167};
143168
144- struct boot_img_elf_sect_hdr
169+ struct __attribute__((packed )) boot_img_elf_prog_hdr
170+ {
171+ uint64_t type ; /* type (position + 0x0 to 0x3) */
172+ uint64_t offset ; /* offset (position + 0x4 to 0x7) */
173+ uint64_t vaddr ; /* address (position + 0x8 to 0xF) */
174+ uint64_t paddr ; /* address duplicate (position + 0x10 to 0x17) */
175+ uint64_t size ; /* size (position + 0x18 to 0x1F) */
176+ uint64_t msize ; /* size duplicate (position + 0x20 to 0x23) */
177+ uint32_t flags ; /* flags (position + 0x24 to 0x27) */
178+ uint32_t align ; /* alignment (position + 0x28 to 0x2B)*/
179+ };
180+
181+ struct boot_img_elf_sect_hdr_32
145182{
146183 uint32_t name ;
147184 uint32_t type ;
@@ -152,6 +189,18 @@ struct boot_img_elf_sect_hdr
152189 uint8_t misc [16 ];
153190};
154191
192+ struct __attribute__((packed )) boot_img_elf_sect_hdr
193+ {
194+ uint32_t name ;
195+ uint64_t type ;
196+ uint32_t flags ;
197+ uint64_t addr ;
198+ uint64_t offset ;
199+ uint64_t size ;
200+ uint8_t misc [16 ];
201+ uint8_t padding [8 ];
202+ };
203+
155204struct boot_img_elf_misc_hdr
156205{
157206 uint8_t * data ; /* header additional data */
0 commit comments