summaryrefslogtreecommitdiffstats
path: root/lib/libproc
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-07-16 21:04:31 +0000
committerdim <dim@FreeBSD.org>2014-07-16 21:04:31 +0000
commit082dc1af3f2b61b464dcf541f07a5ee1969edbb2 (patch)
tree903950a6c9766d294f5b5f667e514ceccf1bc3c1 /lib/libproc
parent023ca0c8f68b8a39653244e83be177b48fcc5989 (diff)
downloadFreeBSD-src-082dc1af3f2b61b464dcf541f07a5ee1969edbb2.zip
FreeBSD-src-082dc1af3f2b61b464dcf541f07a5ee1969edbb2.tar.gz
MFC r268463:
In libproc, avoid calling __cxa_demangle(), and thus depending on either libcxxrt or libsupc++, if WITHOUT_CXX is defined. [1] Noticed by: sbruno [1] However, on stable/10 this is more accurately described by WITHOUT_GNUCXX, so I've changed the test to that instead.
Diffstat (limited to 'lib/libproc')
-rw-r--r--lib/libproc/Makefile4
-rw-r--r--lib/libproc/proc_sym.c35
2 files changed, 21 insertions, 18 deletions
diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
index 4449c06..898bb3a 100644
--- a/lib/libproc/Makefile
+++ b/lib/libproc/Makefile
@@ -18,9 +18,11 @@ CFLAGS+= -I${.CURDIR}
.if ${MK_LIBCPLUSPLUS} != "no"
LDADD+= -lcxxrt
DPADD+= ${LIBCXXRT}
-.else
+.elif ${MK_GNUCXX} != "no"
LDADD+= -lsupc++
DPADD+= ${LIBSTDCPLUSPLUS}
+.else
+CFLAGS+= -DNO_CXA_DEMANGLE
.endif
SHLIB_MAJOR= 2
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c
index 2338895..4be1126 100644
--- a/lib/libproc/proc_sym.c
+++ b/lib/libproc/proc_sym.c
@@ -46,27 +46,34 @@
#include "_libproc.h"
+#ifndef NO_CXA_DEMANGLE
extern char *__cxa_demangle(const char *, char *, size_t *, int *);
+#endif /* NO_CXA_DEMANGLE */
static void proc_rdl2prmap(rd_loadobj_t *, prmap_t *);
static void
demangle(const char *symbol, char *buf, size_t len)
{
+#ifndef NO_CXA_DEMANGLE
char *dembuf;
- size_t demlen = len;
+ size_t demlen;
- dembuf = malloc(len);
- if (!dembuf)
- goto fail;
- dembuf = __cxa_demangle(symbol, dembuf, &demlen, NULL);
- if (!dembuf)
- goto fail;
- strlcpy(buf, dembuf, len);
- free(dembuf);
+ if (symbol[0] == '_' && symbol[1] == 'Z' && symbol[2]) {
+ dembuf = malloc(len);
+ if (!dembuf)
+ goto fail;
+ demlen = len;
+ dembuf = __cxa_demangle(symbol, dembuf, &demlen, NULL);
+ if (!dembuf)
+ goto fail;
+ strlcpy(buf, dembuf, len);
+ free(dembuf);
+ }
return;
fail:
+#endif /* NO_CXA_DEMANGLE */
strlcpy(buf, symbol, len);
}
@@ -291,10 +298,7 @@ proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name,
if (addr >= rsym && addr < rsym + sym.st_size) {
s = elf_strptr(e, dynsymstridx, sym.st_name);
if (s) {
- if (s[0] == '_' && s[1] == 'Z' && s[2])
- demangle(s, name, namesz);
- else
- strlcpy(name, s, namesz);
+ demangle(s, name, namesz);
memcpy(symcopy, &sym, sizeof(sym));
/*
* DTrace expects the st_value to contain
@@ -329,10 +333,7 @@ symtab:
if (addr >= rsym && addr < rsym + sym.st_size) {
s = elf_strptr(e, symtabstridx, sym.st_name);
if (s) {
- if (s[0] == '_' && s[1] == 'Z' && s[2])
- demangle(s, name, namesz);
- else
- strlcpy(name, s, namesz);
+ demangle(s, name, namesz);
memcpy(symcopy, &sym, sizeof(sym));
/*
* DTrace expects the st_value to contain
OpenPOWER on IntegriCloud