summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdtrace/common
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libdtrace/common')
-rw-r--r--usr/src/lib/libdtrace/common/dt_cc.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/usr/src/lib/libdtrace/common/dt_cc.c b/usr/src/lib/libdtrace/common/dt_cc.c
index d972aba4f7..56ea585320 100644
--- a/usr/src/lib/libdtrace/common/dt_cc.c
+++ b/usr/src/lib/libdtrace/common/dt_cc.c
@@ -1927,12 +1927,13 @@ static int
dt_load_libs_dir(dtrace_hdl_t *dtp, const char *path)
{
struct dirent *dp;
- const char *p;
+ const char *p, *end;
DIR *dirp;
char fname[PATH_MAX];
FILE *fp;
void *rv;
+ dt_lib_depend_t *dld;
if ((dirp = opendir(path)) == NULL) {
dt_dprintf("skipping lib dir %s: %s\n", path, strerror(errno));
@@ -1953,6 +1954,25 @@ dt_load_libs_dir(dtrace_hdl_t *dtp, const char *path)
continue;
}
+ /*
+ * Skip files whose name match an already processed library
+ */
+ for (dld = dt_list_next(&dtp->dt_lib_dep); dld != NULL;
+ dld = dt_list_next(dld)) {
+ end = strrchr(dld->dtld_library, '/');
+ /* dt_lib_depend_add ensures this */
+ assert(end != NULL);
+ if (strcmp(end + 1, dp->d_name) == 0)
+ break;
+ }
+
+ if (dld != NULL) {
+ dt_dprintf("skipping library %s, already processed "
+ "library with the same name: %s", dp->d_name,
+ dld->dtld_library);
+ continue;
+ }
+
dtp->dt_filetag = fname;
if (dt_lib_depend_add(dtp, &dtp->dt_lib_dep, fname) != 0)
return (-1); /* preserve dt_errno */
@@ -2056,7 +2076,14 @@ dt_load_libs(dtrace_hdl_t *dtp)
dtp->dt_cflags |= DTRACE_C_NOLIBS;
- for (dirp = dt_list_next(&dtp->dt_lib_path);
+ /*
+ * /usr/lib/dtrace is always at the head of the list. The rest of the
+ * list is specified in the precedence order the user requested. Process
+ * everything other than the head first. DTRACE_C_NOLIBS has already
+ * been spcified so dt_vopen will ensure that there is always one entry
+ * in dt_lib_path.
+ */
+ for (dirp = dt_list_next(dt_list_next(&dtp->dt_lib_path));
dirp != NULL; dirp = dt_list_next(dirp)) {
if (dt_load_libs_dir(dtp, dirp->dir_path) != 0) {
dtp->dt_cflags &= ~DTRACE_C_NOLIBS;
@@ -2064,6 +2091,13 @@ dt_load_libs(dtrace_hdl_t *dtp)
}
}
+ /* Handle /usr/lib/dtrace */
+ dirp = dt_list_next(&dtp->dt_lib_path);
+ if (dt_load_libs_dir(dtp, dirp->dir_path) != 0) {
+ dtp->dt_cflags &= ~DTRACE_C_NOLIBS;
+ return (-1); /* errno is set for us */
+ }
+
if (dt_load_libs_sort(dtp) < 0)
return (-1); /* errno is set for us */