This commit is contained in:
jakcron
2015-10-06 10:42:28 +08:00
parent a8635fc601
commit 7ab299b57f
2 changed files with 31 additions and 15 deletions
+12 -1
View File
@@ -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);
} }
+5
View File
@@ -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