From 4c893afdcc4d7fbb7a166488ebc27672f35026fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 22 Oct 2014 05:50:34 +0200 Subject: [PATCH] (GX) Cleanups --- wii/app_booter/dolloader.c | 35 ++++++++++++++--------------------- wii/app_booter/elfloader.c | 17 +++++++---------- wii/app_booter/main.c | 7 +++++-- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/wii/app_booter/dolloader.c b/wii/app_booter/dolloader.c index 5f635e6c29..6f1d47d016 100644 --- a/wii/app_booter/dolloader.c +++ b/wii/app_booter/dolloader.c @@ -5,34 +5,27 @@ #define ARENA1_HI_LIMIT 0x81800000 -typedef struct _dolheader { - u32 text_pos[7]; - u32 data_pos[11]; - u32 text_start[7]; - u32 data_start[11]; - u32 text_size[7]; - u32 data_size[11]; - u32 bss_start; - u32 bss_size; - u32 entry_point; +typedef struct _dolheade +{ + u32 text_pos[7]; + u32 data_pos[11]; + u32 text_start[7]; + u32 data_start[11]; + u32 text_size[7]; + u32 data_size[11]; + u32 bss_start; + u32 bss_size; + u32 entry_point; } dolheader; u32 load_dol_image(const void *dolstart) { + u32 i; + dolheader *dolfile = NULL; if(!dolstart) return 0; - u32 i; - dolheader *dolfile = (dolheader *) dolstart; - -/* if (dolfile->bss_start > 0 && dolfile->bss_start < ARENA1_HI_LIMIT) { - u32 bss_size = dolfile->bss_size; - if (dolfile->bss_start + bss_size > ARENA1_HI_LIMIT) { - bss_size = ARENA1_HI_LIMIT - dolfile->bss_start; - } - memset((void *) dolfile->bss_start, 0, bss_size); - sync_before_exec((void *) dolfile->bss_start, bss_size); - } */ + dolfile = (dolheader *) dolstart; for (i = 0; i < 7; i++) { diff --git a/wii/app_booter/elfloader.c b/wii/app_booter/elfloader.c index e00311bd77..b6e2c3b517 100644 --- a/wii/app_booter/elfloader.c +++ b/wii/app_booter/elfloader.c @@ -27,9 +27,7 @@ * ====================================================================== */ s32 valid_elf_image (void *addr) { - Elf32_Ehdr *ehdr; /* Elf header structure pointer */ - - ehdr = (Elf32_Ehdr *) addr; + Elf32_Ehdr *ehdr = (Elf32_Ehdr *)addr; if (!IS_ELF (*ehdr)) return 0; @@ -49,13 +47,12 @@ s32 valid_elf_image (void *addr) * entry point address. * ====================================================================== */ -u32 load_elf_image (void *elfstart) { - Elf32_Ehdr *ehdr; - Elf32_Phdr *phdrs; +u32 load_elf_image (void *elfstart) +{ u8 *image; int i; - - ehdr = (Elf32_Ehdr *) elfstart; + Elf32_Phdr *phdrs = NULL; + Elf32_Ehdr *ehdr = (Elf32_Ehdr *) elfstart; if(ehdr->e_phoff == 0 || ehdr->e_phnum == 0) return 0; @@ -65,8 +62,8 @@ u32 load_elf_image (void *elfstart) { phdrs = (Elf32_Phdr*)(elfstart + ehdr->e_phoff); - for(i=0;ie_phnum;i++) { - + for(i=0;ie_phnum;i++) + { if(phdrs[i].p_type != PT_LOAD) continue; diff --git a/wii/app_booter/main.c b/wii/app_booter/main.c index 5a03b02315..6b8c8e4cc0 100644 --- a/wii/app_booter/main.c +++ b/wii/app_booter/main.c @@ -13,8 +13,10 @@ #define EXECUTABLE_MEM_ADDR 0x91800000 #define SYSTEM_ARGV ((struct __argv *) 0x93200000) -// if we name this main, GCC inserts the __eabi symbol, even when we specify -mno-eabi -// what a lovely "feature" +/* if we name this main, GCC inserts the __eabi symbol, + * even when we specify -mno-eabi. + */ + void app_booter_main(void) { void *exeBuffer = (void *) EXECUTABLE_MEM_ADDR; @@ -27,6 +29,7 @@ void app_booter_main(void) exeEntryPointAddress = load_dol_image(exeBuffer); exeEntryPoint = (entrypoint) exeEntryPointAddress; + if (!exeEntryPoint) return;