diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-10-15 13:44:56 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-10-15 13:44:56 +0000 |
| commit | 16d3daed247b1695bbf21679b70086c38d044eb7 (patch) | |
| tree | b6f459dfe48396dbd24f046a2f746892a3d8e630 /usr/src/cmd/sgs | |
| parent | 8fe8a39ea9f7811d9c1e2e48a46932561906883f (diff) | |
| parent | a6d101109bfb442cf0db6d8ebb5fb7c32cb16d7e (diff) | |
| download | illumos-joyent-16d3daed247b1695bbf21679b70086c38d044eb7.tar.gz | |
[illumos-gate merge]
commit a6d101109bfb442cf0db6d8ebb5fb7c32cb16d7e
9472 Add smbutil discon command
commit 4226f635096bf9d814aa9fb335518c4855bbe3a3
6375 Add native name demangling support
commit 83b4671e6262c5aa6b4f9fb5a384b1946dfc2e7f
9664 loader: need UEFI32 support
commit e1bf37b1abeb6653a6e35e2bd6924131cced1efe
9884 cw(1) should use -fpic rather than -Kpic
Conflicts:
usr/src/test/util-tests/tests/Makefile
usr/src/cmd/mdb/common/mdb/mdb_demangle.c
Diffstat (limited to 'usr/src/cmd/sgs')
| -rw-r--r-- | usr/src/cmd/sgs/Makefile.com | 4 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/dump/common/dump.c | 29 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/gprof/common/printgprof.c | 99 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/libconv/Makefile.com | 45 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/libconv/common/demangle.c | 48 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/libconv/common/demangle.msg | 6 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/libconv/common/lintsup.c | 2 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/liblddbg/common/util.c | 29 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/nm/common/nm.c | 56 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/prof/common/prof.c | 12 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/prof/common/profv.c | 8 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/rtld/sparc/Makefile | 2 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/rtld/sparcv9/Makefile | 6 |
13 files changed, 186 insertions, 160 deletions
diff --git a/usr/src/cmd/sgs/Makefile.com b/usr/src/cmd/sgs/Makefile.com index 6964761a4e..9230fd96de 100644 --- a/usr/src/cmd/sgs/Makefile.com +++ b/usr/src/cmd/sgs/Makefile.com @@ -66,8 +66,8 @@ CPPFLAGS = -I. -I../common -I../../include -I../../include/$(MACH) \ $(CPPFLAGS.master) -I$(ELFCAP) # PICS64 is unique to our environment -$(PICS64) := sparc_CFLAGS += -xregs=no%appl -K pic -$(PICS64) := sparcv9_CFLAGS += -xregs=no%appl -K pic +$(PICS64) := sparc_CFLAGS += -xregs=no%appl $(C_PICFLAGS) +$(PICS64) := sparcv9_CFLAGS += -xregs=no%appl $(C_PICFLAGS) $(PICS64) := CPPFLAGS += -DPIC -D_REENTRANT LDFLAGS += $(ZIGNORE) diff --git a/usr/src/cmd/sgs/dump/common/dump.c b/usr/src/cmd/sgs/dump/common/dump.c index 016f045dc1..10c10c5b19 100644 --- a/usr/src/cmd/sgs/dump/common/dump.c +++ b/usr/src/cmd/sgs/dump/common/dump.c @@ -24,6 +24,7 @@ * All Rights Reserved * * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018, Joyent, Inc. */ /* Get definitions for the relocation types supported. */ @@ -477,28 +478,32 @@ static char * demangled_name(char *s) { static char *buf = NULL; - const char *dn; + size_t buflen = 0; + char *dn; size_t len; - dn = conv_demangle_name(s); + dn = (char *)conv_demangle_name(s); /* * If not demangled, just return the symbol name */ - if (strcmp(s, dn) == 0) + if (dn == s) return (s); + len = strlen(dn) + strlen(s) + 4; + + if (buflen < len) { + free(buf); + if ((buf = malloc(len)) == NULL) + return (s); + buflen = len; + } + /* * Demangled. Format it */ - if (buf != NULL) - free(buf); - - len = strlen(dn) + strlen(s) + 4; - if ((buf = malloc(len)) == NULL) - return (s); - - (void) snprintf(buf, len, "%s\t[%s]", dn, s); + (void) snprintf(buf, buflen, "%s\t[%s]", dn, s); + free(dn); return (buf); } @@ -526,7 +531,7 @@ print_symtab(Elf *elf_file, SCNTAB *p_symtab, Elf_Data *sym_data, adj = 8; while (range > 0) { - char *sym_name = (char *)0; + char *sym_name = NULL; int type, bind; int specsec; unsigned int shndx; diff --git a/usr/src/cmd/sgs/gprof/common/printgprof.c b/usr/src/cmd/sgs/gprof/common/printgprof.c index d02e9a3d9a..acabccaedd 100644 --- a/usr/src/cmd/sgs/gprof/common/printgprof.c +++ b/usr/src/cmd/sgs/gprof/common/printgprof.c @@ -22,10 +22,11 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2018 Jason King + * Copyright 2018, Joyent, Inc. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <ctype.h> #include <string.h> #include <sys/param.h> @@ -34,7 +35,7 @@ #include "gprof.h" void print_demangled_name(int, nltype *); -void striped_name(char *, nltype **); +static void stripped_name(char **, size_t *, nltype **); extern long hz; @@ -65,7 +66,7 @@ printprof(void) nltype *np; nltype **sortednlp; int i, index; - int print_count = number_funcs_toprint; + int print_count = number_funcs_toprint; bool print_flag = TRUE; mod_info_t *mi; @@ -293,7 +294,7 @@ printgprof(nltype **timesortnlp) { int index; nltype *parentp; - int print_count = number_funcs_toprint; + int print_count = number_funcs_toprint; bool count_flag = TRUE; /* @@ -500,10 +501,7 @@ printname(nltype *selfp) c = demangled_name(selfp); if (selfp->name != 0) { - if (!Cflag) - (void) printf("%s", selfp->name); - else - (void) printf("%s", c); + (void) printf("%s", c); #ifdef DEBUG if (debug & DFNDEBUG) @@ -523,24 +521,26 @@ printname(nltype *selfp) else (void) printf(" (%d)", selfp->index); } + + if (c != selfp->name) + free((void *)c); } void print_demangled_name(int n, nltype *selfp) { - char *c; + char *c = (char *)demangled_name(selfp); int i; - c = selfp->name; - - if (strcmp(c, demangled_name(selfp)) == 0) + if (c == selfp->name) return; - else { - (void) printf("\n"); - for (i = 1; i < n; i++) - (void) printf(" "); - (void) printf("[%s]", selfp->name); - } + + (void) printf("\n"); + for (i = 1; i < n; i++) + (void) printf(" "); + (void) printf("[%s]", selfp->name); + + free(c); } void @@ -862,8 +862,6 @@ printblurb(char *blurbname) (void) fclose(blurbfile); } -char *s1, *s2; - static int namecmp(const void *arg1, const void *arg2) { @@ -873,20 +871,50 @@ namecmp(const void *arg1, const void *arg2) if (!Cflag) return (strcmp((*npp1)->name, (*npp2)->name)); else { - striped_name(s1, npp1); - striped_name(s2, npp2); + static char *s1 = NULL, *s2 = NULL; + static size_t s1len = 0, s2len = 0; + + stripped_name(&s1, &s1len, npp1); + stripped_name(&s2, &s2len, npp2); return (strcmp(s1, s2)); } } -void -striped_name(char *s, nltype **npp) +#define NAME_CHUNK 512 +#define ROUNDLEN(x) (((x) + NAME_CHUNK - 1) / NAME_CHUNK * NAME_CHUNK) +static void +adjust_size(char **pp, size_t *lenp, const char *name) { - const char *d; + void *newp; + size_t nlen = strlen(name); + size_t buflen; + + if (*lenp > nlen) { + (void) memset(*pp, '\0', *lenp); + return; + } + + buflen = ROUNDLEN(nlen + 1); + if ((newp = realloc(*pp, buflen)) == NULL) { + (void) fprintf(stderr, + "gprof: out of memory comparing names\n"); + exit(EXIT_FAILURE); + } + (void) memset(newp, '\0', buflen); + + *lenp = buflen; + *pp = newp; +} + +static void +stripped_name(char **sp, size_t *slenp, nltype **npp) +{ + const char *name, *d; char *c; - c = (char *)s; - d = demangled_name(*npp); + name = d = demangled_name(*npp); + adjust_size(sp, slenp, name); + c = *sp; while ((*d != '(') && (*d != '\0')) { if (*d != ':') @@ -895,6 +923,9 @@ striped_name(char *s, nltype **npp) d++; } *c = '\0'; + + if ((*npp)->name != name) + free((void *)name); } /* @@ -972,11 +1003,6 @@ printindex() } } - if (Cflag) { - s1 = malloc(500 * sizeof (char)); - s2 = malloc(500 * sizeof (char)); - } - qsort(namesortnlp, nnames, sizeof (nltype *), namecmp); for (index = 1, todo = nnames; index <= ncycle; index++) @@ -1038,13 +1064,16 @@ printindex() if (does_clash(namesortnlp, i, nnames)) { (void) printf("%6.6s %d:%s\n", peterbuffer, nlp->module->id, d); - } else + } else { (void) printf("%6.6s %s\n", peterbuffer, d); + } - if (d != nlp->name) + if (d != nlp->name) { (void) printf("%6.6s [%s]", "", nlp->name); + free((void *)d); + } } else { (void) printf("%6.6s ", peterbuffer); (void) sprintf(peterbuffer, "<cycle %d>", diff --git a/usr/src/cmd/sgs/libconv/Makefile.com b/usr/src/cmd/sgs/libconv/Makefile.com index d95213e586..c6287c433c 100644 --- a/usr/src/cmd/sgs/libconv/Makefile.com +++ b/usr/src/cmd/sgs/libconv/Makefile.com @@ -21,12 +21,13 @@ # # Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018, Joyent, Inc. # LIBRARY = libconv.a COMOBJS32 = cap_machelf32.o dynamic_machelf32.o \ - globals_machelf32.o sections_machelf32.o \ + globals_machelf32.o sections_machelf32.o \ symbols_machelf32.o symbols_sparc_machelf32.o COMOBJS64 = cap_machelf64.o dynamic_machelf64.o \ @@ -36,19 +37,19 @@ COMOBJS64 = cap_machelf64.o dynamic_machelf64.o \ COMOBJS= arch.o audit.o \ c_literal.o \ cap.o config.o \ - corenote.o data.o \ - deftag.o demangle.o \ + corenote.o data.o \ + deftag.o demangle.o \ dl.o dwarf.o \ - dwarf_ehe.o dynamic.o \ + dwarf_ehe.o dynamic.o \ elf.o entry.o \ globals.o group.o \ - lddstub.o map.o \ + lddstub.o map.o \ phdr.o relocate.o \ - relocate_i386.o relocate_amd64.o \ + relocate_i386.o relocate_amd64.o \ relocate_sparc.o sections.o \ - segments.o strproc.o \ - symbols.o syminfo.o \ - tokens.o time.o \ + segments.o strproc.o \ + symbols.o syminfo.o \ + tokens.o time.o \ version.o ELFCAP_OBJS= elfcap.o @@ -61,15 +62,15 @@ BLTOBJS= arch_msg.o audit_msg.o \ corenote_msg.o data_msg.o \ deftag_msg.o demangle_msg.o \ dl_msg.o dwarf_msg.o \ - dwarf_ehe_msg.o dynamic_msg.o \ - elf_msg.o entry_msg.o \ + dwarf_ehe_msg.o dynamic_msg.o \ + elf_msg.o entry_msg.o \ globals_msg.o group_msg.o \ - map_msg.o lddstub_msg.o \ - phdr_msg.o relocate_amd64_msg.o \ + map_msg.o lddstub_msg.o \ + phdr_msg.o relocate_amd64_msg.o \ relocate_i386_msg.o relocate_sparc_msg.o \ - sections_msg.o segments_msg.o \ - symbols_msg.o symbols_sparc_msg.o \ - syminfo_msg.o time_msg.o \ + sections_msg.o segments_msg.o \ + symbols_msg.o symbols_sparc_msg.o \ + syminfo_msg.o time_msg.o \ version_msg.o @@ -84,8 +85,8 @@ OBJECTS = $(COMOBJS) $(COMOBJS32) $(COMOBJS64) $(ELFCAP_OBJS) \ NOCTFOBJS = $(OBJECTS) CTFMERGE_LIB = : -include $(SRC)/lib/Makefile.lib -include $(SRC)/cmd/sgs/Makefile.com +include $(SRC)/lib/Makefile.lib +include $(SRC)/cmd/sgs/Makefile.com CERRWARN += -_gcc=-Wno-type-limits CERRWARN += -_gcc=-Wno-switch @@ -113,6 +114,14 @@ LINTSRCS= $(COMOBJS:%.o=../common/%.c) \ LINTSRCS32 = $(COMOBJS32:%32.o=../common/%.c) LINTSRCS64 = $(COMOBJS64:%64.o=../common/%.c) +# Since libconv uses dlopen(3C) to load libdemangle-sys.so (much like it did +# for the old Sun Studio libdemangle.so) in order to avoid messy bootstrapping +# problems, but it also needs the definitions from demangle-sys.h for +# SYSDEM_LANG_AUTO, lint will complain about sysdemangle() being defined but not +# used unless it is explicitly included during the lint pass +$(LINTOUT32) := LDLIBS += -ldemangle-sys +$(LINTOUT64) := LDLIBS += -ldemangle-sys + SGSMSGTARG= $(BLTOBJS:%_msg.o=../common/%.msg) LINTFLAGS += -u diff --git a/usr/src/cmd/sgs/libconv/common/demangle.c b/usr/src/cmd/sgs/libconv/common/demangle.c index 8b590d87e0..eb2961ea3a 100644 --- a/usr/src/cmd/sgs/libconv/common/demangle.c +++ b/usr/src/cmd/sgs/libconv/common/demangle.c @@ -21,10 +21,11 @@ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018, Joyent, Inc. */ #include <stdio.h> -#include <demangle.h> +#include <demangle-sys.h> #include "_conv.h" #include "demangle_msg.h" @@ -59,13 +60,11 @@ const char * conv_demangle_name(const char *name) { - static char _str[SYM_MAX], *str = _str; - static size_t size = SYM_MAX; - static int again = 1; - static int (*fptr)() = 0; - int error; + static char *(*fptr)() = 0; + static volatile int loading = 0; + char *d; - if (str == 0) + if (loading) return (name); /* @@ -78,38 +77,15 @@ conv_demangle_name(const char *name) if (fptr == 0) { void *hdl; - str = 0; + loading = 1; if (!(hdl = dlopen(MSG_ORIG(MSG_DEM_LIB), RTLD_LAZY)) || - !(fptr = (int (*)())dlsym(hdl, MSG_ORIG(MSG_DEM_SYM)))) + !(fptr = (char *(*)())dlsym(hdl, MSG_ORIG(MSG_DEM_SYM)))) return (name); - str = _str; + loading = 0; } - if ((error = (*fptr)(name, str, size)) == 0) - return ((const char *)str); - - while ((error == DEMANGLE_ESPACE) && again) { - char *_str; - size_t _size = size; - - /* - * If we haven't allocated our maximum try incrementing the - * present buffer size. Use malloc() rather than realloc() so - * that we at least have the old buffer on failure. - */ - if (((_size += SYM_MAX) > (SYM_MAX * 4)) || - ((_str = malloc(_size)) == 0)) { - again = 0; - break; - } - if (size != SYM_MAX) { - free(str); - } - str = _str; - size = _size; + if ((d = fptr(name, SYSDEM_LANG_AUTO, NULL)) == NULL) + return (name); - if ((error = (*fptr)(name, str, size)) == 0) - return ((const char *)str); - } - return (name); + return (d); } diff --git a/usr/src/cmd/sgs/libconv/common/demangle.msg b/usr/src/cmd/sgs/libconv/common/demangle.msg index c7cbeaf921..4a69427057 100644 --- a/usr/src/cmd/sgs/libconv/common/demangle.msg +++ b/usr/src/cmd/sgs/libconv/common/demangle.msg @@ -23,8 +23,8 @@ # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" +# Copyright 2018 Jason King # -@ MSG_DEM_SYM "cplus_demangle" -@ MSG_DEM_LIB "libdemangle.so.1" +@ MSG_DEM_SYM "sysdemangle" +@ MSG_DEM_LIB "libdemangle-sys.so.1" diff --git a/usr/src/cmd/sgs/libconv/common/lintsup.c b/usr/src/cmd/sgs/libconv/common/lintsup.c index 4c0d6e4fdd..6f1dfc4125 100644 --- a/usr/src/cmd/sgs/libconv/common/lintsup.c +++ b/usr/src/cmd/sgs/libconv/common/lintsup.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018, Joyent, Inc. */ /* LINTLIBRARY */ /* PROTOLIB1 */ @@ -39,7 +40,6 @@ #include <sys/auxv.h> #include <libelf.h> #include <link.h> -#include <demangle.h> #include <elfcap.h> #include <dwarf.h> #include "sgs.h" diff --git a/usr/src/cmd/sgs/liblddbg/common/util.c b/usr/src/cmd/sgs/liblddbg/common/util.c index 575a9bd15f..09bcd437e9 100644 --- a/usr/src/cmd/sgs/liblddbg/common/util.c +++ b/usr/src/cmd/sgs/liblddbg/common/util.c @@ -22,6 +22,8 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2018 Jason King */ #include "msg.h" @@ -342,16 +344,35 @@ Dbg_util_nl(Lm_list *lml, int flag) const char * Dbg_demangle_name(const char *name) { + static char *buf = NULL; + if (DBG_NOTCLASS(DBG_C_DEMANGLE)) return (name); - return (conv_demangle_name(name)); + free(buf); + buf = (char *)conv_demangle_name(name); + if (buf == name) { + buf = NULL; + return (name); + } + + return (buf); } const char * Elf_demangle_name(const char *name) { - if (DBG_ISDEMANGLE()) - return (conv_demangle_name(name)); - return (name); + static char *buf = NULL; + + if (!DBG_ISDEMANGLE()) + return (name); + + free(buf); + buf = (char *)conv_demangle_name(name); + if (buf == name) { + buf = NULL; + return (name); + } + + return (buf); } diff --git a/usr/src/cmd/sgs/nm/common/nm.c b/usr/src/cmd/sgs/nm/common/nm.c index 258bd9fd67..fc3ded721e 100644 --- a/usr/src/cmd/sgs/nm/common/nm.c +++ b/usr/src/cmd/sgs/nm/common/nm.c @@ -25,6 +25,7 @@ * All Rights Reserved * * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018 Jason King */ #include <stdio.h> @@ -260,7 +261,7 @@ main(int argc, char *argv[], char *envp[]) "%s: -u or -e set, -g ignored\n"), prog_name); break; - case 'r': if (R_flag) { + case 'r': if (R_flag) { R_flag = 0; (void) fprintf(stderr, gettext( "%s: -r set, -R ignored\n"), @@ -666,7 +667,7 @@ static void print_with_otherflags(int, Elf *, unsigned int, */ static void print_symtab(Elf *elf_file, unsigned int shstrndx, - Elf_Scn *p_sd, GElf_Shdr *shdr, char *filename) + Elf_Scn *p_sd, GElf_Shdr *shdr, char *filename) { Elf_Data * sd; @@ -781,7 +782,7 @@ is_bss_section(unsigned int shndx, Elf * elf_file, unsigned int shstrndx) */ static SYM * readsyms(Elf_Data * data, GElf_Sxword num, Elf *elf, - unsigned int link, unsigned int symscnndx) + unsigned int link, unsigned int symscnndx) { SYM *s, *buf; GElf_Sym sym; @@ -805,15 +806,15 @@ readsyms(Elf_Data * data, GElf_Sxword num, Elf *elf, if (sym.st_name == 0) buf->name = ""; else if (C_flag) { - const char *dn; + const char *dn = NULL; char *name = (char *)elf_strptr(elf, link, sym.st_name); + dn = conv_demangle_name(name); - if (strcmp(dn, name) == 0) { /* Not demangled */ - if (exotic(name)) { - name = FormatName(name, d_buf); - } - } else { /* name demangled */ + if (dn != name) { name = FormatName(name, dn); + free((void *)dn); + } else if (exotic(name)) { + name = FormatName(name, d_buf); } buf->name = name; } @@ -1014,10 +1015,7 @@ is_sym_print(SYM *sym_data) * -u flag specified */ static void -print_with_uflag( - SYM *sym_data, - char *filename -) +print_with_uflag(SYM *sym_data, char *filename) { if ((sym_data->shndx == SHN_UNDEF) && (strlen(sym_data->name))) { if (!r_flag) { @@ -1094,18 +1092,13 @@ print_brief_sym_type(Elf *elf_file, unsigned int shstrndx, SYM *sym_data) * -p flag specified */ static void -print_with_pflag( - int ndigits, - Elf *elf_file, - unsigned int shstrndx, - SYM *sym_data, - char *filename -) +print_with_pflag(int ndigits, Elf *elf_file, unsigned int shstrndx, + SYM *sym_data, char *filename) { const char * const fmt[] = { - "%.*llu ", /* FMT_T_DEC */ - "0x%.*llx ", /* FMT_T_HEX */ - "0%.*llo " /* FMT_T_OCT */ + "%.*llu ", /* FMT_T_DEC */ + "0x%.*llx ", /* FMT_T_HEX */ + "0%.*llo " /* FMT_T_OCT */ }; if (is_sym_print(sym_data) != 1) @@ -1148,12 +1141,8 @@ print_with_pflag( * -P flag specified */ static void -print_with_Pflag( - int ndigits, - Elf *elf_file, - unsigned int shstrndx, - SYM *sym_data -) +print_with_Pflag(int ndigits, Elf *elf_file, unsigned int shstrndx, + SYM *sym_data) { #define SYM_LEN 10 char sym_name[SYM_LEN+1]; @@ -1200,13 +1189,8 @@ print_with_Pflag( * other flags specified */ static void -print_with_otherflags( - int ndigits, - Elf *elf_file, - unsigned int shstrndx, - SYM *sym_data, - char *filename -) +print_with_otherflags(int ndigits, Elf *elf_file, unsigned int shstrndx, + SYM *sym_data, char *filename) { const char * const fmt_value_size[] = { "%*llu|%*lld|", /* FMT_T_DEC */ diff --git a/usr/src/cmd/sgs/prof/common/prof.c b/usr/src/cmd/sgs/prof/common/prof.c index 38a0aa0a9f..4b6086040c 100644 --- a/usr/src/cmd/sgs/prof/common/prof.c +++ b/usr/src/cmd/sgs/prof/common/prof.c @@ -22,6 +22,7 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2018 Jason King */ /* Copyright (c) 1988 AT&T */ @@ -32,7 +33,7 @@ * * Usage: * - * prof [-ChsVz] [-a | c | n | t] [-o | x] [-g | l] + * prof [-ChsVz] [-a | c | n | t] [-o | x] [-g | l] * [-m mdata] [prog] * * Where "prog" is the program that was profiled; "a.out" by default. @@ -136,7 +137,7 @@ char *aformat = "%8o "; int gflag = 0; /* replaces gmatch and gmask */ int Cflag = 0; -PROF_FILE *ldptr; /* For program ("a.out") file. */ +PROF_FILE *ldptr; /* For program ("a.out") file. */ FILE *mon_iop; /* For profile (MON_OUT) file. */ char *sym_fn = "a.out"; /* Default program file name. */ @@ -197,7 +198,7 @@ struct snymEntry { char *sym_addr; /* address which has a synonym */ int howMany; /* # of synonyms for this symbol */ int snymReported; /* 'was printed in a report line already' */ - /* flag, */ + /* flag, */ /* > 0 report line printed for these syns. */ /* == 0 not printed yet. */ long tot_sl_count; /* total subr calls for these snyms */ @@ -1311,9 +1312,7 @@ demangled_name(char *s) const char *name; size_t len; - name = conv_demangle_name(s); - - if (strcmp(name, s) == 0) + if ((name = conv_demangle_name(s)) == s) return (s); if (format_buf != NULL) @@ -1324,6 +1323,7 @@ demangled_name(char *s) if (format_buf == NULL) return (s); (void) snprintf(format_buf, len, FORMAT_BUF, name, s); + free((void *)name); return (format_buf); } diff --git a/usr/src/cmd/sgs/prof/common/profv.c b/usr/src/cmd/sgs/prof/common/profv.c index 4f9b72596e..887b36bba5 100644 --- a/usr/src/cmd/sgs/prof/common/profv.c +++ b/usr/src/cmd/sgs/prof/common/profv.c @@ -22,10 +22,10 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2018, Joyent, Inc. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * All routines in this file are for processing new-style, *versioned* * mon.out format. Together with rdelf.c, lookup.c and profv.h, these @@ -74,7 +74,8 @@ setup_demangled_names(void) nbe = namebuf + namebuf_sz; for (i = 0; i < total_funcs; i++) { - if ((p = conv_demangle_name(profsym[i].name)) == NULL) + p = conv_demangle_name(profsym[i].name); + if (p == profsym[i].name) continue; namelen = strlen(p); @@ -97,6 +98,7 @@ setup_demangled_names(void) nbp += namelen + 1; cur_len += namelen + 1; + free((void *)p); } } diff --git a/usr/src/cmd/sgs/rtld/sparc/Makefile b/usr/src/cmd/sgs/rtld/sparc/Makefile index d2630c52db..d3af26fc0b 100644 --- a/usr/src/cmd/sgs/rtld/sparc/Makefile +++ b/usr/src/cmd/sgs/rtld/sparc/Makefile @@ -68,7 +68,7 @@ include $(SRC)/cmd/sgs/rtld/Makefile.com CPPFLAGS += -I../../../../uts/sparc/krtld -DA_OUT CFLAGS += -xregs=no%appl -ASFLAGS += -K pic +ASFLAGS += $(AS_PICFLAGS) LINTFLAGS += -DA_OUT ADBGENCFLAGS += -erroff=%all ADBGENFLAGS += -milp32 diff --git a/usr/src/cmd/sgs/rtld/sparcv9/Makefile b/usr/src/cmd/sgs/rtld/sparcv9/Makefile index 0093a7b86e..d9863462a7 100644 --- a/usr/src/cmd/sgs/rtld/sparcv9/Makefile +++ b/usr/src/cmd/sgs/rtld/sparcv9/Makefile @@ -40,11 +40,11 @@ P_MACHOBJS= sparc_elf.o _setup.o CP_MACHOBJS= common_sparc.o -S_MACHOBJS= +S_MACHOBJS= P_ASOBJS= boot.o boot_elf.o caller.o -S_ASOBJS= +S_ASOBJS= CRTSRCS= ../../../../lib/crt/sparc CRTI= pics/crti.o @@ -68,7 +68,7 @@ include $(SRC)/lib/Makefile.lib.64 CPPFLAGS += -I../../../../uts/sparc/krtld CFLAGS += -xregs=no%appl -ASFLAGS += -s -K pic -D__sparcv9 -D_ELF64 $(sparcv9_XARCH) +ASFLAGS += -s $(AS_PICFLAGS) -D__sparcv9 -D_ELF64 $(sparcv9_XARCH) ADBGENFLAGS += -mlp64 ADBGENCFLAGS += -erroff=%all ADBSUB= $(ADBSUB64) |
