[compiler-rt] [asan] Ignore vDSO on FreeBSD (PR #76223)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 22 01:32:35 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Rainer Orth (rorth)

<details>
<summary>Changes</summary>

Most asan tests `FAIL` on FreeBSD 14.0/amd64 with
```
==17651==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
```
With `ASAN_OPTIONS=verbosity=2` one sees:
```
==4880==info->dlpi_name = [vdso]	info->dlpi_addr = 0xffffe780
==4880==info->dlpi_name = lib/clang/18/lib/freebsd/libclang_rt.asan-i386.so	info->dlpi_addr = 0x2808a000
```
Ignoring the vDSO as on Linux fixes this.

Tested on `amd64-pc-freebsd14.0`.

---
Full diff: https://github.com/llvm/llvm-project/pull/76223.diff


1 Files Affected:

- (modified) compiler-rt/lib/asan/asan_linux.cpp (+5) 


``````````diff
diff --git a/compiler-rt/lib/asan/asan_linux.cpp b/compiler-rt/lib/asan/asan_linux.cpp
index e19b4479aaf345..f1a9ddceaa8e7b 100644
--- a/compiler-rt/lib/asan/asan_linux.cpp
+++ b/compiler-rt/lib/asan/asan_linux.cpp
@@ -148,6 +148,11 @@ static int FindFirstDSOCallback(struct dl_phdr_info *info, size_t size,
       internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
     return 0;
 #    endif
+#   if SANITIZER_FREEBSD
+  // Ignore vDSO.
+  if (internal_strcmp(info->dlpi_name, "[vdso]") == 0)
+    return 0;
+#   endif
 
   *name = info->dlpi_name;
   return 1;

``````````

</details>


https://github.com/llvm/llvm-project/pull/76223


More information about the llvm-commits mailing list