(wii/app_booter) Style nits

This commit is contained in:
twinaphex 2015-09-21 19:28:20 +02:00
parent 350dee9f51
commit 83c328d539
2 changed files with 404 additions and 373 deletions

View File

@ -25,30 +25,27 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /* This is the ELF ABI header file formerly known as "elf_abi.h". */
* This is the ELF ABI header file
* formerly known as "elf_abi.h".
*/
#ifndef _ELF_ABI_H #ifndef _ELF_ABI_H
#define _ELF_ABI_H #define _ELF_ABI_H
#include <stdint.h>
#include <gctypes.h> #include <gctypes.h>
/* /* This version doesn't work for 64-bit ABIs - Erik. */
* This version doesn't work for 64-bit ABIs - Erik.
*/
/* /* These typedefs need to be handled better. */
* These typedefs need to be handled better.
*/ typedef uint32_t Elf32_Addr; /* Unsigned program address */
typedef u32 Elf32_Addr; /* Unsigned program address */ typedef uint32_t Elf32_Off; /* Unsigned file offset */
typedef u32 Elf32_Off; /* Unsigned file offset */ typedef int32_t Elf32_Sword; /* Signed large integer */
typedef s32 Elf32_Sword; /* Signed large integer */ typedef uint32_t Elf32_Word; /* Unsigned large integer */
typedef u32 Elf32_Word; /* Unsigned large integer */ typedef uint16_t Elf32_Half; /* Unsigned medium integer */
typedef u16 Elf32_Half; /* Unsigned medium integer */
/* e_ident[] identification indexes */ /* e_ident[] identification indexes */
#define EI_MAG0 0 /* file ID */ #define EI_MAG0 0 /* file ID */
#define EI_MAG1 1 /* file ID */ #define EI_MAG1 1 /* file ID */
#define EI_MAG2 2 /* file ID */ #define EI_MAG2 2 /* file ID */
@ -62,6 +59,7 @@ typedef u16 Elf32_Half; /* Unsigned medium integer */
#define EI_NIDENT 16 /* Size of e_ident[] */ #define EI_NIDENT 16 /* Size of e_ident[] */
/* e_ident[] magic number */ /* e_ident[] magic number */
#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */ #define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
#define ELFMAG1 'E' /* e_ident[EI_MAG1] */ #define ELFMAG1 'E' /* e_ident[EI_MAG1] */
#define ELFMAG2 'L' /* e_ident[EI_MAG2] */ #define ELFMAG2 'L' /* e_ident[EI_MAG2] */
@ -70,6 +68,7 @@ typedef u16 Elf32_Half; /* Unsigned medium integer */
#define SELFMAG 4 /* size of magic */ #define SELFMAG 4 /* size of magic */
/* e_ident[] file class */ /* e_ident[] file class */
#define ELFCLASSNONE 0 /* invalid */ #define ELFCLASSNONE 0 /* invalid */
#define ELFCLASS32 1 /* 32-bit objs */ #define ELFCLASS32 1 /* 32-bit objs */
#define ELFCLASS64 2 /* 64-bit objs */ #define ELFCLASS64 2 /* 64-bit objs */
@ -82,6 +81,7 @@ typedef u16 Elf32_Half; /* Unsigned medium integer */
#define ELFDATANUM 3 /* number of data encode defines */ #define ELFDATANUM 3 /* number of data encode defines */
/* e_ident[] OS/ABI specific ELF extensions */ /* e_ident[] OS/ABI specific ELF extensions */
#define ELFOSABI_NONE 0 /* No extension specified */ #define ELFOSABI_NONE 0 /* No extension specified */
#define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */ #define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
#define ELFOSABI_NETBSD 2 /* NetBSD */ #define ELFOSABI_NETBSD 2 /* NetBSD */
@ -93,19 +93,23 @@ typedef u16 Elf32_Half; /* Unsigned medium integer */
#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */ #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
#define ELFOSABI_MODESTO 11 /* Novell Modesto */ #define ELFOSABI_MODESTO 11 /* Novell Modesto */
#define ELFOSABI_OPENBSD 12 /* OpenBSD */ #define ELFOSABI_OPENBSD 12 /* OpenBSD */
/* 64-255 Architecture-specific value range */ /* 64-255 Architecture-specific value range */
/* e_ident[] ABI Version */ /* e_ident[] ABI Version */
#define ELFABIVERSION 0 #define ELFABIVERSION 0
/* e_ident */ /* e_ident */
#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ #define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
(ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
(ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
(ehdr).e_ident[EI_MAG3] == ELFMAG3) (ehdr).e_ident[EI_MAG3] == ELFMAG3)
/* ELF Header */ /* ELF Header */
typedef struct elfhdr{ typedef struct elfhdr
{
unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
Elf32_Half e_type; /* object file type */ Elf32_Half e_type; /* object file type */
Elf32_Half e_machine; /* machine */ Elf32_Half e_machine; /* machine */
@ -124,6 +128,7 @@ typedef struct elfhdr{
} Elf32_Ehdr; } Elf32_Ehdr;
/* e_type */ /* e_type */
#define ET_NONE 0 /* No file type */ #define ET_NONE 0 /* No file type */
#define ET_REL 1 /* relocatable file */ #define ET_REL 1 /* relocatable file */
#define ET_EXEC 2 /* executable file */ #define ET_EXEC 2 /* executable file */
@ -136,6 +141,7 @@ typedef struct elfhdr{
#define ET_HIPROC 0xffff /* specific e_type */ #define ET_HIPROC 0xffff /* specific e_type */
/* e_machine */ /* e_machine */
#define EM_NONE 0 /* No Machine */ #define EM_NONE 0 /* No Machine */
#define EM_M32 1 /* AT&T WE 32100 */ #define EM_M32 1 /* AT&T WE 32100 */
#define EM_SPARC 2 /* SPARC */ #define EM_SPARC 2 /* SPARC */
@ -153,16 +159,18 @@ typedef struct elfhdr{
#define EM_SPARC64 11 /* RESERVED - was SPARC v9 #define EM_SPARC64 11 /* RESERVED - was SPARC v9
64-bit unoffical */ 64-bit unoffical */
#endif #endif
/* RESERVED 11-14 for future use */ /* RESERVED 11-14 for future use */
#define EM_PARISC 15 /* HPPA */ #define EM_PARISC 15 /* HPPA */
/* RESERVED 16 for future use */ /* RESERVED 16 for future use */
#define EM_VPP500 17 /* Fujitsu VPP500 */ #define EM_VPP500 17 /* Fujitsu VPP500 */
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
#define EM_960 19 /* Intel 80960 */ #define EM_960 19 /* Intel 80960 */
#define EM_PPC 20 /* PowerPC */ #define EM_PPC 20 /* PowerPC */
#define EM_PPC64 21 /* 64-bit PowerPC */ #define EM_PPC64 21 /* 64-bit PowerPC */
#define EM_S390 22 /* IBM System/390 Processor */ #define EM_S390 22 /* IBM System/390 Processor */
/* RESERVED 23-35 for future use */ /* RESERVED 23-35 for future use */
#define EM_V800 36 /* NEC V800 */ #define EM_V800 36 /* NEC V800 */
#define EM_FR20 37 /* Fujitsu FR20 */ #define EM_FR20 37 /* Fujitsu FR20 */
#define EM_RH32 38 /* TRW RH-32 */ #define EM_RH32 38 /* TRW RH-32 */
@ -183,7 +191,7 @@ typedef struct elfhdr{
#define EM_68HC12 53 /* Motorola M68HC12 */ #define EM_68HC12 53 /* Motorola M68HC12 */
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
#define EM_PCP 55 /* Siemens PCP */ #define EM_PCP 55 /* Siemens PCP */
#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ #define EM_NCPU 56 /* Sony nCPU embedded RISC */
#define EM_NDR1 57 /* Denso NDR1 microprocessor */ #define EM_NDR1 57 /* Denso NDR1 microprocessor */
#define EM_STARCORE 58 /* Motorola Start*Core processor */ #define EM_STARCORE 58 /* Motorola Start*Core processor */
#define EM_ME16 59 /* Toyota ME16 processor */ #define EM_ME16 59 /* Toyota ME16 processor */
@ -191,7 +199,7 @@ typedef struct elfhdr{
#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ #define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
#define EM_X86_64 62 /* AMD x86-64 */ #define EM_X86_64 62 /* AMD x86-64 */
#define EM_PDSP 63 /* Sony DSP Processor */ #define EM_PDSP 63 /* Sony DSP Processor */
/* RESERVED 64,65 for future use */ /* RESERVED 64,65 for future use */
#define EM_FX66 66 /* Siemens FX66 microcontroller */ #define EM_FX66 66 /* Siemens FX66 microcontroller */
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ #define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
@ -221,12 +229,15 @@ typedef struct elfhdr{
#define EM_NUM 92 /* number of machine types */ #define EM_NUM 92 /* number of machine types */
/* Version */ /* Version */
#define EV_NONE 0 /* Invalid */ #define EV_NONE 0 /* Invalid */
#define EV_CURRENT 1 /* Current */ #define EV_CURRENT 1 /* Current */
#define EV_NUM 2 /* number of versions */ #define EV_NUM 2 /* number of versions */
/* Section Header */ /* Section Header */
typedef struct {
typedef struct
{
Elf32_Word sh_name; /* name - index into section header Elf32_Word sh_name; /* name - index into section header
string table section */ string table section */
Elf32_Word sh_type; /* type */ Elf32_Word sh_type; /* type */
@ -241,6 +252,7 @@ typedef struct {
} Elf32_Shdr; } Elf32_Shdr;
/* Special Section Indexes */ /* Special Section Indexes */
#define SHN_UNDEF 0 /* undefined */ #define SHN_UNDEF 0 /* undefined */
#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ #define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
#define SHN_LOPROC 0xff00 /* reserved range for processor */ #define SHN_LOPROC 0xff00 /* reserved range for processor */
@ -253,6 +265,7 @@ typedef struct {
#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */ #define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
/* sh_type */ /* sh_type */
#define SHT_NULL 0 /* inactive */ #define SHT_NULL 0 /* inactive */
#define SHT_PROGBITS 1 /* program defined information */ #define SHT_PROGBITS 1 /* program defined information */
#define SHT_SYMTAB 2 /* symbol table section */ #define SHT_SYMTAB 2 /* symbol table section */
@ -316,6 +329,7 @@ typedef struct {
#define ELF_TEXT ".text" /* code */ #define ELF_TEXT ".text" /* code */
/* Section Attribute Flags - sh_flags */ /* Section Attribute Flags - sh_flags */
#define SHF_WRITE 0x1 /* Writable */ #define SHF_WRITE 0x1 /* Writable */
#define SHF_ALLOC 0x2 /* occupies memory */ #define SHF_ALLOC 0x2 /* occupies memory */
#define SHF_EXECINSTR 0x4 /* executable */ #define SHF_EXECINSTR 0x4 /* executable */
@ -331,12 +345,15 @@ typedef struct {
/* specific section attributes */ /* specific section attributes */
/* Section Group Flags */ /* Section Group Flags */
#define GRP_COMDAT 0x1 /* COMDAT group */ #define GRP_COMDAT 0x1 /* COMDAT group */
#define GRP_MASKOS 0x0ff00000 /* Mask OS specific flags */ #define GRP_MASKOS 0x0ff00000 /* Mask OS specific flags */
#define GRP_MASKPROC 0xf0000000 /* Mask processor specific flags */ #define GRP_MASKPROC 0xf0000000 /* Mask processor specific flags */
/* Symbol Table Entry */ /* Symbol Table Entry */
typedef struct elf32_sym {
typedef struct elf32_sym
{
Elf32_Word st_name; /* name - index into string table */ Elf32_Word st_name; /* name - index into string table */
Elf32_Addr st_value; /* symbol value */ Elf32_Addr st_value; /* symbol value */
Elf32_Word st_size; /* symbol size */ Elf32_Word st_size; /* symbol size */
@ -346,15 +363,18 @@ typedef struct elf32_sym {
} Elf32_Sym; } Elf32_Sym;
/* Symbol table index */ /* Symbol table index */
#define STN_UNDEF 0 /* undefined */ #define STN_UNDEF 0 /* undefined */
/* Extract symbol info - st_info */ /* Extract symbol info - st_info */
#define ELF32_ST_BIND(x) ((x) >> 4) #define ELF32_ST_BIND(x) ((x) >> 4)
#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) #define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
#define ELF32_ST_VISIBILITY(x) ((x) & 0x3) #define ELF32_ST_VISIBILITY(x) ((x) & 0x3)
/* Symbol Binding - ELF32_ST_BIND - st_info */ /* Symbol Binding - ELF32_ST_BIND - st_info */
#define STB_LOCAL 0 /* Local symbol */ #define STB_LOCAL 0 /* Local symbol */
#define STB_GLOBAL 1 /* Global symbol */ #define STB_GLOBAL 1 /* Global symbol */
#define STB_WEAK 2 /* like global - lower precedence */ #define STB_WEAK 2 /* like global - lower precedence */
@ -378,6 +398,7 @@ typedef struct elf32_sym {
#define STT_HIPROC 15 /* specific symbol types */ #define STT_HIPROC 15 /* specific symbol types */
/* Symbol visibility - ELF32_ST_VISIBILITY - st_other */ /* Symbol visibility - ELF32_ST_VISIBILITY - st_other */
#define STV_DEFAULT 0 /* Normal visibility rules */ #define STV_DEFAULT 0 /* Normal visibility rules */
#define STV_INTERNAL 1 /* Processor specific hidden class */ #define STV_INTERNAL 1 /* Processor specific hidden class */
#define STV_HIDDEN 2 /* Symbol unavailable in other mods */ #define STV_HIDDEN 2 /* Symbol unavailable in other mods */
@ -385,6 +406,7 @@ typedef struct elf32_sym {
/* Relocation entry with implicit addend */ /* Relocation entry with implicit addend */
typedef struct typedef struct
{ {
Elf32_Addr r_offset; /* offset of relocation */ Elf32_Addr r_offset; /* offset of relocation */
@ -392,6 +414,7 @@ typedef struct
} Elf32_Rel; } Elf32_Rel;
/* Relocation entry with explicit addend */ /* Relocation entry with explicit addend */
typedef struct typedef struct
{ {
Elf32_Addr r_offset; /* offset of relocation */ Elf32_Addr r_offset; /* offset of relocation */
@ -400,12 +423,14 @@ typedef struct
} Elf32_Rela; } Elf32_Rela;
/* Extract relocation info - r_info */ /* Extract relocation info - r_info */
#define ELF32_R_SYM(i) ((i) >> 8) #define ELF32_R_SYM(i) ((i) >> 8)
#define ELF32_R_TYPE(i) ((unsigned char) (i)) #define ELF32_R_TYPE(i) ((unsigned char) (i))
#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t)) #define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
/* Program Header */ /* Program Header */
typedef struct { typedef struct
{
Elf32_Word p_type; /* segment type */ Elf32_Word p_type; /* segment type */
Elf32_Off p_offset; /* segment offset */ Elf32_Off p_offset; /* segment offset */
Elf32_Addr p_vaddr; /* virtual address of segment */ Elf32_Addr p_vaddr; /* virtual address of segment */
@ -417,6 +442,7 @@ typedef struct {
} Elf32_Phdr; } Elf32_Phdr;
/* Segment types - p_type */ /* Segment types - p_type */
#define PT_NULL 0 /* unused */ #define PT_NULL 0 /* unused */
#define PT_LOAD 1 /* loadable segment */ #define PT_LOAD 1 /* loadable segment */
#define PT_DYNAMIC 2 /* dynamic linking section */ #define PT_DYNAMIC 2 /* dynamic linking section */
@ -438,6 +464,7 @@ typedef struct {
#define PF_MASKOS 0x0ff00000 /* OS specific segment flags */ #define PF_MASKOS 0x0ff00000 /* OS specific segment flags */
#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ #define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
/* specific segment flags */ /* specific segment flags */
/* Dynamic structure */ /* Dynamic structure */
typedef struct typedef struct
{ {
@ -452,6 +479,7 @@ typedef struct
extern Elf32_Dyn _DYNAMIC[]; extern Elf32_Dyn _DYNAMIC[];
/* Dynamic Array Tags - d_tag */ /* Dynamic Array Tags - d_tag */
#define DT_NULL 0 /* marks end of _DYNAMIC array */ #define DT_NULL 0 /* marks end of _DYNAMIC array */
#define DT_NEEDED 1 /* string table offset of needed lib */ #define DT_NEEDED 1 /* string table offset of needed lib */
#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */ #define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
@ -467,8 +495,7 @@ extern Elf32_Dyn _DYNAMIC[];
#define DT_INIT 12 /* address of initialization func. */ #define DT_INIT 12 /* address of initialization func. */
#define DT_FINI 13 /* address of termination function */ #define DT_FINI 13 /* address of termination function */
#define DT_SONAME 14 /* string table offset of shared obj */ #define DT_SONAME 14 /* string table offset of shared obj */
#define DT_RPATH 15 /* string table offset of library #define DT_RPATH 15 /* string table offset of library search path */
search path */
#define DT_SYMBOLIC 16 /* start sym search in shared obj. */ #define DT_SYMBOLIC 16 /* start sym search in shared obj. */
#define DT_REL 17 /* address of rel. tbl. w addends */ #define DT_REL 17 /* address of rel. tbl. w addends */
#define DT_RELSZ 18 /* size of DT_REL relocation table */ #define DT_RELSZ 18 /* size of DT_REL relocation table */
@ -494,21 +521,21 @@ extern Elf32_Dyn _DYNAMIC[];
#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ #define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
/* Dynamic Tag Flags - d_un.d_val */ /* Dynamic Tag Flags - d_un.d_val */
#define DF_ORIGIN 0x01 /* Object may use DF_ORIGIN */ #define DF_ORIGIN 0x01 /* Object may use DF_ORIGIN */
#define DF_SYMBOLIC 0x02 /* Symbol resolutions starts here */ #define DF_SYMBOLIC 0x02 /* Symbol resolutions starts here */
#define DF_TEXTREL 0x04 /* Object contains text relocations */ #define DF_TEXTRE 0x04 /* Object contains text relocations */
#define DF_BIND_NOW 0x08 /* No lazy binding for this object */ #define DF_BIND_NOW 0x08 /* No lazy binding for this object */
#define DF_STATIC_TLS 0x10 /* Static thread local storage */ #define DF_STATIC_TLS 0x10 /* Static thread local storage */
/* Standard ELF hashing function */ /* Standard ELF hashing function */
unsigned long elf_hash(const unsigned char *name); unsigned long elf_hash(const unsigned char *name);
#define ELF_TARG_VER 1 /* The ver for which this code is intended */ #define ELF_TARG_VER 1 /* The ver for which this code is intended */
/* /* XXX - PowerPC defines really don't belong in here,
* XXX - PowerPC defines really don't belong in here, * but we'll put them in for simplicity. */
* but we'll put them in for simplicity.
*/
/* Values for Elf32/64_Ehdr.e_flags. */ /* Values for Elf32/64_Ehdr.e_flags. */
#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ #define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
@ -519,6 +546,7 @@ unsigned long elf_hash(const unsigned char *name);
flag */ flag */
/* PowerPC relocations defined by the ABIs */ /* PowerPC relocations defined by the ABIs */
#define R_PPC_NONE 0 #define R_PPC_NONE 0
#define R_PPC_ADDR32 1 /* 32bit absolute address */ #define R_PPC_ADDR32 1 /* 32bit absolute address */
#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ #define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
@ -561,6 +589,7 @@ unsigned long elf_hash(const unsigned char *name);
/* The remaining relocs are from the Embedded ELF ABI, and are not /* The remaining relocs are from the Embedded ELF ABI, and are not
in the SVR4 ELF ABI. */ in the SVR4 ELF ABI. */
#define R_PPC_EMB_NADDR32 101 #define R_PPC_EMB_NADDR32 101
#define R_PPC_EMB_NADDR16 102 #define R_PPC_EMB_NADDR16 102
#define R_PPC_EMB_NADDR16_LO 103 #define R_PPC_EMB_NADDR16_LO 103

View File

@ -2,6 +2,7 @@
This code is licensed to you under the terms of the GNU GPL, version 2; This code is licensed to you under the terms of the GNU GPL, version 2;
see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <stdarg.h> #include <stdarg.h>
#include "string.h" #include "string.h"
@ -9,22 +10,22 @@
#include "elf_abi.h" #include "elf_abi.h"
#define EXECUTABLE_MEM_ADDR 0x91800000
#define SYSTEM_ARGV ((struct __argv *) 0x93200000) #define SYSTEM_ARGV ((struct __argv *) 0x93200000)
#define EXECUTABLE_MEM_ADDR 0x91800000
#define ARENA1_HI_LIMIT 0x81800000 #define ARENA1_HI_LIMIT 0x81800000
typedef struct _dolheade typedef struct _dolheade
{ {
u32 text_pos[7]; uint32_t text_pos[7];
u32 data_pos[11]; uint32_t data_pos[11];
u32 text_start[7]; uint32_t text_start[7];
u32 data_start[11]; uint32_t data_start[11];
u32 text_size[7]; uint32_t text_size[7];
u32 data_size[11]; uint32_t data_size[11];
u32 bss_start; uint32_t bss_start;
u32 bss_size; uint32_t bss_size;
u32 entry_point; uint32_t entry_point;
} dolheader; } dolheader;
typedef void (*entrypoint)(void); typedef void (*entrypoint)(void);
@ -68,7 +69,6 @@ static int32_t valid_elf_image (void *addr)
static uint32_t load_elf_image (void *elfstart) static uint32_t load_elf_image (void *elfstart)
{ {
u8 *image;
int i; int i;
Elf32_Phdr *phdrs = NULL; Elf32_Phdr *phdrs = NULL;
Elf32_Ehdr *ehdr = (Elf32_Ehdr*) elfstart; Elf32_Ehdr *ehdr = (Elf32_Ehdr*) elfstart;
@ -83,6 +83,8 @@ static uint32_t load_elf_image (void *elfstart)
for (i = 0; i < ehdr->e_phnum; i++) for (i = 0; i < ehdr->e_phnum; i++)
{ {
uint8_t *image;
if(phdrs[i].p_type != PT_LOAD) if(phdrs[i].p_type != PT_LOAD)
continue; continue;
@ -95,7 +97,7 @@ static uint32_t load_elf_image (void *elfstart)
if(!phdrs[i].p_filesz) if(!phdrs[i].p_filesz)
continue; continue;
image = (u8 *) (elfstart + phdrs[i].p_offset); image = (uint8_t*)(elfstart + phdrs[i].p_offset);
memcpy ((void *) phdrs[i].p_paddr, (const void *) image, phdrs[i].p_filesz); memcpy ((void *) phdrs[i].p_paddr, (const void *) image, phdrs[i].p_filesz);
sync_before_exec ((void *) phdrs[i].p_paddr, phdrs[i].p_memsz); sync_before_exec ((void *) phdrs[i].p_paddr, phdrs[i].p_memsz);
@ -106,7 +108,7 @@ static uint32_t load_elf_image (void *elfstart)
static uint32_t load_dol_image(const void *dolstart) static uint32_t load_dol_image(const void *dolstart)
{ {
u32 i; uint32_t i;
dolheader *dolfile = NULL; dolheader *dolfile = NULL;
if(!dolstart) if(!dolstart)
@ -141,9 +143,9 @@ static uint32_t load_dol_image(const void *dolstart)
void app_booter_main(void) void app_booter_main(void)
{ {
void *exeBuffer = (void*)EXECUTABLE_MEM_ADDR;
u32 exeEntryPointAddress = 0;
entrypoint exeEntryPoint; entrypoint exeEntryPoint;
uint32_t exeEntryPointAddress = 0;
void *exeBuffer = (void*)EXECUTABLE_MEM_ADDR;
if (valid_elf_image(exeBuffer) == 1) if (valid_elf_image(exeBuffer) == 1)
exeEntryPointAddress = load_elf_image(exeBuffer); exeEntryPointAddress = load_elf_image(exeBuffer);
@ -157,7 +159,7 @@ void app_booter_main(void)
if (SYSTEM_ARGV->argvMagic == ARGV_MAGIC) if (SYSTEM_ARGV->argvMagic == ARGV_MAGIC)
{ {
void *new_argv = (void *) (exeEntryPointAddress + 8); void *new_argv = (void*)(exeEntryPointAddress + 8);
memcpy(new_argv, SYSTEM_ARGV, sizeof(struct __argv)); memcpy(new_argv, SYSTEM_ARGV, sizeof(struct __argv));
sync_before_exec(new_argv, sizeof(struct __argv)); sync_before_exec(new_argv, sizeof(struct __argv));
} }