[PATCH] D14957: [ELF/AArch64] Fix overflow checks for R_AARCH64_{ABS, PREL}{16, 32} relocations.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 17:51:27 PST 2015


ikudrin added inline comments.

================
Comment at: ELF/Target.cpp:58-59
@@ +57,4 @@
+template <unsigned N>
+static void checkIsIntOrUInt(uint64_t Val, uint32_t Type) {
+  if (!isInt<N>(Val) && !isUInt<N>(Val))
+    error("Relocation " + getELFRelocationTypeName(Config->EMachine, Type) +
----------------
ruiu wrote:
> By the way, is isInt<N> correct? Isn't that isInt<N-1>?
That's why I've made "precise" tests. The old lld was not correct in those cases.

The docs say, that, for example, for R_AARCH64_ABS16 the valid range is -2^15 <= X < 2^16.
-2^15 is the minimum valid value for IsInt<16> and 2^16-1 is the maximum for IsUInt<16>.


http://reviews.llvm.org/D14957





More information about the llvm-commits mailing list