[compiler-rt] [sanitizer_common] Heed __ndbl_ prefix for 32-bit Linux/sparc64 inter… (PR #109106)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 02:18:44 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Rainer Orth (rorth)
<details>
<summary>Changes</summary>
…ceptors
When ASan testing is enabled on SPARC as per PR #<!-- -->107405, a couple of tests `FAIL` on Linux/sparc64:
```
AddressSanitizer-sparc-linux :: TestCases/printf-2.c
AddressSanitizer-sparc-linux :: TestCases/printf-3.c
AddressSanitizer-sparc-linux :: TestCases/printf-4.c
AddressSanitizer-sparc-linux :: TestCases/printf-5.c
SanitizerCommon-asan-sparc-Linux :: Linux/unexpected_format_specifier_test.cpp
```
It turns out the interceptors aren't used since on Linux/sparc64 `double` and `long double` are the same, and a couple of `stdio` functions are prefixed with `__nldbl_` (no long double) accordingly.
This patch handles this.
Tested on `sparc64-unknown-linux-gnu`.
---
Full diff: https://github.com/llvm/llvm-project/pull/109106.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc (+33)
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index e09a4a8ae25fd8..bf5bb43018efc4 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -127,6 +127,39 @@ extern const short *_toupper_tab_;
extern const short *_tolower_tab_;
#endif
+#if SANITIZER_LINUX && SANITIZER_SPARC32
+// On 32-bit Linux/sparc64, double and long double are identical and glibc
+// uses a __nldbl_ (no long double) prefix for various stdio functions.
+# define __isoc23_fscanf __nldbl___isoc23_fscanf
+# define __isoc23_scanf __nldbl___isoc23_scanf
+# define __isoc23_sscanf __nldbl___isoc23_sscanf
+# define __isoc23_vfscanf __nldbl___isoc23_vfscanf
+# define __isoc23_vscanf __nldbl___isoc23_vscanf
+# define __isoc23_vsscanf __nldbl___isoc23_vsscanf
+# define __isoc99_fscanf __nldbl___isoc99_fscanf
+# define __isoc99_scanf __nldbl___isoc99_scanf
+# define __isoc99_sscanf __nldbl___isoc99_sscanf
+# define __isoc99_vfscanf __nldbl___isoc99_vfscanf
+# define __isoc99_vscanf __nldbl___isoc99_vscanf
+# define __isoc99_vsscanf __nldbl___isoc99_vsscanf
+# define asprintf __nldbl_asprintf
+# define fprintf __nldbl_fprintf
+# define fscanf __nldbl_fscanf
+# define printf __nldbl_printf
+# define scanf __nldbl_scanf
+# define snprintf __nldbl_snprintf
+# define sprintf __nldbl_sprintf
+# define sscanf __nldbl_sscanf
+# define vasprintf __nldbl_vasprintf
+# define vfprintf __nldbl_vfprintf
+# define vfscanf __nldbl_vfscanf
+# define vprintf __nldbl_vprintf
+# define vscanf __nldbl_vscanf
+# define vsnprintf __nldbl_vsnprintf
+# define vsprintf __nldbl_vsprintf
+# define vsscanf __nldbl_vsscanf
+#endif
+
#if SANITIZER_MUSL && \
(defined(__i386__) || defined(__arm__) || SANITIZER_MIPS32 || SANITIZER_PPC32)
// musl 1.2.0 on existing 32-bit architectures uses new symbol names for the
``````````
</details>
https://github.com/llvm/llvm-project/pull/109106
More information about the llvm-commits
mailing list