mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-02 16:59:03 +00:00
[makerom] Fixed ELF parsing bug. https://github.com/profi200/Project_CTR/pull/2#issuecomment-145699191
This commit is contained in:
+12
-1
@@ -955,6 +955,8 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
|
||||
if (elf->programHeaders[i].sizeInMemory != 0 && elf->programHeaders[i].type == PF_X){
|
||||
InitSegment(&segment);
|
||||
|
||||
printf("new segment\n");
|
||||
|
||||
foundFirstSection = false;
|
||||
size = 0;
|
||||
sizeInMemory = elf->programHeaders[i].sizeInMemory;
|
||||
@@ -965,10 +967,14 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
|
||||
if (IsIgnoreSection(elf->sections[curr]))
|
||||
continue;
|
||||
|
||||
|
||||
if (!foundFirstSection) {
|
||||
if (elf->sections[curr].address != elf->programHeaders[i].virtualAddress)
|
||||
continue;
|
||||
|
||||
printf("first section name: %s (vaddr = 0x%llx, size = 0x%llx)\n", elf->sections[curr].name, elf->sections[curr].address, elf->sections[curr].size);
|
||||
|
||||
|
||||
foundFirstSection = true;
|
||||
segment.vAddr = elf->sections[curr].address;
|
||||
segment.name = elf->sections[curr].name;
|
||||
@@ -977,6 +983,9 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
|
||||
size = elf->sections[curr].size;
|
||||
}
|
||||
else {
|
||||
|
||||
printf("follw section name: %s (vaddr = 0x%llx, size = 0x%llx)\n", elf->sections[curr].name, elf->sections[curr].address, elf->sections[curr].size);
|
||||
|
||||
AddSegmentSection(&segment, &elf->sections[curr]);
|
||||
padding = elf->sections[curr].address - (elf->sections[prev].address + elf->sections[prev].size);
|
||||
size += padding + elf->sections[curr].size;
|
||||
@@ -1007,5 +1016,7 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
|
||||
|
||||
bool IsIgnoreSection(elf_section_entry info)
|
||||
{
|
||||
return (info.type != SHT_PROGBITS && info.type != SHT_NOBITS && info.type != SHT_INIT_ARRAY && info.type != SHT_FINI_ARRAY);
|
||||
printf("%s:0x%x,0x%x\n", info.name, info.type, info.flags);
|
||||
|
||||
return (info.type != SHT_PROGBITS && info.type != SHT_NOBITS && info.type != SHT_INIT_ARRAY && info.type != SHT_FINI_ARRAY && info.type != SHT_ARM_EXIDX);
|
||||
}
|
||||
|
||||
+19
-14
@@ -79,26 +79,31 @@ typedef struct
|
||||
|
||||
/* Legal values for sh_type (section type). */
|
||||
|
||||
#define SHT_NULL 0 /* Section header table entry unused */
|
||||
#define SHT_PROGBITS 1 /* Program data */
|
||||
#define SHT_SYMTAB 2 /* Symbol table */
|
||||
#define SHT_STRTAB 3 /* String table */
|
||||
#define SHT_RELA 4 /* Relocation entries with addends */
|
||||
#define SHT_HASH 5 /* Symbol hash table */
|
||||
#define SHT_DYNAMIC 6 /* Dynamic linking information */
|
||||
#define SHT_NOTE 7 /* Notes */
|
||||
#define SHT_NOBITS 8 /* Program space with no data (bss) */
|
||||
#define SHT_REL 9 /* Relocation entries, no addends */
|
||||
#define SHT_SHLIB 10 /* Reserved */
|
||||
#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
|
||||
#define SHT_NULL 0 /* Section header table entry unused */
|
||||
#define SHT_PROGBITS 1 /* Program data */
|
||||
#define SHT_SYMTAB 2 /* Symbol table */
|
||||
#define SHT_STRTAB 3 /* String table */
|
||||
#define SHT_RELA 4 /* Relocation entries with addends */
|
||||
#define SHT_HASH 5 /* Symbol hash table */
|
||||
#define SHT_DYNAMIC 6 /* Dynamic linking information */
|
||||
#define SHT_NOTE 7 /* Notes */
|
||||
#define SHT_NOBITS 8 /* Program space with no data (bss) */
|
||||
#define SHT_REL 9 /* Relocation entries, no addends */
|
||||
#define SHT_SHLIB 10 /* Reserved */
|
||||
#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
|
||||
#define SHT_UNKNOWN12 12
|
||||
#define SHT_UNKNOWN13 13
|
||||
#define SHT_INIT_ARRAY 14
|
||||
#define SHT_FINI_ARRAY 15
|
||||
#define SHT_PREINIT_ARRAY 16
|
||||
#define SHT_GROUP 17
|
||||
#define SHT_GROUP 17
|
||||
#define SHT_SYMTAB_SHNDX 18
|
||||
#define SHT_NUM 19
|
||||
#define SHT_NUM 19
|
||||
#define SHT_ARM_EXIDX 0x70000001 /* Exception Index table */
|
||||
#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking pre-emption map*/
|
||||
#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility attributes */
|
||||
#define SHT_ARM_DEBUGOVERLAY 0x70000004
|
||||
#define SHT_ARM_OVERLAYSECTION 0x70000005
|
||||
|
||||
#define SHF_WRITE 0x01 /* sh_flags */
|
||||
#define SHF_ALLOC 0x02
|
||||
|
||||
Reference in New Issue
Block a user