Skip to content

Commit f18a840

Browse files
committed
rpx: Fix crc section where size is incorrect
1 parent 3a26cc8 commit f18a840

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

source/wiiurpxlib.cpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define ZLIB_LEVEL 6
2424

2525
using namespace rpx;
26+
using crc = be2_val<uint32_t>;
2627

2728
void rpx::writerpx(const rpx& elf, std::ostream& os) {
2829
//write elf header out
@@ -130,10 +131,21 @@ void rpx::relink(rpx& elf) {
130131
return s.hdr.sh_type == SHT_RPL_CRCS;
131132
});
132133
crc_section->crc32 = 0;
134+
135+
//check if size wrong
136+
if (crc_section->data.size() != elf.sections.size() * sizeof(crc)) {
137+
printf("WARN: crc section is %x bytes - should be %x! Fixing.\n",
138+
crc_section->data.size(),
139+
elf.sections.size() * sizeof(crc)
140+
);
141+
142+
crc_section->data.resize(elf.sections.size() * sizeof(crc));
143+
}
144+
133145
//spans: keeping all the jank in one place since 2020
134-
std::span<be2_val<uint32_t>> crcs(
135-
(be2_val<uint32_t>*)crc_section->data.data(),
136-
crc_section->data.size() / sizeof(be2_val<uint32_t>)
146+
std::span<crc> crcs(
147+
(crc*)crc_section->data.data(),
148+
crc_section->data.size() / sizeof(crc)
137149
);
138150

139151
bool first_section = true;

0 commit comments

Comments
 (0)