aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib/libdtrace
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2016-12-20 18:25:41 +0000
committerMark Johnston <markj@FreeBSD.org>2016-12-20 18:25:41 +0000
commit3a3e3279e7faeac2bba4cbfed15e6b2c67132f62 (patch)
treeab34ce5dbf24d4d73e786b3fa8ccc92efd6bc6d2 /cddl/contrib/opensolaris/lib/libdtrace
parent85b6e3b227dc6a7280645cd500d9ced780de217e (diff)
downloadsrc-3a3e3279e7faeac2bba4cbfed15e6b2c67132f62.tar.gz
src-3a3e3279e7faeac2bba4cbfed15e6b2c67132f62.zip
Avoid modifying the object string table when patching USDT probes.
dtrace converts pairs of consecutive underscores in a probe name to dashes. When dtrace -G processes relocations corresponding to USDT probe sites, it performs this conversion on the corresponding symbol names prior to looking up the resulting probe names in the USDT provider definition. However, in so doing it would actually modify the input object's string table, which breaks the string suffix merging done by recent binutils. Because we don't care about the symbol name once the probe site is recorded, just perform the probe lookup using a temporary copy. Reported by: hrs, swills MFC after: 3 weeks
Notes
Notes: svn path=/head/; revision=310332
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libdtrace')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
index ba5919d9d6b7..f13e10769250 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
@@ -1223,6 +1223,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
static const char dt_enabled[] = "enabled";
static const char dt_symprefix[] = "$dtrace";
static const char dt_symfmt[] = "%s%ld.%s";
+ char probename[DTRACE_NAMELEN];
int fd, i, ndx, eprobe, mod = 0;
Elf *elf = NULL;
GElf_Ehdr ehdr;
@@ -1576,8 +1577,6 @@ 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("___") */
-
if (dt_symtab_lookup(data_sym, isym, rela.r_offset,
shdr_rel.sh_info, &fsym,
(emachine1 == EM_PPC64), elf) != 0)
@@ -1628,10 +1627,14 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
"no such provider %s", pname));
}
- if ((prp = dt_probe_lookup(pvp, p)) == NULL) {
+ if (strlcpy(probename, p + 3, sizeof (probename)) >=
+ sizeof (probename))
return (dt_link_error(dtp, elf, fd, bufs,
- "no such probe %s", p));
- }
+ "invalid probe name %s", probename));
+ (void) strhyphenate(probename);
+ if ((prp = dt_probe_lookup(pvp, probename)) == NULL)
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "no such probe %s", probename));
assert(fsym.st_value <= rela.r_offset);