[llvm] [X86AsmBackend] Check fixup value overflow (PR #176827)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 19 21:13:56 PST 2026
================
@@ -698,21 +698,21 @@ void X86AsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
assert(Fixup.getOffset() + Size <= F.getSize() && "Invalid fixup offset!");
- int64_t SignedValue = static_cast<int64_t>(Value);
- if (IsResolved && Fixup.isPCRel()) {
- // check that PC relative fixup fits into the fixup size.
- if (Size > 0 && !isIntN(Size * 8, SignedValue))
+ // Check fixup value overflow similar to GAS (fixups emitted as RELA
+ // relocations have a value of 0):
+ // - Signed: high bits must be all 0s or all 1s (sign extension).
+ // - Unsigned: abs(value) must fit (e.g. 1-byte field allows [-255,255]).
----------------
phoebewang wrote:
Where's abs from?
https://github.com/llvm/llvm-project/pull/176827
More information about the llvm-commits
mailing list