Page MenuHomeFreeBSD

D1757.id3640.diff
No OneTemporary

D1757.id3640.diff

Index: cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
===================================================================
--- cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
+++ cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
@@ -36,7 +36,7 @@
#include <string.h>
#include <errno.h>
#include <libelf.h>
-#include <gelf.h>
+#include <dtrace.h>
/*
* In Solaris 10 GA, the only mechanism for communicating helper information
@@ -64,6 +64,9 @@
static int gen; /* DOF helper generation */
#ifdef illumos
extern dof_hdr_t __SUNW_dof; /* DOF defined in the .SUNW_dof section */
+#else
+extern dof_hdr_t __start__SUNW_dof; /* DOF defined in the _SUNW_dof section */
+extern dof_hdr_t __stop__SUNW_dof; /* Ending of DOF section */
#endif
static boolean_t dof_init_debug = B_FALSE; /* From DTRACE_DOF_INIT_DEBUG */
@@ -102,7 +105,9 @@
#ifdef illumos
dof_hdr_t *dof = &__SUNW_dof;
#else
- dof_hdr_t *dof = NULL;
+ dof_hdr_t *dof = &__start__SUNW_dof;
+ dof_hdr_t *dof_end = &__stop__SUNW_dof;
+ dof_hdr_t *dof_next;
#endif
#ifdef _LP64
Elf64_Ehdr *elf;
@@ -118,17 +123,6 @@
#endif
int fd;
const char *p;
-#ifndef illumos
- Elf *e;
- Elf_Scn *scn = NULL;
- Elf_Data *dofdata = NULL;
- dof_hdr_t *dof_next = NULL;
- GElf_Shdr shdr;
- int efd;
- char *s;
- size_t shstridx;
- uint64_t aligned_filesz;
-#endif
if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL)
return;
@@ -152,41 +146,11 @@
modname = lmp->l_name;
else
modname++;
-#ifndef illumos
- elf_version(EV_CURRENT);
- if ((efd = open(lmp->l_name, O_RDONLY, 0)) < 0) {
- dprintf(1, "couldn't open file for reading\n");
- return;
- }
- if ((e = elf_begin(efd, ELF_C_READ, NULL)) == NULL) {
- dprintf(1, "elf_begin failed\n");
- close(efd);
- return;
- }
- elf_getshdrstrndx(e, &shstridx);
- dof = NULL;
- while ((scn = elf_nextscn(e, scn)) != NULL) {
- gelf_getshdr(scn, &shdr);
- if (shdr.sh_type == SHT_SUNW_dof) {
- s = elf_strptr(e, shstridx, shdr.sh_name);
- if (s != NULL && strcmp(s, ".SUNW_dof") == 0) {
- dofdata = elf_getdata(scn, NULL);
- dof = dofdata->d_buf;
- break;
- }
- }
- }
- if (dof == NULL) {
- dprintf(1, "SUNW_dof section not found\n");
- elf_end(e);
- close(efd);
- return;
- }
- while ((char *) dof < (char *) dofdata->d_buf + dofdata->d_size) {
- aligned_filesz = (shdr.sh_addralign == 0 ? dof->dofh_filesz :
- roundup2(dof->dofh_filesz, shdr.sh_addralign));
- dof_next = (void *) ((char *) dof + aligned_filesz);
+#ifdef __FreeBSD__
+ while (dof < dof_end) {
+ dof_next = (void *) ((char *) dof +
+ roundup2(dof->dofh_filesz, DTRACE_DOFSCN_ALIGN));
#endif
if (dof->dofh_ident[DOF_ID_MAG0] != DOF_MAG_MAG0 ||
@@ -237,7 +201,7 @@
dprintf(1, "DTrace ioctl failed for DOF at %p", dof);
else {
dprintf(1, "DTrace ioctl succeeded for DOF at %p\n", dof);
-#ifndef illumos
+#ifdef __FreeBSD__
gen = dh.gen;
#endif
}
@@ -248,9 +212,6 @@
/* End of while loop */
dof = dof_next;
}
-
- elf_end(e);
- (void) close(efd);
#endif
}
Index: cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
===================================================================
--- cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
+++ cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
@@ -79,7 +79,11 @@
static const char DTRACE_SHSTRTAB32[] = "\0"
".shstrtab\0" /* 1 */
+#ifdef illumos
".SUNW_dof\0" /* 11 */
+#else
+"_SUNW_dof\0" /* 11 */
+#endif
".strtab\0" /* 21 */
".symtab\0" /* 29 */
#ifdef __sparc
@@ -90,13 +94,19 @@
static const char DTRACE_SHSTRTAB64[] = "\0"
".shstrtab\0" /* 1 */
+#ifdef illumos
".SUNW_dof\0" /* 11 */
+#else
+"_SUNW_dof\0" /* 11 */
+#endif
".strtab\0" /* 21 */
".symtab\0" /* 29 */
".rela.SUNW_dof"; /* 37 */
+#ifdef illumos
static const char DOFSTR[] = "__SUNW_dof";
static const char DOFLAZYSTR[] = "___SUNW_dof";
+#endif
typedef struct dt_link_pair {
struct dt_link_pair *dlp_next; /* next pair in linked list */
@@ -165,6 +175,7 @@
dep->de_nrel = count;
dep->de_nsym = count + 1; /* the first symbol is always null */
+#ifdef illumos
if (dtp->dt_lazyload) {
dep->de_strlen += sizeof (DOFLAZYSTR);
dep->de_nsym++;
@@ -172,6 +183,7 @@
dep->de_strlen += sizeof (DOFSTR);
dep->de_nsym++;
}
+#endif
if ((dep->de_rel = calloc(dep->de_nrel,
sizeof (dep->de_rel[0]))) == NULL) {
@@ -273,6 +285,7 @@
}
}
+#ifdef illumos
/*
* Add a symbol for the DOF itself. We use a different symbol for
* lazily and actively loaded DOF to make them easy to distinguish.
@@ -293,6 +306,7 @@
bcopy(DOFSTR, dep->de_strtab + strtabsz, sizeof (DOFSTR));
strtabsz += sizeof (DOFSTR);
}
+#endif
assert(count == dep->de_nrel);
assert(strtabsz == dep->de_strlen);
@@ -360,6 +374,7 @@
dep->de_nrel = count;
dep->de_nsym = count + 1; /* the first symbol is always null */
+#ifdef illumos
if (dtp->dt_lazyload) {
dep->de_strlen += sizeof (DOFLAZYSTR);
dep->de_nsym++;
@@ -367,6 +382,7 @@
dep->de_strlen += sizeof (DOFSTR);
dep->de_nsym++;
}
+#endif
if ((dep->de_rel = calloc(dep->de_nrel,
sizeof (dep->de_rel[0]))) == NULL) {
@@ -463,6 +479,7 @@
}
}
+#ifdef illumos
/*
* Add a symbol for the DOF itself. We use a different symbol for
* lazily and actively loaded DOF to make them easy to distinguish.
@@ -483,6 +500,7 @@
bcopy(DOFSTR, dep->de_strtab + strtabsz, sizeof (DOFSTR));
strtabsz += sizeof (DOFSTR);
}
+#endif
assert(count == dep->de_nrel);
assert(strtabsz == dep->de_strlen);
@@ -569,7 +587,11 @@
shp->sh_type = SHT_SUNW_dof;
shp->sh_offset = off;
shp->sh_size = dof->dofh_filesz;
+#ifdef illumos
shp->sh_addralign = 8;
+#else
+ shp->sh_addralign = DTRACE_DOFSCN_ALIGN;
+#endif
off = shp->sh_offset + shp->sh_size;
shp = &elf_file.shdr[ESHDR_STRTAB];
@@ -719,7 +741,11 @@
shp->sh_type = SHT_SUNW_dof;
shp->sh_offset = off;
shp->sh_size = dof->dofh_filesz;
+#ifdef illumos
shp->sh_addralign = 8;
+#else
+ shp->sh_addralign = DTRACE_DOFSCN_ALIGN;
+#endif
off = shp->sh_offset + shp->sh_size;
shp = &elf_file.shdr[ESHDR_STRTAB];
Index: cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
===================================================================
--- cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
+++ cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
@@ -143,6 +143,10 @@
extern int dtrace_program_header(dtrace_hdl_t *, FILE *, const char *);
+#ifndef illumos
+#define DTRACE_DOFSCN_ALIGN 8
+#endif
+
extern void *dtrace_dof_create(dtrace_hdl_t *, dtrace_prog_t *, uint_t);
extern void dtrace_dof_destroy(dtrace_hdl_t *, void *);
Index: share/mk/bsd.dep.mk
===================================================================
--- share/mk/bsd.dep.mk
+++ share/mk/bsd.dep.mk
@@ -121,28 +121,25 @@
.endfor
# DTrace probe definitions
-# libelf is currently needed for drti.o
.if ${SRCS:M*.d}
-LDADD+= -lelf
-DPADD+= ${LIBELF}
CFLAGS+= -I${.OBJDIR}
.endif
.for _DSRC in ${SRCS:M*.d:N*/*}
.for _D in ${_DSRC:R}
DHDRS+= ${_D}.h
${_D}.h: ${_DSRC}
- ${DTRACE} -xnolibs -h -s ${.ALLSRC}
+ ${DTRACE} ${DFLAGS} -h -s ${.ALLSRC}
SRCS:= ${SRCS:S/^${_DSRC}$//}
OBJS+= ${_D}.o
CLEANFILES+= ${_D}.h ${_D}.o
${_D}.o: ${_DSRC} ${OBJS:S/^${_D}.o$//}
- ${DTRACE} -xnolibs -G -o ${.TARGET} -s ${.ALLSRC}
+ ${DTRACE} ${DFLAGS} -G -o ${.TARGET} -s ${.ALLSRC}
.if defined(LIB)
CLEANFILES+= ${_D}.So ${_D}.po
${_D}.So: ${_DSRC} ${SOBJS:S/^${_D}.So$//}
- ${DTRACE} -xnolibs -G -o ${.TARGET} -s ${.ALLSRC}
+ ${DTRACE} ${DFLAGS} -G -o ${.TARGET} -s ${.ALLSRC}
${_D}.po: ${_DSRC} ${POBJS:S/^${_D}.po$//}
- ${DTRACE} -xnolibs -G -o ${.TARGET} -s ${.ALLSRC}
+ ${DTRACE} ${DFLAGS} -G -o ${.TARGET} -s ${.ALLSRC}
.endif
.endfor
.endfor
Index: share/mk/sys.mk
===================================================================
--- share/mk/sys.mk
+++ share/mk/sys.mk
@@ -68,21 +68,23 @@
CTFCONVERT ?= ctfconvert
CTFMERGE ?= ctfmerge
-# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
-# read-only files as non-root by passing -f.
-CP ?= cp -f
-
-DTRACE ?= dtrace
.if defined(CFLAGS) && (${CFLAGS:M-g} != "")
CTFFLAGS += -g
.endif
+# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
+# read-only files as non-root by passing -f.
+CP ?= cp -f
+
CXX ?= c++
CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
PO_CXXFLAGS ?= ${CXXFLAGS}
CPP ?= cpp
+DTRACE ?= dtrace
+DFLAGS ?= -x nolibs
+
.if empty(.MAKEFLAGS:M-s)
ECHO ?= echo
ECHODIR ?= echo

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 27, 10:06 PM (13 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26264165
Default Alt Text
D1757.id3640.diff (8 KB)

Event Timeline