[llvm] [ARMAsmBackend] Add checks for relocation addends in assembler (PR #109969)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 03:40:03 PDT 2024


================
@@ -0,0 +1,28 @@
+// RUN: not llvm-mc -triple armv7-apple-darwin -filetype=obj %s 2>&1 | FileCheck %s
+
+_foo:
+    // Check that the relocation size is valid.
+
+    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
+    bl  _foo+0xfffffff00
----------------
jcohen-apple wrote:

There's one edge case there that I think I didn't understand correctly:

_foo2:
    bl  _foo2-0x1fffffc

If I multiple the number by -1, in 2's complement I get 0x2000004, so this should be the same as:

_foo2:
   bl _foo2+0x2000004

Which gcc does accept (and it should, it's a legal offset). What am I missing here?

https://github.com/llvm/llvm-project/pull/109969


More information about the llvm-commits mailing list