clean up rel helpers

This commit is contained in:
Martin Michelsen
2026-05-08 22:22:41 -07:00
parent e342915505
commit 9915422ae6
3 changed files with 46 additions and 37 deletions
+15
View File
@@ -182,3 +182,18 @@ std::set<uint32_t> all_relocation_offsets_for_rel_file(const void* data, size_t
return ret;
}
template <typename T>
size_t get_rel_array_count(const std::set<uint32_t>& offsets, size_t start_offset) {
auto it = offsets.lower_bound(start_offset);
if (it == offsets.end()) {
throw std::out_of_range("start offset out of range");
}
if (*it == start_offset) {
it++;
}
if (it == offsets.end()) {
throw std::out_of_range("no further offset beyond start offset");
}
return (*it - start_offset) / sizeof(T);
}