diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index ba5919d9d6b7..ed6d71e6dac6 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -1423,6 +1423,14 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) goto err; } + if ((p = strstr(s, "___")) == NULL) { + dt_strtab_destroy(strtab); + goto err; + } + if (strstr(p + 3, "__") != NULL && + dt_strtab_index(strtab, s) == -1) + dt_strtab_insert(strtab, s); + if (GELF_ST_BIND(fsym.st_info) != STB_LOCAL) continue; @@ -1468,7 +1476,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) * are still responsible for freeing them once we're done with * the elf handle. */ - if (nsym > 0) { + if (nsym > 0 || dt_strtab_size(strtab) > 1) { /* * The first byte of the string table is reserved for * the \0 entry. @@ -1576,7 +1584,22 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) bcopy(s, pname, p - s); pname[p - s] = '\0'; - p = strhyphenate(p + 3); /* strlen("___") */ + p += 3; /* strlen("___") */ + if (strstr(p, "__") != NULL) { + s = (char *) data_str->d_buf + rsym.st_name; + len = strlen(s); + + (void) strlcpy((char *) data_str->d_buf + istr, s, + len + 1); + s = (char *)data_str->d_buf + istr; + p = strstr(s, "___"); + assert(p != NULL); + p = strhyphenate(p + 3); + + rsym.st_name = istr; + istr += len + 1; + (void) gelf_update_sym(data_sym, ndx, &rsym); + } if (dt_symtab_lookup(data_sym, isym, rela.r_offset, shdr_rel.sh_info, &fsym,