Skip to content

Commit 24deb16

Browse files
authored
Merge pull request #1917 from spicyjpeg/elf-fix
Fix ELF loader ignoring non-PROGBITS sections that should be allocated
2 parents 14e80d6 + 9b4dbca commit 24deb16

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/supportpsx/binloader.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,12 @@ bool loadELF(IO<File> file, IO<File> dest, BinaryLoader::Info& info, std::map<ui
225225
Elf_Half sec_num = reader.sections.size();
226226
for (unsigned i = 0; i < sec_num; i++) {
227227
section* psec = reader.sections[i];
228-
auto name = psec->get_name();
229228

230-
if (StringsHelpers::endsWith(name, "_Header")) continue;
231-
if (StringsHelpers::startsWith(name, ".comment")) continue;
229+
if (!(psec->get_flags() & SHF_ALLOC)) continue;
230+
if (psec->get_type() == SHT_NOBITS) continue;
232231

233-
auto type = psec->get_type();
234-
if (type != SHT_PROGBITS) continue;
232+
auto name = psec->get_name();
233+
if (StringsHelpers::endsWith(name, "_Header")) continue;
235234

236235
auto size = psec->get_size();
237236
auto data = psec->get_data();

0 commit comments

Comments
 (0)