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){
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);
}