mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2024-12-24 23:21:51 +01:00
Fix checking the size of modules before linking
This commit is contained in:
parent
c68e375567
commit
6a2a7ca1fd
@ -111,8 +111,7 @@ int main(int argc, char **argv) {
|
||||
uint32_t destination_address = ((uint32_t) gModuleData + (sizeof(module_information_t) + 0x0000FFFF)) & 0xFFFF0000;
|
||||
for (int i = 0; i < modules.GetFilecount(); i++) {
|
||||
DEBUG_FUNCTION_LINE("Loading module %s", modules.GetFilepath(i));
|
||||
|
||||
std::optional<ModuleData> moduleData = ModuleDataFactory::load(modules.GetFilepath(i), &destination_address, MEMORY_REGION_USABLE_END - textSectionStart, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
||||
std::optional<ModuleData> moduleData = ModuleDataFactory::load(modules.GetFilepath(i), &destination_address, MEMORY_REGION_USABLE_END - destination_address, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
||||
|
||||
if (moduleData) {
|
||||
DEBUG_FUNCTION_LINE("Successfully loaded %s", modules.GetFilepath(i));
|
||||
|
@ -54,7 +54,6 @@ std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t *de
|
||||
uint32_t totalSize = 0;
|
||||
uint32_t endAddress = 0;
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||
section *psec = reader.sections[i];
|
||||
if (psec->get_type() == 0x80000002) {
|
||||
@ -63,6 +62,13 @@ std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t *de
|
||||
|
||||
if ((psec->get_type() == SHT_PROGBITS || psec->get_type() == SHT_NOBITS) && (psec->get_flags() & SHF_ALLOC)) {
|
||||
uint32_t sectionSize = psec->get_size();
|
||||
|
||||
totalSize += sectionSize;
|
||||
if(totalSize > maximum_size){
|
||||
DEBUG_FUNCTION_LINE("Couldn't load setup module because it's too big.");
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t address = (uint32_t) psec->get_address();
|
||||
|
||||
destinations[psec->get_index()] = (uint8_t *) baseOffset;
|
||||
@ -107,7 +113,6 @@ std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t *de
|
||||
moduleData.addSectionInfo(SectionInfo(psec->get_name(), destination, sectionSize));
|
||||
DEBUG_FUNCTION_LINE("Saved %s section info. Location: %08X size: %08X", psec->get_name().c_str(), destination, sectionSize);
|
||||
|
||||
totalSize += sectionSize;
|
||||
|
||||
if (endAddress < destination + sectionSize) {
|
||||
endAddress = destination + sectionSize;
|
||||
|
Loading…
Reference in New Issue
Block a user