forked from mirrors/gecko-dev
Bug 1798865 - Adjust llvm-symbolizer lookup order. r=glandium,andi
Differential Revision: https://phabricator.services.mozilla.com/D161138
This commit is contained in:
parent
f5545df315
commit
0ee39a42f7
1 changed files with 28 additions and 25 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
|
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
|
||||||
index c3e08f58c2ce..b5c5b9e3e74a 100644
|
index 7ef499ce07b1..8fd682f943fe 100644
|
||||||
--- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
|
--- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
|
||||||
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
|
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
|
||||||
@@ -21,6 +21,10 @@
|
@@ -21,6 +21,10 @@
|
||||||
|
|
@ -13,18 +13,18 @@ index c3e08f58c2ce..b5c5b9e3e74a 100644
|
||||||
namespace __sanitizer {
|
namespace __sanitizer {
|
||||||
|
|
||||||
void CatastrophicErrorWrite(const char *buffer, uptr length) {
|
void CatastrophicErrorWrite(const char *buffer, uptr length) {
|
||||||
@@ -222,6 +226,34 @@ char *FindPathToBinary(const char *name) {
|
@@ -206,11 +210,35 @@ char *FindPathToBinary(const char *name) {
|
||||||
if (*end == '\0') break;
|
return internal_strdup(name);
|
||||||
beg = end + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ uptr name_len = internal_strlen(name);
|
||||||
|
+ InternalMmapVector<char> buffer(kMaxPathLength);
|
||||||
+
|
+
|
||||||
+#if SANITIZER_LINUX
|
+#if SANITIZER_LINUX
|
||||||
+ // If we cannot find the requested binary in PATH, we should try to locate
|
+ // 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
|
+ // 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.
|
+ // (e.g. llvm-symbolizer shipped with sanitizer build to symbolize on client.
|
||||||
+ if (internal_readlink("/proc/self/exe", buffer.data(), kMaxPathLength) < 0)
|
+ if (internal_readlink("/proc/self/exe", buffer.data(), kMaxPathLength) >= 0) {
|
||||||
+ return nullptr;
|
|
||||||
+
|
|
||||||
+ uptr buf_len = internal_strlen(buffer.data());
|
+ uptr buf_len = internal_strlen(buffer.data());
|
||||||
+
|
+
|
||||||
+ /* Avoid using dirname() here */
|
+ /* Avoid using dirname() here */
|
||||||
|
|
@ -34,17 +34,20 @@ index c3e08f58c2ce..b5c5b9e3e74a 100644
|
||||||
+ buf_len--;
|
+ buf_len--;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (!buf_len)
|
+ if (buf_len && buf_len + name_len + 1 <= kMaxPathLength) {
|
||||||
+ return nullptr;
|
|
||||||
+
|
|
||||||
+ if (buf_len + name_len + 1 <= kMaxPathLength) {
|
|
||||||
+ internal_memcpy(&buffer[buf_len], name, name_len);
|
+ internal_memcpy(&buffer[buf_len], name, name_len);
|
||||||
+ buffer[buf_len + name_len] = '\0';
|
+ buffer[buf_len + name_len] = '\0';
|
||||||
+ if (FileExists(buffer.data()))
|
+ if (FileExists(buffer.data()))
|
||||||
+ return internal_strdup(buffer.data());
|
+ return internal_strdup(buffer.data());
|
||||||
+ }
|
+ }
|
||||||
|
+ }
|
||||||
+#endif
|
+#endif
|
||||||
+
|
+
|
||||||
|
const char *path = GetEnv("PATH");
|
||||||
|
if (!path)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
- uptr name_len = internal_strlen(name);
|
||||||
|
- InternalMmapVector<char> buffer(kMaxPathLength);
|
||||||
|
const char *beg = path;
|
||||||
|
while (true) {
|
||||||
|
const char *end = internal_strchrnul(beg, kPathSeparator);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue