Skip to content

Commit 8ead454

Browse files
committed
[lld][macho] Use reloc length correctly in hash computation
1 parent defe934 commit 8ead454

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lld/MachO/BPSectionOrderer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ struct BPOrdererMachO : lld::BPOrderer<BPOrdererMachO> {
6161

6262
// Calculate relocation hashes
6363
for (const auto &r : sec.relocs) {
64-
if (r.length == 0 || r.referent.isNull() || r.offset >= data.size())
64+
uint32_t relocLength = 1 << r.length;
65+
if (r.referent.isNull() || r.offset + relocLength > data.size())
6566
continue;
6667

6768
uint64_t relocHash = getRelocHash(r, sectionToIdx);
6869
uint32_t start = (r.offset < windowSize) ? 0 : r.offset - windowSize + 1;
69-
for (uint32_t i = start; i < r.offset + r.length; i++) {
70+
for (uint32_t i = start; i < r.offset + relocLength; i++) {
7071
auto window = data.drop_front(i).take_front(windowSize);
7172
hashes.push_back(xxh3_64bits(window) ^ relocHash);
7273
}

0 commit comments

Comments
 (0)