From b6c024fc5c66a4f79902429f1346a8c7212ebbfc Mon Sep 17 00:00:00 2001 From: James Benton Date: Sun, 30 Sep 2018 08:37:33 +0100 Subject: [PATCH] elf2rpl: Set file offset to 0 for the SHT_NOBITS and SHT_NULL sections. --- tools/elf2rpl/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/elf2rpl/main.cpp b/tools/elf2rpl/main.cpp index 3008d66..5d713ee 100644 --- a/tools/elf2rpl/main.cpp +++ b/tools/elf2rpl/main.cpp @@ -569,6 +569,14 @@ calculateSectionOffsets(ElfFile &file) auto offset = file.header.shoff; offset += align_up(static_cast(file.sections.size() * sizeof(elf::SectionHeader)), 64); + for (auto §ion : file.sections) { + if (section->header.type == elf::SHT_NOBITS || + section->header.type == elf::SHT_NULL) { + section->header.offset = 0u; + section->data.clear(); + } + } + for (auto §ion : file.sections) { if (section->header.type == elf::SHT_RPL_CRCS) { section->header.offset = offset;