Skip to content

Commit

Permalink
Add an assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Feb 5, 2022
1 parent b02c8cb commit f72999a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions elf/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,12 @@ i64 get_section_rank(Context<E> &ctx, Chunk<E> *chunk) {
}

// Returns the smallest number n such that
// n >= val and n % align == skew % align.
// val <= n and n % align == skew % align.
inline u64 align_with_skew(u64 val, u64 align, u64 skew) {
skew = skew % align;
return align_to(val + align - skew, align) - align + skew;
u64 n = align_to(val + align - skew, align) - align + skew;
assert(val <= n && n < val + align && n % align == skew % align);
return n;
}

template <typename E>
Expand Down

0 comments on commit f72999a

Please sign in to comment.