mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-11 02:29:29 +00:00
Tentative fix for unreadable ELF sections without flags
This commit is contained in:
parent
fcbeb2fa22
commit
3aebb8cb41
1 changed files with 8 additions and 4 deletions
|
@ -56,7 +56,7 @@ enum class sh_flag : u32
|
||||||
__bitset_enum_max
|
__bitset_enum_max
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr bool is_memorizable_section(sec_type type)
|
constexpr bool is_memorizable_section(sec_type type, bs_t<sh_flag> flags)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,10 @@ constexpr bool is_memorizable_section(sec_type type)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case sec_type::sht_progbits:
|
||||||
|
{
|
||||||
|
return flags.all_of(sh_flag::shf_alloc);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (type > sec_type::sht_rel)
|
if (type > sec_type::sht_rel)
|
||||||
|
@ -334,7 +338,7 @@ public:
|
||||||
{
|
{
|
||||||
static_cast<shdr_t&>(shdrs.emplace_back()) = shdr;
|
static_cast<shdr_t&>(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);
|
stream.seek(offset + shdr.sh_offset);
|
||||||
if (!stream.read(shdrs.back().bin, shdr.sh_size))
|
if (!stream.read(shdrs.back().bin, shdr.sh_size))
|
||||||
|
@ -393,7 +397,7 @@ public:
|
||||||
|
|
||||||
for (shdr_t shdr : shdrs)
|
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);
|
shdr.sh_offset = std::exchange(off, off + shdr.sh_size);
|
||||||
}
|
}
|
||||||
|
@ -409,7 +413,7 @@ public:
|
||||||
|
|
||||||
for (const auto& shdr : shdrs)
|
for (const auto& shdr : shdrs)
|
||||||
{
|
{
|
||||||
if (!is_memorizable_section(shdr.sh_type))
|
if (!is_memorizable_section(shdr.sh_type, shdr.sh_flags()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue