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