From 3aebb8cb4117e352e033947e816164e44be2aa54 Mon Sep 17 00:00:00 2001 From: Eladash Date: Wed, 4 May 2022 08:26:52 +0300 Subject: [PATCH] Tentative fix for unreadable ELF sections without flags --- rpcs3/Loader/ELF.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rpcs3/Loader/ELF.h b/rpcs3/Loader/ELF.h index 5239ff1215..b7f8ab0331 100644 --- a/rpcs3/Loader/ELF.h +++ b/rpcs3/Loader/ELF.h @@ -56,7 +56,7 @@ enum class sh_flag : u32 __bitset_enum_max }; -constexpr bool is_memorizable_section(sec_type type) +constexpr bool is_memorizable_section(sec_type type, bs_t flags) { switch (type) { @@ -65,6 +65,10 @@ constexpr bool is_memorizable_section(sec_type type) { return false; } + case sec_type::sht_progbits: + { + return flags.all_of(sh_flag::shf_alloc); + } default: { if (type > sec_type::sht_rel) @@ -334,7 +338,7 @@ public: { static_cast(shdrs.emplace_back()) = shdr; - if (!(opts & elf_opt::no_data) && is_memorizable_section(shdr.sh_type)) + if (!(opts & elf_opt::no_data) && is_memorizable_section(shdr.sh_type, shdr.sh_flags())) { stream.seek(offset + shdr.sh_offset); if (!stream.read(shdrs.back().bin, shdr.sh_size)) @@ -393,7 +397,7 @@ public: for (shdr_t shdr : shdrs) { - if (is_memorizable_section(shdr.sh_type)) + if (is_memorizable_section(shdr.sh_type, shdr.sh_flags())) { shdr.sh_offset = std::exchange(off, off + shdr.sh_size); } @@ -409,7 +413,7 @@ public: for (const auto& shdr : shdrs) { - if (!is_memorizable_section(shdr.sh_type)) + if (!is_memorizable_section(shdr.sh_type, shdr.sh_flags())) { continue; }