mirror of
https://github.com/devkitPro/wut.git
synced 2026-08-08 10:44:44 -05:00
readRpl: Add SHT_RPL_CRCS value check
This commit is contained in:
parent
541676ce38
commit
c7325899be
|
|
@ -458,6 +458,45 @@ printRplImports(std::vector<Section> §ions,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
checkRplCrcs(std::vector<Section> §ions)
|
||||
{
|
||||
elf::RplCrc *crcs = NULL;
|
||||
auto crcSectionIndex = 0u;
|
||||
|
||||
for (auto i = 0u; i < sections.size(); ++i) {
|
||||
auto §ion = sections[i];
|
||||
if (section.header.type == elf::SHT_RPL_CRCS) {
|
||||
crcs = reinterpret_cast<elf::RplCrc *>(section.data.data());
|
||||
crcSectionIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!crcs) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < sections.size(); ++i) {
|
||||
auto §ion = sections[i];
|
||||
auto crc = uint32_t { 0u };
|
||||
|
||||
if (i == crcSectionIndex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (section.data.size()) {
|
||||
crc = crc32(0, Z_NULL, 0);
|
||||
crc = crc32(crc, reinterpret_cast<Bytef *>(section.data.data()), section.data.size());
|
||||
}
|
||||
|
||||
if (crc != crcs[i].crc) {
|
||||
fmt::print("Unexpected crc for section {}, read 0x{:08X} but calculated 0x{:08X}",
|
||||
i, crcs[i].crc, crc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
printRplCrcs(std::vector<Section> §ions,
|
||||
const char *shStrTab,
|
||||
|
|
@ -662,6 +701,8 @@ int main(int argc, char **argv)
|
|||
printSectionSummary(sections, shStrTab);
|
||||
}
|
||||
|
||||
checkRplCrcs(sections);
|
||||
|
||||
// Print section data
|
||||
for (auto i = 0u; i < sections.size(); ++i) {
|
||||
auto §ion = sections[i];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user