From 688c4a253733f173e712ee1ff8a082a75f470ee0 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Sat, 24 Aug 2024 22:26:42 -0400 Subject: [PATCH] Fixed incorrect size used for finding section segments --- src/elf.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/elf.cpp b/src/elf.cpp index 3d4e387..ba01c50 100644 --- a/src/elf.cpp +++ b/src/elf.cpp @@ -239,10 +239,11 @@ ELFIO::section* read_sections(N64Recomp::Context& context, const N64Recomp::ElfP auto& section_out = context.sections[section->get_index()]; ELFIO::Elf_Word type = section->get_type(); ELFIO::Elf_Xword flags = section->get_flags(); + ELFIO::Elf_Xword section_size = section->get_size(); // Check if this section will end up in the ROM. It must not be a nobits (NOLOAD) type, must have the alloc flag set and must have a nonzero size. - if (type != ELFIO::SHT_NOBITS && (section->get_flags() & ELFIO::SHF_ALLOC) && section->get_size() != 0) { - std::optional segment_index = get_segment(segments, section_out.size, section->get_offset()); + if (type != ELFIO::SHT_NOBITS && (flags & ELFIO::SHF_ALLOC) && section_size != 0) { + std::optional segment_index = get_segment(segments, section_size, section->get_offset()); if (!segment_index.has_value()) { fmt::print(stderr, "Could not find segment that section {} belongs to!\n", section->get_name()); return nullptr;