diff options
author | dim <dim@FreeBSD.org> | 2014-07-09 17:31:57 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-07-09 17:31:57 +0000 |
commit | 231e8a9942fcfd0676d2a3b465421e8c6eab1b33 (patch) | |
tree | ca65259d1511344c42653978f8511db87db01e85 /lib | |
parent | f61cfea21c1fca628cee6142824f1baaf3f8ec14 (diff) | |
download | FreeBSD-src-231e8a9942fcfd0676d2a3b465421e8c6eab1b33.zip FreeBSD-src-231e8a9942fcfd0676d2a3b465421e8c6eab1b33.tar.gz |
In libproc, avoid calling __cxa_demangle(), and thus depending on either
libcxxrt or libsupc++, if WITHOUT_CXX is defined.
Noticed by: sbruno
MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libproc/Makefile | 4 | ||||
-rw-r--r-- | lib/libproc/proc_sym.c | 35 |
2 files changed, 21 insertions, 18 deletions
diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile index 7375a9a..dafe10d 100644 --- a/lib/libproc/Makefile +++ b/lib/libproc/Makefile @@ -15,7 +15,9 @@ INCS= libproc.h CFLAGS+= -I${.CURDIR} -.if ${MK_LIBCPLUSPLUS} != "no" +.if ${MK_CXX} == "no" +CFLAGS+= -DNO_CXA_DEMANGLE +.elif ${MK_LIBCPLUSPLUS} != "no" LDADD+= -lcxxrt DPADD+= ${LIBCXXRT} .else diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c index 3777a46..4d60043 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); } @@ -297,10 +304,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 @@ -335,10 +339,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 |