Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class Reader {
const auto begin = encoded(position, tableEncoding, segment.MappedAddress);
const auto fde = encoded(position, tableEncoding, segment.MappedAddress);
if (position < segment.MappedAddress || position - segment.MappedAddress > segment.FileSize) throw RelinkerException("Strict filter: EH frame table exceeds segment", position);
result.push_back(readFde(begin, fde));
auto region = readFde(begin, fde);
if (region.End != region.Begin) result.push_back(std::move(region));
}
}
return result;
Expand Down Expand Up @@ -211,7 +212,7 @@ class Reader {
const auto cie = readCie(cieField - cieOffset);
const auto begin = encoded(position, cie.PointerEncoding);
const auto size = encoded(position, cie.PointerEncoding & 0x0F);
if (begin != expectedBegin || size == 0 || size > std::numeric_limits<VirtualAddress>::max() - begin)
if (begin != expectedBegin || size > std::numeric_limits<VirtualAddress>::max() - begin)
throw RelinkerException("Strict filter: inconsistent FDE function range", address);
StrictCodeRegion region{begin, begin + size, {}};
if (cie.Personality != 0) region.ExtraTargets.push_back(cie.Personality);
Expand Down
5 changes: 4 additions & 1 deletion core/relinker/relinker/tests/UnwindRecordBoundsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ int main() {
Domain::ProgramHeader funcSeg{}; funcSeg.Type = 1; funcSeg.MappedAddress = 0x800; funcSeg.FileSize = 0x20;
const auto below = Relinker::UnusedNidFilter::ReadExceptionFunctions(belowBytes, {funcSeg, load, eh}, {}, {});
Require(below.size() == 1 && below[0].Begin == 0x800 && below[0].End == 0x810);
auto empty = Fixture();
Io::WriteU64(empty, 112, 0);
Require(Relinker::UnusedNidFilter::ReadExceptionFunctions(empty, {load, eh}, {}, {}).empty());
for (int kind = 0; kind < 10; ++kind) {
auto bytes = Fixture(); auto segment = load;
switch (kind) {
Expand Down Expand Up @@ -64,6 +67,6 @@ int main() {
catch (const std::exception&) { rejected = true; }
Require(rejected);
}
std::cout << "13 unwind record cases passed\n";
std::cout << "14 unwind record cases passed\n";
} catch (const std::exception& error) { std::cerr << error.what() << '\n'; return 1; }
}
Loading