libnm-core: don't use RTLD_DEEPBIND when building with asan

The address sanitizer is not compatible [1] with libraries dynamically
opened using RTLD_DEEPBIND: disable the flag when building with asan.

[1] https://github.com/google/sanitizers/issues/611
This commit is contained in:
Beniamino Galvani 2018-02-07 15:02:53 +01:00
parent 0af2762cbf
commit 936e0a51fe
2 changed files with 9 additions and 1 deletions

View file

@ -1148,6 +1148,7 @@ if test "$with_address_sanitizer" = yes -o "$with_address_sanitizer" = "exec"; t
sanitizer_exec_cflags="$sanitizer_exec_cflags -fsanitize=address"
sanitizer_exec_ldflags="$sanitizer_exec_ldflags -Wc,-fsanitize=address"
AC_DEFINE(ASAN_BUILD, 1, [Whether NM is built with address sanitizer])
if test "$with_address_sanitizer" = "yes"; then
sanitizer_lib_cflags="$sanitizer_lib_cflags -fsanitize=address"

View file

@ -94,6 +94,7 @@ nm_jansson_load (void)
MISSING,
} state = UNKNOWN;
void *handle;
int mode;
if (G_LIKELY (state != UNKNOWN))
goto out;
@ -102,7 +103,13 @@ nm_jansson_load (void)
if (!bind_symbols (RTLD_DEFAULT))
goto out;
handle = dlopen (JANSSON_SONAME, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE | RTLD_DEEPBIND);
mode = RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE | RTLD_DEEPBIND;
#if defined (ASAN_BUILD)
/* Address sanitizer is incompatible with RTLD_DEEPBIND. */
mode &= ~RTLD_DEEPBIND;
#endif
handle = dlopen (JANSSON_SONAME, mode);
if (!handle)
goto out;