elf2rpl: Change fixLoaderVirtualAddress to use section type instead of name.

This commit is contained in:
James Benton 2018-05-25 00:17:22 +01:00
parent a1072fc729
commit 11adfb8f07

View File

@ -698,39 +698,22 @@ fixLoaderVirtualAddresses(ElfFile &file)
{ {
auto addr = LoadBaseAddress; auto addr = LoadBaseAddress;
// All symbols pointing to this section require fixing for (auto &section : file.sections) {
if (section->header.type == elf::SHT_RPL_EXPORTS) {
if (auto section = getSectionByName(file, ".fexports")) { relocateSection(file, *section,
relocateSection(file, *section, align_up(addr, section->header.addralign));
align_up(addr, section->header.addralign)); addr += section->data.size();
addr += section->data.size(); }
} }
if (auto section = getSectionByName(file, ".dexports")) { for (auto &section : file.sections) {
relocateSection(file, *section, if (section->header.type == elf::SHT_SYMTAB ||
align_up(addr, section->header.addralign)); section->header.type == elf::SHT_STRTAB) {
addr += section->data.size(); relocateSection(file, *section,
} align_up(addr, section->header.addralign));
section->header.flags |= elf::SHF_ALLOC;
if (auto section = getSectionByName(file, ".symtab")) { addr += section->data.size();
relocateSection(file, *section, }
align_up(addr, section->header.addralign));
section->header.flags |= elf::SHF_ALLOC;
addr += section->data.size();
}
if (auto section = getSectionByName(file, ".strtab")) {
relocateSection(file, *section,
align_up(addr, section->header.addralign));
section->header.flags |= elf::SHF_ALLOC;
addr += section->data.size();
}
if (auto section = getSectionByName(file, ".shstrtab")) {
relocateSection(file, *section,
align_up(addr, section->header.addralign));
section->header.flags |= elf::SHF_ALLOC;
addr += section->data.size();
} }
for (auto &section : file.sections) { for (auto &section : file.sections) {