Skip to content

Commit

Permalink
lang/gcc12: Fix Address sanitizer
Browse files Browse the repository at this point in the history
Software compiled with -fsanitize=address fails to run with the error
message "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".

This commit fixes the issue by ignoring the [vdso] loaded shared library
instead of linux-vdso.so.

PR:		267751
Reported by:	yuri
  • Loading branch information
lsalvadore committed Nov 30, 2022
1 parent 20320b8 commit 2714142
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lang/gcc12/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PORTNAME= gcc
PORTVERSION= 12.2.0
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= lang
MASTER_SITES= GCC
PKGNAMESUFFIX= ${SUFFIX}
Expand Down
18 changes: 18 additions & 0 deletions lang/gcc12/files/patch-libsanitizer_asan_asan__linux.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Since the vDSO shared librares on Linux and FreeBSD are called
differently, the initialization order check fails on FreeBSD.
This patch fixes it by ignoring [vdso] instead of linux-vdso.so.

GCC gets the original file from the LLVM Project, so this patch should
probably be upstreamed directly to the LLVM Project rather than to GCC.

--- libsanitizer/asan/asan_linux.cpp.orig 2022-11-23 10:52:45 UTC
+++ libsanitizer/asan/asan_linux.cpp
@@ -135,7 +135,7 @@ static int FindFirstDSOCallback(struct dl_phdr_info *i
return 0;

// Ignore vDSO
- if (internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
+ if (internal_strncmp(info->dlpi_name, "[vdso]", sizeof("[vdso]") - 1) == 0)
return 0;

#if SANITIZER_FREEBSD || SANITIZER_NETBSD

0 comments on commit 2714142

Please sign in to comment.