aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-05-18 15:59:17 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-05-18 15:59:17 +0000
commit7cfe04239d86856773f86b2ec712e0982ce23ac8 (patch)
treef21c8e9b65b7270b21596029fa13cc7f35a49347
parentb3ba39776441fc8097776c665a508bd992d81449 (diff)
downloadsrc-7cfe04239d86856773f86b2ec712e0982ce23ac8.tar.gz
src-7cfe04239d86856773f86b2ec712e0982ce23ac8.zip
MF11 r361088:
Merge changes that enable DTrace-using ports to link correctly with lld 10, avoiding "unknown relocation 8" and other errors. MFC r312658 (by markj): Remove the DTRACEHIOC_ADD ioctl. This ioctl has been considered legacy by upstream since the DTrace code was first imported, and is unused. The removal also allows some simplification of dtrace_helper_slurp(). Also remove a bogus copyout in the DTRACEHIOC_ADDDOF handler. Due to a bug, it would overwrite an in-memory copy of the DOF header rather than the passed-in DOF helper. Moreover, DTRACEHIOC_ADDDOF already copies the helper back out automatically since its argument has the IOC_OUT attribute. MFC r313262 (by markj): Use PC-relative relocations for USDT probe sites on i386 and amd64. When recording probe site addresses in the output DOF file, dtrace -G needs to emit relocations for the .SUNW_dof section in order to obtain the addresses of functions containing probe sites. DTrace expects the addresses to be relative to the base address of the final ELF file, and the amd64 USDT implementation was relying on some unspecified and incorrect behaviour in the base system GNU ld to achieve this. This change reimplements the probe site relocation handling to allow USDT to be used with lld and newer GNU binutils. Specifically, it makes use of R_X86_64_PC64/R_386_PC32 relocations to obtain the probe site address relative to the DOF file address, and adds and uses a new DOF relocation type which computes the final probe site address using these relative offsets. Approved by: re (gjb) Reported by and discussed with: Rafael Esp?ndola Differential Revision: https://reviews.freebsd.org/D9374
Notes
Notes: svn path=/releng/11.4/; revision=361217
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c14
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c140
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c8
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c59
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h2
-rw-r--r--sys/cddl/dev/dtrace/dtrace_ioctl.c14
6 files changed, 89 insertions, 148 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
index a4e325671f9f..3d1d976bd3dd 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
@@ -462,18 +462,8 @@ dof_add_probe(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
dt_buf_write(dtp, &ddo->ddo_enoffs, pip->pi_enoffs,
pip->pi_nenoffs * sizeof (uint32_t), sizeof (uint32_t));
- /*
- * If pi_rname isn't set, the relocation will be against the
- * function name. If it is, the relocation will be against
- * pi_rname. This will be used if the function is scoped
- * locally so an alternate symbol is added for the purpose
- * of this relocation.
- */
- if (pip->pi_rname == NULL)
- dofr.dofr_name = dofpr.dofpr_func;
- else
- dofr.dofr_name = dof_add_string(ddo, pip->pi_rname);
- dofr.dofr_type = DOF_RELO_SETX;
+ dofr.dofr_name = dof_add_string(ddo, pip->pi_rname);
+ dofr.dofr_type = DOF_RELO_DOFREL;
dofr.dofr_offset = dt_buf_len(&ddo->ddo_probes);
dofr.dofr_data = 0;
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
index 1da91f003591..1120a6947c0b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
@@ -239,7 +239,7 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep)
rel->r_offset = s->dofs_offset +
dofr[j].dofr_offset;
rel->r_info = ELF32_R_INFO(count + dep->de_global,
- R_386_32);
+ R_386_PC32);
#elif defined(__mips__)
/* XXX */
printf("%s:%s(%d): MIPS not implemented\n",
@@ -257,15 +257,6 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep)
/* XXX */
printf("%s:%s(%d): RISC-V not implemented\n",
__FUNCTION__, __FILE__, __LINE__);
-#elif defined(__sparc)
- /*
- * Add 4 bytes to hit the low half of this 64-bit
- * big-endian address.
- */
- rel->r_offset = s->dofs_offset +
- dofr[j].dofr_offset + 4;
- rel->r_info = ELF32_R_INFO(count + dep->de_global,
- R_SPARC_32);
#else
#error unknown ISA
#endif
@@ -274,7 +265,7 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep)
sym->st_value = 0;
sym->st_size = 0;
sym->st_info = ELF32_ST_INFO(STB_GLOBAL, STT_FUNC);
- sym->st_other = 0;
+ sym->st_other = ELF32_ST_VISIBILITY(STV_HIDDEN);
sym->st_shndx = SHN_UNDEF;
rel++;
@@ -291,11 +282,7 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep)
sym->st_value = 0;
sym->st_size = dof->dofh_filesz;
sym->st_info = ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT);
-#ifdef illumos
- sym->st_other = 0;
-#else
sym->st_other = ELF32_ST_VISIBILITY(STV_HIDDEN);
-#endif
sym->st_shndx = ESHDR_DOF;
sym++;
@@ -452,18 +439,8 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
#elif defined(__i386) || defined(__amd64)
rel->r_offset = s->dofs_offset +
dofr[j].dofr_offset;
-#ifdef illumos
- rel->r_info = ELF64_R_INFO(count + dep->de_global,
- R_AMD64_64);
-#else
- rel->r_info = ELF64_R_INFO(count + dep->de_global,
- R_X86_64_RELATIVE);
-#endif
-#elif defined(__sparc)
- rel->r_offset = s->dofs_offset +
- dofr[j].dofr_offset;
rel->r_info = ELF64_R_INFO(count + dep->de_global,
- R_SPARC_64);
+ R_X86_64_PC64);
#else
#error unknown ISA
#endif
@@ -472,7 +449,7 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
sym->st_value = 0;
sym->st_size = 0;
sym->st_info = GELF_ST_INFO(STB_GLOBAL, STT_FUNC);
- sym->st_other = 0;
+ sym->st_other = ELF64_ST_VISIBILITY(STV_HIDDEN);
sym->st_shndx = SHN_UNDEF;
rel++;
@@ -489,11 +466,7 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
sym->st_value = 0;
sym->st_size = dof->dofh_filesz;
sym->st_info = GELF_ST_INFO(STB_GLOBAL, STT_OBJECT);
-#ifdef illumos
- sym->st_other = 0;
-#else
sym->st_other = ELF64_ST_VISIBILITY(STV_HIDDEN);
-#endif
sym->st_shndx = ESHDR_DOF;
sym++;
@@ -801,16 +774,15 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
}
static int
-dt_symtab_lookup(Elf_Data *data_sym, int nsym, uintptr_t addr, uint_t shn,
- GElf_Sym *sym, int uses_funcdesc, Elf *elf)
+dt_symtab_lookup(Elf_Data *data_sym, int start, int end, uintptr_t addr,
+ uint_t shn, GElf_Sym *sym, int uses_funcdesc, Elf *elf)
{
- int i, ret = -1;
Elf64_Addr symval;
Elf_Scn *opd_scn;
Elf_Data *opd_desc;
- GElf_Sym s;
+ int i;
- for (i = 0; i < nsym && gelf_getsym(data_sym, i, sym) != NULL; i++) {
+ for (i = start; i < end && gelf_getsym(data_sym, i, sym) != NULL; i++) {
if (GELF_ST_TYPE(sym->st_info) == STT_FUNC) {
symval = sym->st_value;
if (uses_funcdesc) {
@@ -820,20 +792,12 @@ dt_symtab_lookup(Elf_Data *data_sym, int nsym, uintptr_t addr, uint_t shn,
*(uint64_t*)((char *)opd_desc->d_buf + symval);
}
if ((uses_funcdesc || shn == sym->st_shndx) &&
- symval <= addr &&
- addr < symval + sym->st_size) {
- if (GELF_ST_BIND(sym->st_info) == STB_GLOBAL)
- return (0);
-
- ret = 0;
- s = *sym;
- }
+ symval <= addr && addr < symval + sym->st_size)
+ return (0);
}
}
- if (ret == 0)
- *sym = s;
- return (ret);
+ return (-1);
}
#if defined(__aarch64__)
@@ -1245,7 +1209,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
dt_provider_t *pvp;
dt_probe_t *prp;
uint32_t off, eclass, emachine1, emachine2;
- size_t symsize, nsym, isym, istr, len;
+ size_t symsize, osym, nsym, isym, istr, len;
key_t objkey;
dt_link_pair_t *pair, *bufs = NULL;
dt_strtab_t *strtab;
@@ -1382,12 +1346,13 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
* target (text) section to replace the call instruction with
* one or more nops.
*
- * If the function containing the probe is locally scoped
- * (static), we create an alias used by the relocation in the
- * generated object. The alias, a new symbol, will be global
- * (so that the relocation from the generated object can be
- * resolved), and hidden (so that it is converted to a local
- * symbol at link time). Such aliases have this form:
+ * To avoid runtime overhead, the relocations added to the
+ * generated object should be resolved at static link time. We
+ * therefore create aliases for the functions that contain
+ * probes. An alias is global (so that the relocation from the
+ * generated object can be resolved), and hidden (so that its
+ * address is known at static link time). Such aliases have this
+ * form:
*
* $dtrace<key>.<function>
*
@@ -1425,16 +1390,13 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
if (strncmp(s, dt_prefix, sizeof (dt_prefix) - 1) != 0)
continue;
- if (dt_symtab_lookup(data_sym, isym, rela.r_offset,
- shdr_rel.sh_info, &fsym,
- (emachine1 == EM_PPC64), elf) != 0) {
+ if (dt_symtab_lookup(data_sym, 0, isym, rela.r_offset,
+ shdr_rel.sh_info, &fsym, (emachine1 == EM_PPC64),
+ elf) != 0) {
dt_strtab_destroy(strtab);
goto err;
}
- if (GELF_ST_BIND(fsym.st_info) != STB_LOCAL)
- continue;
-
if (fsym.st_name > data_str->d_size) {
dt_strtab_destroy(strtab);
goto err;
@@ -1470,12 +1432,12 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
}
/*
- * If needed, allocate the additional space for the symbol
- * table and string table copying the old data into the new
- * buffers, and marking the buffers as dirty. We inject those
- * newly allocated buffers into the libelf data structures, but
- * are still responsible for freeing them once we're done with
- * the elf handle.
+ * If any probes were found, allocate the additional space for
+ * the symbol table and string table, copying the old data into
+ * the new buffers, and marking the buffers as dirty. We inject
+ * those newly allocated buffers into the libelf data
+ * structures, but are still responsible for freeing them once
+ * we're done with the elf handle.
*/
if (nsym > 0) {
/*
@@ -1524,9 +1486,11 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
shdr_sym.sh_size += nsym * symsize;
(void) gelf_update_shdr(scn_sym, &shdr_sym);
+ osym = isym;
nsym += isym;
} else {
dt_strtab_destroy(strtab);
+ continue;
}
/*
@@ -1585,8 +1549,11 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
bcopy(s, pname, p - s);
pname[p - s] = '\0';
- if (dt_symtab_lookup(data_sym, isym, rela.r_offset,
- shdr_rel.sh_info, &fsym,
+ if (dt_symtab_lookup(data_sym, osym, isym,
+ rela.r_offset, shdr_rel.sh_info, &fsym,
+ (emachine1 == EM_PPC64), elf) != 0 &&
+ dt_symtab_lookup(data_sym, 0, osym,
+ rela.r_offset, shdr_rel.sh_info, &fsym,
(emachine1 == EM_PPC64), elf) != 0)
goto err;
@@ -1596,37 +1563,30 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
assert(GELF_ST_TYPE(fsym.st_info) == STT_FUNC);
/*
- * If a NULL relocation name is passed to
- * dt_probe_define(), the function name is used for the
- * relocation. The relocation needs to use a mangled
- * name if the symbol is locally scoped; the function
- * name may need to change if we've found the global
- * alias for the locally scoped symbol (we prefer
- * global symbols to locals in dt_symtab_lookup()).
+ * If this is our first time encountering this symbol,
+ * emit an alias.
*/
s = (char *)data_str->d_buf + fsym.st_name;
- r = NULL;
- if (GELF_ST_BIND(fsym.st_info) == STB_LOCAL) {
+ if (strncmp(s, dt_symprefix,
+ sizeof (dt_symprefix) - 1) != 0) {
+ u_int bind = GELF_ST_BIND(fsym.st_info);
+
dsym = fsym;
dsym.st_name = istr;
- dsym.st_info = GELF_ST_INFO(STB_GLOBAL,
- STT_FUNC);
- dsym.st_other =
- ELF64_ST_VISIBILITY(STV_ELIMINATE);
+ dsym.st_info = GELF_ST_INFO(bind == STB_LOCAL ?
+ STB_GLOBAL : bind, STT_FUNC);
+ dsym.st_other = GELF_ST_VISIBILITY(STV_HIDDEN);
(void) gelf_update_sym(data_sym, isym, &dsym);
-
- r = (char *)data_str->d_buf + istr;
- istr += 1 + sprintf(r, dt_symfmt,
- dt_symprefix, objkey, s);
+ r = (char *) data_str->d_buf + istr;
+ istr += 1 + sprintf(r, dt_symfmt, dt_symprefix, objkey,
+ s);
isym++;
assert(isym <= nsym);
-
- } else if (strncmp(s, dt_symprefix,
- strlen(dt_symprefix)) == 0) {
+ } else {
r = s;
- if ((s = strchr(s, '.')) == NULL)
- goto err;
+ s = strchr(s, '.');
+ assert(s != NULL);
s++;
}
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
index 29138746cfd9..7cf352d4d505 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
@@ -545,9 +545,7 @@ dt_probe_define(dt_provider_t *pvp, dt_probe_t *prp,
for (pip = prp->pr_inst; pip != NULL; pip = pip->pi_next) {
if (strcmp(pip->pi_fname, fname) == 0 &&
- ((rname == NULL && pip->pi_rname == NULL) ||
- (rname != NULL && pip->pi_rname != NULL &&
- strcmp(pip->pi_rname, rname) == 0)))
+ strcmp(pip->pi_rname, rname) == 0)
break;
}
@@ -565,7 +563,7 @@ dt_probe_define(dt_provider_t *pvp, dt_probe_t *prp,
if ((pip->pi_fname = strdup(fname)) == NULL)
goto nomem;
- if (rname != NULL && (pip->pi_rname = strdup(rname)) == NULL)
+ if ((pip->pi_rname = strdup(rname)) == NULL)
goto nomem;
pip->pi_noffs = 0;
@@ -605,7 +603,7 @@ dt_probe_define(dt_provider_t *pvp, dt_probe_t *prp,
dt_dprintf("defined probe %s %s:%s %s() +0x%x (%s)\n",
isenabled ? "(is-enabled)" : "",
pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, fname, offset,
- rname != NULL ? rname : fname);
+ rname);
assert(*noffs < *maxoffs);
(*offs)[(*noffs)++] = offset;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
index 5dd7d28c693e..7baaf24c7267 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
@@ -13886,12 +13886,13 @@ err:
/*
* Apply the relocations from the specified 'sec' (a DOF_SECT_URELHDR) to the
- * specified DOF. At present, this amounts to simply adding 'ubase' to the
- * site of any user SETX relocations to account for load object base address.
- * In the future, if we need other relocations, this function can be extended.
+ * specified DOF. SETX relocations are computed using 'ubase', the base load
+ * address of the object containing the DOF, and DOFREL relocations are relative
+ * to the relocation offset within the DOF.
*/
static int
-dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase)
+dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase,
+ uint64_t udaddr)
{
uintptr_t daddr = (uintptr_t)dof;
uintptr_t ts_end;
@@ -13931,6 +13932,7 @@ dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase)
case DOF_RELO_NONE:
break;
case DOF_RELO_SETX:
+ case DOF_RELO_DOFREL:
if (r->dofr_offset >= ts->dofs_size || r->dofr_offset +
sizeof (uint64_t) > ts->dofs_size) {
dtrace_dof_error(dof, "bad relocation offset");
@@ -13947,7 +13949,11 @@ dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase)
return (-1);
}
- *(uint64_t *)taddr += ubase;
+ if (r->dofr_type == DOF_RELO_SETX)
+ *(uint64_t *)taddr += ubase;
+ else
+ *(uint64_t *)taddr +=
+ udaddr + ts->dofs_offset + r->dofr_offset;
break;
default:
dtrace_dof_error(dof, "invalid relocation type");
@@ -13968,7 +13974,7 @@ dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase)
*/
static int
dtrace_dof_slurp(dof_hdr_t *dof, dtrace_vstate_t *vstate, cred_t *cr,
- dtrace_enabling_t **enabp, uint64_t ubase, int noprobes)
+ dtrace_enabling_t **enabp, uint64_t ubase, uint64_t udaddr, int noprobes)
{
uint64_t len = dof->dofh_loadsz, seclen;
uintptr_t daddr = (uintptr_t)dof;
@@ -14130,7 +14136,7 @@ dtrace_dof_slurp(dof_hdr_t *dof, dtrace_vstate_t *vstate, cred_t *cr,
switch (sec->dofs_type) {
case DOF_SECT_URELHDR:
- if (dtrace_dof_relocate(dof, sec, ubase) != 0)
+ if (dtrace_dof_relocate(dof, sec, ubase, udaddr) != 0)
return (-1);
break;
}
@@ -15495,7 +15501,7 @@ dtrace_anon_property(void)
}
rv = dtrace_dof_slurp(dof, &state->dts_vstate, CRED(),
- &dtrace_anon.dta_enabling, 0, B_TRUE);
+ &dtrace_anon.dta_enabling, 0, 0, B_TRUE);
if (rv == 0)
rv = dtrace_dof_options(dof, state);
@@ -16250,18 +16256,11 @@ dtrace_helper_provider_validate(dof_hdr_t *dof, dof_sec_t *sec)
}
static int
-#ifdef __FreeBSD__
dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp, struct proc *p)
-#else
-dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
-#endif
{
dtrace_helpers_t *help;
dtrace_vstate_t *vstate;
dtrace_enabling_t *enab = NULL;
-#ifndef __FreeBSD__
- proc_t *p = curproc;
-#endif
int i, gen, rv, nhelpers = 0, nprovs = 0, destroy = 1;
uintptr_t daddr = (uintptr_t)dof;
@@ -16272,8 +16271,8 @@ dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
vstate = &help->dthps_vstate;
- if ((rv = dtrace_dof_slurp(dof, vstate, NULL, &enab,
- dhp != NULL ? dhp->dofhp_addr : 0, B_FALSE)) != 0) {
+ if ((rv = dtrace_dof_slurp(dof, vstate, NULL, &enab, dhp->dofhp_addr,
+ dhp->dofhp_dof, B_FALSE)) != 0) {
dtrace_dof_destroy(dof);
return (rv);
}
@@ -16281,22 +16280,20 @@ dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
/*
* Look for helper providers and validate their descriptions.
*/
- if (dhp != NULL) {
- for (i = 0; i < dof->dofh_secnum; i++) {
- dof_sec_t *sec = (dof_sec_t *)(uintptr_t)(daddr +
- dof->dofh_secoff + i * dof->dofh_secsize);
-
- if (sec->dofs_type != DOF_SECT_PROVIDER)
- continue;
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ dof_sec_t *sec = (dof_sec_t *)(uintptr_t)(daddr +
+ dof->dofh_secoff + i * dof->dofh_secsize);
- if (dtrace_helper_provider_validate(dof, sec) != 0) {
- dtrace_enabling_destroy(enab);
- dtrace_dof_destroy(dof);
- return (-1);
- }
+ if (sec->dofs_type != DOF_SECT_PROVIDER)
+ continue;
- nprovs++;
+ if (dtrace_helper_provider_validate(dof, sec) != 0) {
+ dtrace_enabling_destroy(enab);
+ dtrace_dof_destroy(dof);
+ return (-1);
}
+
+ nprovs++;
}
/*
@@ -16337,7 +16334,7 @@ dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
gen = help->dthps_generation++;
dtrace_enabling_destroy(enab);
- if (dhp != NULL && nprovs > 0) {
+ if (nprovs > 0) {
/*
* Now that this is in-kernel, we change the sense of the
* members: dofhp_dof denotes the in-kernel copy of the DOF
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
index ef33a56cb187..2b2731c0f0e7 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
@@ -788,6 +788,7 @@ typedef struct dof_relodesc {
#define DOF_RELO_NONE 0 /* empty relocation entry */
#define DOF_RELO_SETX 1 /* relocate setx value */
+#define DOF_RELO_DOFREL 2 /* relocate DOF-relative value */
typedef struct dof_optdesc {
uint32_t dofo_option; /* option identifier */
@@ -1414,7 +1415,6 @@ typedef struct {
#define DTRACEHIOC_REMOVE (DTRACEHIOC | 2) /* remove helper */
#define DTRACEHIOC_ADDDOF (DTRACEHIOC | 3) /* add helper DOF */
#else
-#define DTRACEHIOC_ADD _IOWR('z', 1, dof_hdr_t)/* add helper */
#define DTRACEHIOC_REMOVE _IOW('z', 2, int) /* remove helper */
#define DTRACEHIOC_ADDDOF _IOWR('z', 3, dof_helper_t)/* add helper DOF */
#endif
diff --git a/sys/cddl/dev/dtrace/dtrace_ioctl.c b/sys/cddl/dev/dtrace/dtrace_ioctl.c
index 4ac3b0d4e993..e35d40023e9e 100644
--- a/sys/cddl/dev/dtrace/dtrace_ioctl.c
+++ b/sys/cddl/dev/dtrace/dtrace_ioctl.c
@@ -44,10 +44,8 @@ dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
case DTRACEHIOC_ADDDOF:
dhp = (dof_helper_t *)addr;
addr = (caddr_t)(uintptr_t)dhp->dofhp_dof;
- /* FALLTHROUGH */
- case DTRACEHIOC_ADD:
- p = curproc;
- if (dhp == NULL || p->p_pid == dhp->dofhp_pid) {
+ if (p->p_pid == dhp->dofhp_pid) {
+ p = curproc;
dof = dtrace_dof_copyin((uintptr_t)addr, &rval);
} else {
p = pfind(dhp->dofhp_pid);
@@ -72,10 +70,7 @@ dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
mutex_enter(&dtrace_lock);
if ((rval = dtrace_helper_slurp(dof, dhp, p)) != -1) {
- if (dhp != NULL) {
- dhp->dofhp_gen = rval;
- copyout(dhp, addr, sizeof(*dhp));
- }
+ dhp->dofhp_gen = rval;
rval = 0;
} else {
rval = EINVAL;
@@ -432,7 +427,8 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
return (EBUSY);
}
- if (dtrace_dof_slurp(dof, vstate, td->td_ucred, &enab, 0, B_TRUE) != 0) {
+ if (dtrace_dof_slurp(dof, vstate, td->td_ucred, &enab, 0, 0,
+ B_TRUE) != 0) {
mutex_exit(&dtrace_lock);
mutex_exit(&cpu_lock);
dtrace_dof_destroy(dof);