Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect alignment during mod section loading #65

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions librecomp/src/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ recomp::mods::CodeModLoadError recomp::mods::ModContext::load_mod_code(uint8_t*

const std::vector<N64Recomp::Section>& mod_sections = mod.recompiler_context->sections;
mod.section_load_addresses.resize(mod_sections.size());

// Copy each section's binary into rdram, leaving room for the section's bss before the next one.
int32_t cur_section_addr = load_address;
for (size_t section_index = 0; section_index < mod_sections.size(); section_index++) {
Expand All @@ -831,8 +831,10 @@ recomp::mods::CodeModLoadError recomp::mods::ModContext::load_mod_code(uint8_t*
MEM_B(i, (gpr)cur_section_addr) = binary_data[section.rom_addr + i];
}
mod.section_load_addresses[section_index] = cur_section_addr;
// Calculate the next section's address based on the size of this section and its bss.
cur_section_addr += section.size + section.bss_size;

// Align the next section's address to 16 bytes.
cur_section_addr = (cur_section_addr + 15) & ~15;
}

// Iterate over each section again after loading them to perform R_MIPS_32 relocations.
Expand Down