mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-06 00:39:11 +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){
|
if (elf->programHeaders[i].sizeInMemory != 0 && elf->programHeaders[i].type == PF_X){
|
||||||
InitSegment(&segment);
|
InitSegment(&segment);
|
||||||
|
|
||||||
|
printf("new segment\n");
|
||||||
|
|
||||||
foundFirstSection = false;
|
foundFirstSection = false;
|
||||||
size = 0;
|
size = 0;
|
||||||
sizeInMemory = elf->programHeaders[i].sizeInMemory;
|
sizeInMemory = elf->programHeaders[i].sizeInMemory;
|
||||||
@@ -965,10 +967,14 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
|
|||||||
if (IsIgnoreSection(elf->sections[curr]))
|
if (IsIgnoreSection(elf->sections[curr]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
if (!foundFirstSection) {
|
if (!foundFirstSection) {
|
||||||
if (elf->sections[curr].address != elf->programHeaders[i].virtualAddress)
|
if (elf->sections[curr].address != elf->programHeaders[i].virtualAddress)
|
||||||
continue;
|
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;
|
foundFirstSection = true;
|
||||||
segment.vAddr = elf->sections[curr].address;
|
segment.vAddr = elf->sections[curr].address;
|
||||||
segment.name = elf->sections[curr].name;
|
segment.name = elf->sections[curr].name;
|
||||||
@@ -977,6 +983,9 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
|
|||||||
size = elf->sections[curr].size;
|
size = elf->sections[curr].size;
|
||||||
}
|
}
|
||||||
else {
|
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]);
|
AddSegmentSection(&segment, &elf->sections[curr]);
|
||||||
padding = elf->sections[curr].address - (elf->sections[prev].address + elf->sections[prev].size);
|
padding = elf->sections[curr].address - (elf->sections[prev].address + elf->sections[prev].size);
|
||||||
size += padding + elf->sections[curr].size;
|
size += padding + elf->sections[curr].size;
|
||||||
@@ -1007,5 +1016,7 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
|
|||||||
|
|
||||||
bool IsIgnoreSection(elf_section_entry info)
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,11 @@ typedef struct
|
|||||||
#define SHT_GROUP 17
|
#define SHT_GROUP 17
|
||||||
#define SHT_SYMTAB_SHNDX 18
|
#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_WRITE 0x01 /* sh_flags */
|
||||||
#define SHF_ALLOC 0x02
|
#define SHF_ALLOC 0x02
|
||||||
|
|||||||
Reference in New Issue
Block a user