VReport(2, "info->dlpi_name = %s\tinfo->dlpi_addr = %p\n", info->dlpi_name,
(void *)info->dlpi_addr);
- const char **name = (const char **)data;
+ // Continue until the first dynamic library is found
+ if (!info->dlpi_name || info->dlpi_name[0] == 0)
+ return 0;
+
+ // Ignore vDSO
+ if (internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
+ return 0;
+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
// Ignore first entry (the main program)
- if (!*name) {
- *name = "";
+ char **p = (char **)data;
+ if (!(*p)) {
+ *p = (char *)-1;
return 0;
}
+#endif
-# if SANITIZER_LINUX
- // Ignore vDSO
- if (internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
+#if SANITIZER_SOLARIS
+ // Ignore executable on Solaris
+ if (info->dlpi_addr == 0)
return 0;
-# endif
+#endif
- *name = info->dlpi_name;
+ *(const char **)data = info->dlpi_name;
return 1;
}
// Ensure that dynamic RT is the first DSO in the list
const char *first_dso_name = nullptr;
dl_iterate_phdr(FindFirstDSOCallback, &first_dso_name);
- if (first_dso_name && first_dso_name[0] && !IsDynamicRTName(first_dso_name)) {
+ if (first_dso_name && !IsDynamicRTName(first_dso_name)) {
Report("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.\n");