linker : loading PT_DYNAMIC , PT_DYNAMIC data

This commit is contained in:
georgemoralis 2023-05-26 19:22:43 +03:00
parent cc471a8535
commit 43033d6bf6
2 changed files with 27 additions and 0 deletions

View File

@ -109,6 +109,30 @@ void Linker::LoadModuleToMemory(Module* m)
LOG_ERROR_IF(debug_loader, "p_memsz==0 in type {}\n", m->elf->ElfPheaderTypeStr(elf_pheader[i].p_type)); LOG_ERROR_IF(debug_loader, "p_memsz==0 in type {}\n", m->elf->ElfPheaderTypeStr(elf_pheader[i].p_type));
} }
break; break;
case PT_DYNAMIC:
if (elf_pheader[i].p_filesz != 0)
{
void* dynamic = new u08[elf_pheader[i].p_filesz];
m->elf->LoadSegment(reinterpret_cast<u64>(dynamic), elf_pheader[i].p_offset, elf_pheader[i].p_filesz);
m->m_dynamic = dynamic;
}
else
{
LOG_ERROR_IF(debug_loader, "p_filesz==0 in type {}\n", m->elf->ElfPheaderTypeStr(elf_pheader[i].p_type));
}
break;
case PT_SCE_DYNLIBDATA:
if (elf_pheader[i].p_filesz != 0)
{
void* dynamic = new u08[elf_pheader[i].p_filesz];
m->elf->LoadSegment(reinterpret_cast<u64>(dynamic), elf_pheader[i].p_offset, elf_pheader[i].p_filesz);
m->m_dynamic_data = dynamic;
}
else
{
LOG_ERROR_IF(debug_loader, "p_filesz==0 in type {}\n", m->elf->ElfPheaderTypeStr(elf_pheader[i].p_type));
}
break;
default: default:
LOG_ERROR_IF(debug_loader, "Unimplemented type {}\n", m->elf->ElfPheaderTypeStr(elf_pheader[i].p_type)); LOG_ERROR_IF(debug_loader, "Unimplemented type {}\n", m->elf->ElfPheaderTypeStr(elf_pheader[i].p_type));
} }

View File

@ -8,6 +8,9 @@ struct Module
Elf* elf = nullptr; Elf* elf = nullptr;
u64 aligned_base_size = 0; u64 aligned_base_size = 0;
u64 base_virtual_addr = 0; //base virtual address u64 base_virtual_addr = 0; //base virtual address
void* m_dynamic = nullptr;
void* m_dynamic_data = nullptr;
}; };
class Linker class Linker