[lld] [LLD][RISCV] Report error for unsatisfiable RISCV_ALIGN (PR #74121)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 10:13:31 PST 2023
================
@@ -686,8 +686,14 @@ static bool relax(InputSection &sec) {
const uint64_t align = PowerOf2Ceil(r.addend + 2);
// All bytes beyond the alignment boundary should be removed.
remove = nextLoc - ((loc + align - 1) & -align);
- assert(static_cast<int32_t>(remove) >= 0 &&
- "R_RISCV_ALIGN needs expanding the content");
+ // If we can't satisfy this alignment, we've found a bad input.
+ if (LLVM_UNLIKELY(static_cast<int32_t>(remove) < 0)) {
+ error(getErrorLocation((const uint8_t*)loc) +
+ "insufficient padding bytes for " + lld::toString(r.type) +
+ ": " + Twine(r.addend) + " bytes available "
----------------
MaskRay wrote:
Combine consecutive literals: `" bytes available for requested alignment of "`.
Even if the code is broken ugly by clang-format, we can utilize `"a"\n"b"`
https://github.com/llvm/llvm-project/pull/74121
More information about the llvm-commits
mailing list