mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-06 13:58:18 +01:00
- added missing gcc_except_table section
- added ignore of paddings in elf2rpl
This commit is contained in:
parent
4981b49563
commit
be3bcba701
@ -151,14 +151,14 @@ SECTIONS {
|
||||
|
||||
/* Reserve space for the TLS segment of the main thread */
|
||||
__tls_start = .;
|
||||
|
||||
|
||||
__tbss_start = .;
|
||||
*(.tbss)
|
||||
*(.tbss.*)
|
||||
*(.gnu.linkonce.tb.*)
|
||||
*(.tcommon)
|
||||
__tbss_end = .;
|
||||
|
||||
|
||||
. += + SIZEOF(.tdata);
|
||||
__tls_end = .;
|
||||
. = ALIGN(32);
|
||||
@ -193,6 +193,7 @@ SECTIONS {
|
||||
/* Required compiler trash */
|
||||
.fixup ALIGN(32) : { *(.fixup*) }
|
||||
.got ALIGN(32) : { *(.got*) }
|
||||
.gcc_except_table ALIGN(32) : { *(.gcc_except_table*) }
|
||||
.hash ALIGN(32) : { *(.hash) }
|
||||
.dynsym ALIGN(32) : { *(.dynsym) }
|
||||
|
||||
|
@ -94,7 +94,7 @@ findSymbol(ElfFile &file, uint32_t address)
|
||||
return symbol.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (auto &symbol : file.symbols) {
|
||||
if (symbol->address == address) {
|
||||
return symbol.get();
|
||||
@ -238,6 +238,9 @@ read(ElfFile &file, const std::string &filename)
|
||||
case elf::R_PPC_RELATIVE:
|
||||
*ptr = byte_swap(addr);
|
||||
break;
|
||||
case elf::R_PPC_NONE:
|
||||
// ignore padding
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unexpected relocation type in .rela.dyn section" << std::endl;
|
||||
return false;
|
||||
@ -448,7 +451,7 @@ read(ElfFile &file, const std::string &filename)
|
||||
// If we can't find a proper symbol, write the addend in and hope for the best
|
||||
auto ptr = getLoaderDataPtr<uint32_t>(inSections, rela.offset);
|
||||
*ptr = addend;
|
||||
|
||||
|
||||
std::cout << "Unexpected addend " << std::hex << addend << " referenced in relocation section " << name << ", continuing." << std::endl;
|
||||
continue;
|
||||
}
|
||||
@ -458,7 +461,7 @@ read(ElfFile &file, const std::string &filename)
|
||||
file.relocations.emplace_back(relocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read dyn relocations
|
||||
for (auto §ion : inSections) {
|
||||
if (section.header.type != elf::SHT_RELA) {
|
||||
@ -484,6 +487,12 @@ read(ElfFile &file, const std::string &filename)
|
||||
auto symbol = getSectionSymbol(symSection, index);
|
||||
auto addr = symbol->value + rela.addend;
|
||||
|
||||
if(type == elf::R_PPC_NONE)
|
||||
{
|
||||
// ignore padding
|
||||
continue;
|
||||
}
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
auto addend = static_cast<uint32_t>(rela.addend);
|
||||
@ -785,7 +794,7 @@ write(ElfFile &file, const std::string &filename)
|
||||
|
||||
if(relocation->type == elf::R_PPC_RELATIVE) {
|
||||
rela.info = elf::R_PPC_ADDR32 | idx << 8;
|
||||
}
|
||||
}
|
||||
|
||||
rela.addend = relocation->addend;
|
||||
rela.offset = relocation->target;
|
||||
@ -897,7 +906,7 @@ write(ElfFile &file, const std::string &filename)
|
||||
char *symData = reinterpret_cast<char *>(&sym);
|
||||
symTabSection->data.insert(symTabSection->data.end(), symData, symData + sizeof(elf::Symbol));
|
||||
}
|
||||
|
||||
|
||||
//Finish SHT_RPL_IMPORTS signatures
|
||||
Bytef *zero_buffer = reinterpret_cast<Bytef *>(calloc(0x10, 1));
|
||||
for (auto §ion : outSections) {
|
||||
@ -1063,7 +1072,7 @@ write(ElfFile &file, const std::string &filename)
|
||||
if (section->header.type != elf::SHT_RPL_CRCS && section->header.type != elf::SHT_RPL_FILEINFO) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (section->header.type != elf::SHT_NOBITS) {
|
||||
section->header.size = section->data.size();
|
||||
}
|
||||
@ -1075,17 +1084,17 @@ write(ElfFile &file, const std::string &filename)
|
||||
section->header.offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add data sections next
|
||||
for (auto §ion : outSections) {
|
||||
if(section->header.offset != -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (section->header.addr < DataAddress || section->header.addr >= WiiuLoadAddress) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (section->header.type != elf::SHT_NOBITS) {
|
||||
section->header.size = section->data.size();
|
||||
}
|
||||
@ -1097,17 +1106,17 @@ write(ElfFile &file, const std::string &filename)
|
||||
section->header.offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add load sections next
|
||||
for (auto §ion : outSections) {
|
||||
if(section->header.offset != -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (section->header.addr < WiiuLoadAddress) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (section->header.type != elf::SHT_NOBITS) {
|
||||
section->header.size = section->data.size();
|
||||
}
|
||||
@ -1119,13 +1128,13 @@ write(ElfFile &file, const std::string &filename)
|
||||
section->header.offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Everything else
|
||||
for (auto §ion : outSections) {
|
||||
if(section->header.offset != -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (section->header.type != elf::SHT_NOBITS) {
|
||||
section->header.size = section->data.size();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user