diff --git a/tools/readrpl/verify.cpp b/tools/readrpl/verify.cpp index a87ca400..e8e43e07 100644 --- a/tools/readrpl/verify.cpp +++ b/tools/readrpl/verify.cpp @@ -343,17 +343,17 @@ bool verifyFileBounds(const Rpl &rpl) { auto result = true; - auto dataMin = -1; - auto dataMax = 0; + auto dataMin = 0xFFFFFFFFu; + auto dataMax = 0u; - auto readMin = -1; - auto readMax = 0; + auto readMin = 0xFFFFFFFFu; + auto readMax = 0u; - auto textMin = -1; - auto textMax = 0; + auto textMin = 0xFFFFFFFFu; + auto textMax = 0u; - auto tempMin = -1; - auto tempMax = 0; + auto tempMin = 0xFFFFFFFFu; + auto tempMax = 0u; for (const auto §ion : rpl.sections) { if (section.header.size == 0 || @@ -366,39 +366,40 @@ verifyFileBounds(const Rpl &rpl) if ((section.header.flags & elf::SHF_EXECINSTR) && section.header.type != elf::SHT_RPL_EXPORTS) { - textMin = std::min(textMin, static_cast(section.header.offset)); - textMax = std::min(textMax, static_cast(section.header.offset + section.header.size)); + textMin = std::min(textMin, section.header.offset); + textMax = std::max(textMax, section.header.offset + section.header.size); } else { if (section.header.flags & elf::SHF_ALLOC) { if (section.header.flags & elf::SHF_WRITE) { - dataMin = std::min(dataMin, static_cast(section.header.offset)); - dataMax = std::min(dataMax, static_cast(section.header.offset + section.header.size)); + dataMin = std::min(dataMin, section.header.offset); + dataMax = std::max(dataMax, section.header.offset + section.header.size); } else { - readMin = std::min(readMin, static_cast(section.header.offset)); - readMax = std::min(readMax, static_cast(section.header.offset + section.header.size)); + readMin = std::min(readMin, section.header.offset); + readMax = std::max(readMax, section.header.offset + section.header.size); } } else { - tempMin = std::min(tempMin, static_cast(section.header.offset)); - tempMax = std::min(tempMax, static_cast(section.header.offset + section.header.size)); + tempMin = std::min(tempMin, section.header.offset); + tempMax = std::max(tempMax, section.header.offset + section.header.size); } } } - if (dataMin == -1) { - dataMax = (rpl.header.shnum * rpl.header.shentsize) + rpl.header.shoff; + if (dataMin == 0xFFFFFFFFu) { + dataMin = (rpl.header.shnum * rpl.header.shentsize) + rpl.header.shoff; + dataMax = dataMin; } - if (readMin == -1) { + if (readMin == 0xFFFFFFFFu) { readMin = dataMax; readMax = dataMax; } - if (textMin == -1) { + if (textMin == 0xFFFFFFFFu) { textMin = readMax; textMax = readMax; } - if (tempMin == -1) { + if (tempMin == 0xFFFFFFFFu) { tempMin = textMax; tempMax = textMax; }