[compiler-rt] [NFC][sanitizer] Simplify splitting TLS and stack (PR #108672)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 12:54:43 PDT 2024
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/108672
>From 97b6e37d4ada7a0f02988ae992606d3d42ebae96 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 13 Sep 2024 20:06:26 -0700
Subject: [PATCH 1/6] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
=?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
[skip ci]
---
.../test/sanitizer_common/TestCases/Linux/tls_get_addr.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/tls_get_addr.c b/compiler-rt/test/sanitizer_common/TestCases/Linux/tls_get_addr.c
index 2f88c22d19dbf9..0aff6039ac4e8a 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/tls_get_addr.c
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/tls_get_addr.c
@@ -10,6 +10,9 @@
// These don't intercept __tls_get_addr.
// XFAIL: lsan,hwasan,ubsan
+// FIXME: Fails for unknown reasons.
+// UNSUPPORTED: powerpc64le-target-arch
+
#ifndef BUILD_SO
# include <assert.h>
# include <dlfcn.h>
>From 05d12ada822a0e19b83f6b831a4815ef55856e7b Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 16 Sep 2024 10:18:22 -0700
Subject: [PATCH 2/6] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
=?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
[skip ci]
---
.../sanitizer_linux_libcdep.cpp | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 55889ae1222ad8..61bbd3ae3b7c3c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -40,6 +40,10 @@
# include <sys/resource.h>
# include <syslog.h>
+# ifdef SANITIZER_GLIBC
+# include <gnu/libc-version.h>
+# endif
+
# if !defined(ElfW)
# define ElfW(type) Elf_##type
# endif
@@ -198,17 +202,11 @@ bool SetEnv(const char *name, const char *value) {
__attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
int *patch) {
-# ifdef _CS_GNU_LIBC_VERSION
- char buf[64];
- uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
- if (len >= sizeof(buf))
- return false;
- buf[len] = 0;
- static const char kGLibC[] = "glibc ";
- if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
- return false;
- const char *p = buf + sizeof(kGLibC) - 1;
+# ifdef SANITIZER_GLIBC
+ const char *p = gnu_get_libc_version();
*major = internal_simple_strtoll(p, &p, 10);
+ // Caller does not expect anything else.
+ CHECK_EQ(*major, 2);
*minor = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
*patch = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
return true;
>From e6793e526699f4aebd6f222c8d0167d9c11a802f Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 16 Sep 2024 10:18:48 -0700
Subject: [PATCH 3/6] CHECK
Created using spr 1.3.4
---
.../sanitizer_linux_libcdep.cpp | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index d40fc54732f48c..20d112c3155d08 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -40,10 +40,6 @@
# include <sys/resource.h>
# include <syslog.h>
-# ifdef SANITIZER_GLIBC
-# include <gnu/libc-version.h>
-# endif
-
# if !defined(ElfW)
# define ElfW(type) Elf_##type
# endif
@@ -202,11 +198,17 @@ bool SetEnv(const char *name, const char *value) {
__attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
int *patch) {
-# ifdef SANITIZER_GLIBC
- const char *p = gnu_get_libc_version();
+# ifdef _CS_GNU_LIBC_VERSION
+ char buf[64];
+ uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
+ if (len >= sizeof(buf))
+ return false;
+ buf[len] = 0;
+ static const char kGLibC[] = "glibc ";
+ if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
+ return false;
+ const char *p = buf + sizeof(kGLibC) - 1;
*major = internal_simple_strtoll(p, &p, 10);
- // Caller does not expect anything else.
- CHECK_EQ(*major, 2);
*minor = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
*patch = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
return true;
>From 89b97e97e2e6b57ff2f7ff9c226b3baa17bd3984 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 16 Sep 2024 10:37:23 -0700
Subject: [PATCH 4/6] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
=?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
[skip ci]
---
.../sanitizer_linux_libcdep.cpp | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 55889ae1222ad8..61bbd3ae3b7c3c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -40,6 +40,10 @@
# include <sys/resource.h>
# include <syslog.h>
+# ifdef SANITIZER_GLIBC
+# include <gnu/libc-version.h>
+# endif
+
# if !defined(ElfW)
# define ElfW(type) Elf_##type
# endif
@@ -198,17 +202,11 @@ bool SetEnv(const char *name, const char *value) {
__attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
int *patch) {
-# ifdef _CS_GNU_LIBC_VERSION
- char buf[64];
- uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
- if (len >= sizeof(buf))
- return false;
- buf[len] = 0;
- static const char kGLibC[] = "glibc ";
- if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
- return false;
- const char *p = buf + sizeof(kGLibC) - 1;
+# ifdef SANITIZER_GLIBC
+ const char *p = gnu_get_libc_version();
*major = internal_simple_strtoll(p, &p, 10);
+ // Caller does not expect anything else.
+ CHECK_EQ(*major, 2);
*minor = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
*patch = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
return true;
>From f7677660ae1997ac8271d23be2c933d5a30870d0 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 16 Sep 2024 10:50:06 -0700
Subject: [PATCH 5/6] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
=?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
[skip ci]
---
.../sanitizer_linux_libcdep.cpp | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 55889ae1222ad8..61bbd3ae3b7c3c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -40,6 +40,10 @@
# include <sys/resource.h>
# include <syslog.h>
+# ifdef SANITIZER_GLIBC
+# include <gnu/libc-version.h>
+# endif
+
# if !defined(ElfW)
# define ElfW(type) Elf_##type
# endif
@@ -198,17 +202,11 @@ bool SetEnv(const char *name, const char *value) {
__attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
int *patch) {
-# ifdef _CS_GNU_LIBC_VERSION
- char buf[64];
- uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
- if (len >= sizeof(buf))
- return false;
- buf[len] = 0;
- static const char kGLibC[] = "glibc ";
- if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
- return false;
- const char *p = buf + sizeof(kGLibC) - 1;
+# ifdef SANITIZER_GLIBC
+ const char *p = gnu_get_libc_version();
*major = internal_simple_strtoll(p, &p, 10);
+ // Caller does not expect anything else.
+ CHECK_EQ(*major, 2);
*minor = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
*patch = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
return true;
>From 044c911aa7eae9a778f36b7b316a69d8ebc03edd Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 16 Sep 2024 10:50:40 -0700
Subject: [PATCH 6/6] drop if
Created using spr 1.3.4
---
.../sanitizer_linux_libcdep.cpp | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 863ae951d34a6c..0239d485dd5c83 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -40,10 +40,6 @@
# include <sys/resource.h>
# include <syslog.h>
-# ifdef SANITIZER_GLIBC
-# include <gnu/libc-version.h>
-# endif
-
# if !defined(ElfW)
# define ElfW(type) Elf_##type
# endif
@@ -202,11 +198,17 @@ bool SetEnv(const char *name, const char *value) {
__attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
int *patch) {
-# ifdef SANITIZER_GLIBC
- const char *p = gnu_get_libc_version();
+# ifdef _CS_GNU_LIBC_VERSION
+ char buf[64];
+ uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
+ if (len >= sizeof(buf))
+ return false;
+ buf[len] = 0;
+ static const char kGLibC[] = "glibc ";
+ if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
+ return false;
+ const char *p = buf + sizeof(kGLibC) - 1;
*major = internal_simple_strtoll(p, &p, 10);
- // Caller does not expect anything else.
- CHECK_EQ(*major, 2);
*minor = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
*patch = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
return true;
More information about the llvm-commits
mailing list