.s: Assembler messages: +a.s:1: Error: 0x80000000 out of range of signed 32bit displacement +% clang -c a.s +``` + +The integrated assembler after #75747 will diagnose the invalid +displacement as well. +``` +% clang -c a.s +a.s:1:19: error: displacement 2147483648 is not within [-2147483648, 2147483647] +movsbl 0x80000000(%r10),%r10d + ^ +``` + +If ASAN_SHADOW_OFFSET_CONST cannot be encoded as a displacement, switch +to `movabsq+movsbl`. +--- + compiler-rt/lib/asan/asan_rtl_x86_64.S | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git compiler-rt/lib/asan/asan_rtl_x86_64.S compiler-rt/lib/asan/asan_rtl_x86_64.S +index 0b7363018f425f..e44587ac4331c7 100644 +--- compiler-rt/lib/asan/asan_rtl_x86_64.S ++++ compiler-rt/lib/asan/asan_rtl_x86_64.S +@@ -27,7 +27,12 @@ FNAME(reg, op, s, i): ;\ + #define ASAN_MEMORY_ACCESS_INITIAL_CHECK_ADD(reg, op, s) \ + mov %##reg,%r10 ;\ + shr $0x3,%r10 ;\ ++ .if ASAN_SHADOW_OFFSET_CONST < 0x80000000 ;\ + movsbl ASAN_SHADOW_OFFSET_CONST(%r10),%r10d ;\ ++ .else ;\ ++ movabsq $ASAN_SHADOW_OFFSET_CONST,%r11 ;\ ++ movsbl (%r10,%r11),%r10d ;\ ++ .endif ;\ + test %r10d,%r10d ;\ + jne CLABEL(reg, op, s, add) ;\ + RLABEL(reg, op, s, add): ;\ diff --git a/devel/llvm17/files/patch-backport-llvmorg-18-init-15680-g966d564e43e6 b/devel/llvm17/files/patch-backport-llvmorg-18-init-15680-g966d564e43e6 new file mode 100644 index 000000000000..424e5f9eeea3 --- /dev/null +++ b/devel/llvm17/files/patch-backport-llvmorg-18-init-15680-g966d564e43e6 @@ -0,0 +1,32 @@ +From 966d564e43e650b9c34f9c67829d3947f52add91 Mon Sep 17 00:00:00 2001 +From: Dan McGregor +Date: Sun, 24 Dec 2023 22:37:35 -0600 +Subject: [PATCH] asan_static x86-64: Support 64-bit ASAN_SHADOW_OFFSET_CONST + redux (#76185) + +Similar to b9935bb02a50, but also apply a similar change to +ACCESS_CHECK_ADD. + +If ASAN_SHADOW_OFFSET_CONST cannot be encoded as a displacement, switch +to `movabsq` and the register offset variant of cmp. +--- + compiler-rt/lib/asan/asan_rtl_x86_64.S | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git compiler-rt/lib/asan/asan_rtl_x86_64.S compiler-rt/lib/asan/asan_rtl_x86_64.S +index e44587ac4331c7..9c5289856d8ae6 100644 +--- compiler-rt/lib/asan/asan_rtl_x86_64.S ++++ compiler-rt/lib/asan/asan_rtl_x86_64.S +@@ -89,7 +89,12 @@ ENDF + #define ASAN_MEMORY_ACCESS_CHECK_ADD(reg, op, s, c) \ + mov %##reg,%r10 ;\ + shr $0x3,%r10 ;\ ++ .if ASAN_SHADOW_OFFSET_CONST < 0x80000000 ;\ + ##c $0x0,ASAN_SHADOW_OFFSET_CONST(%r10) ;\ ++ .else ;\ ++ movabsq $ASAN_SHADOW_OFFSET_CONST,%r11 ;\ ++ ##c $0x0,(%r10,%r11) ;\ ++ .endif ;\ + jne FLABEL(reg, op, s, add) ;\ + retq ;\ + diff --git a/devel/llvm17/files/patch-backport-llvmorg-18-init-1760-g68744ffbdd7d b/devel/llvm17/files/patch-backport-llvmorg-18-init-1760-g68744ffbdd7d new file mode 100644 index 000000000000..58ff453d8a06 --- /dev/null +++ b/devel/llvm17/files/patch-backport-llvmorg-18-init-1760-g68744ffbdd7d @@ -0,0 +1,31 @@ +From 68744ffbdd7daac41da274eef9ac0d191e11c16d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Storsj=C3=B6?= +Date: Thu, 10 Aug 2023 11:09:36 +0300 +Subject: [PATCH] [lldb] Fix building with latest libc++ + +Since https://reviews.llvm.org/D157058 in libc++, +the base template for char_traits has been removed - it is only +provided for char, wchar_t, char8_t, char16_t and char32_t. +(Thus, to use basic_string with a type other than those, we'd need +to supply suitable traits ourselves.) + +For this particular use, a vector works just as well as basic_string. + +Differential Revision: https://reviews.llvm.org/D157589 +--- + .../Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +index 4efc454967a12..f9d95fc5d2a66 100644 +--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp ++++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +@@ -631,7 +631,7 @@ static void WriteRegisterValueInHexFixedWidth( + } else { + // Zero-out any unreadable values. + if (reg_info.byte_size > 0) { +- std::basic_string zeros(reg_info.byte_size, '\0'); ++ std::vector zeros(reg_info.byte_size, '\0'); + AppendHexValue(response, zeros.data(), zeros.size(), false); + } + }