made text and data ELF regions compulsory

This commit is contained in:
applestash
2014-08-29 21:50:18 +10:00
parent 64665019c3
commit 61da4a1107
2 changed files with 12 additions and 6 deletions
+7 -2
View File
@@ -113,7 +113,8 @@ finish:
if(result == NOT_ELF_FILE) fprintf(stderr,"[ELF ERROR] Not ELF File\n");
else if(result == NOT_ARM_ELF) fprintf(stderr,"[ELF ERROR] Not ARM ELF\n");
else if(result == NON_EXECUTABLE_ELF) fprintf(stderr,"[ELF ERROR] Not Executeable ELF\n");
else if(result == NOT_FIND_CODE_SECTIONS) fprintf(stderr,"[ELF ERROR] Failed to retrieve code sections from ELF\n");
else if(result == NOT_FIND_TEXT_SEGMENT) fprintf(stderr,"[ELF ERROR] Failed to retrieve text sections from ELF\n");
else if(result == NOT_FIND_DATA_SEGMENT) fprintf(stderr,"[ELF ERROR] Failed to retrieve data sections from ELF\n");
else fprintf(stderr,"[ELF ERROR] Failed to process ELF file (%d)\n",result);
}
for(int i = 0; i < elf->activeSegments; i++)
@@ -239,9 +240,13 @@ int CreateExeFsCode(elf_context *elf, u8 *elfFile, ncch_settings *set)
result = CreateCodeSegmentFromElf(&rwdata,elf,elfFile,set->rsfSet->ExeFs.ReadWrite,set->rsfSet->ExeFs.ReadWriteNum);
if(result) return result;
/* Checking the existence of essential ELF Segments */
if(!text.size) return NOT_FIND_TEXT_SEGMENT;
if(!rwdata.size) return NOT_FIND_DATA_SEGMENT;
/* Allocating Buffer for ExeFs Code */
u32 size = (text.maxPageNum + rodata.maxPageNum + rwdata.maxPageNum)*elf->pageSize;
u8 *code = malloc(size);
u8 *code = calloc(1,size);
/* Writing Code into Buffer */
u8 *textPos = (code + 0);