summaryrefslogtreecommitdiffstats
path: root/build/build-clang/find_symbolizer_linux_clang_10.patch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /build/build-clang/find_symbolizer_linux_clang_10.patch
parentInitial commit. (diff)
downloadfirefox-esr-upstream/115.8.0esr.tar.xz
firefox-esr-upstream/115.8.0esr.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'build/build-clang/find_symbolizer_linux_clang_10.patch')
-rw-r--r--build/build-clang/find_symbolizer_linux_clang_10.patch58
1 files changed, 58 insertions, 0 deletions
diff --git a/build/build-clang/find_symbolizer_linux_clang_10.patch b/build/build-clang/find_symbolizer_linux_clang_10.patch
new file mode 100644
index 0000000000..1ddb02024d
--- /dev/null
+++ b/build/build-clang/find_symbolizer_linux_clang_10.patch
@@ -0,0 +1,58 @@
+We currently need this patch because ASan only searches PATH to find the
+llvm-symbolizer binary to symbolize ASan traces. On testing machines, this
+can be installed in PATH easily. However, for e.g. the ASan Nightly Project,
+where we ship an ASan build, including llvm-symbolizer, to the user, we
+cannot expect llvm-symbolizer to be on PATH. Instead, we should try to look
+it up next to the binary. This patch implements the functionality for Linux
+only until there is similar functionality provided upstream.
+
+diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
+index 79930d79425..cfb4f90c0d5 100644
+--- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
++++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
+@@ -20,6 +20,10 @@
+ #include "sanitizer_common.h"
+ #include "sanitizer_file.h"
+
++#if SANITIZER_LINUX
++#include "sanitizer_posix.h"
++#endif
++
+ namespace __sanitizer {
+
+ void CatastrophicErrorWrite(const char *buffer, uptr length) {
+@@ -194,6 +198,34 @@ char *FindPathToBinary(const char *name) {
+ if (*end == '\0') break;
+ beg = end + 1;
+ }
++
++#if SANITIZER_LINUX
++ // If we cannot find the requested binary in PATH, we should try to locate
++ // it next to the binary, in case it is shipped with the build itself
++ // (e.g. llvm-symbolizer shipped with sanitizer build to symbolize on client.
++ if (internal_readlink("/proc/self/exe", buffer.data(), kMaxPathLength) < 0)
++ return nullptr;
++
++ uptr buf_len = internal_strlen(buffer.data());
++
++ /* Avoid using dirname() here */
++ while (buf_len > 0) {
++ if (buffer[buf_len - 1] == '/')
++ break;
++ buf_len--;
++ }
++
++ if (!buf_len)
++ return nullptr;
++
++ if (buf_len + name_len + 1 <= kMaxPathLength) {
++ internal_memcpy(&buffer[buf_len], name, name_len);
++ buffer[buf_len + name_len] = '\0';
++ if (FileExists(buffer.data()))
++ return internal_strdup(buffer.data());
++ }
++#endif
++
+ return nullptr;
+ }
+