Print this page
libconv

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/nm/common/nm.c
          +++ new/usr/src/cmd/sgs/nm/common/nm.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1988 AT&T
  24   24   * Copyright (c) 1989 AT&T
  25   25   * All Rights Reserved
  26   26   *
  27   27   * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
       28 + * Copyright 2018 Jason King
  28   29   */
  29   30  
  30   31  #include <stdio.h>
  31   32  #include <stdlib.h>
  32   33  #include <unistd.h>
  33   34  #include <ctype.h>
  34   35  #include <locale.h>
  35   36  #include <libelf.h>
  36   37  #include <sys/elf_SPARC.h>
  37   38  
↓ open down ↓ 760 lines elided ↑ open up ↑
 798  799          s = buf;        /* save pointer to head of array */
 799  800  
 800  801          for (i = 1; i < num; i++, buf++) {
 801  802                  (void) gelf_getsym(data, i, &sym);
 802  803  
 803  804                  buf->indx = i;
 804  805                  /* allow to work on machines where NULL-derefs dump core */
 805  806                  if (sym.st_name == 0)
 806  807                          buf->name = "";
 807  808                  else if (C_flag) {
 808      -                        const char *dn;
      809 +                        const char *dn = NULL;
 809  810                          char *name = (char *)elf_strptr(elf, link, sym.st_name);
      811 +
 810  812                          dn = conv_demangle_name(name);
 811      -                        if (strcmp(dn, name) == 0) {    /* Not demangled */
 812      -                                if (exotic(name)) {
 813      -                                        name = FormatName(name, d_buf);
 814      -                                }
 815      -                        } else {  /* name demangled */
      813 +                        if (dn != name) {
 816  814                                  name = FormatName(name, dn);
      815 +                                free((void *)dn);
      816 +                        } else if (exotic(name)) {
      817 +                                name = FormatName(name, d_buf);
 817  818                          }
 818  819                          buf->name = name;
 819  820                  }
 820  821                  else
 821  822                          buf->name = (char *)elf_strptr(elf, link, sym.st_name);
 822  823  
 823  824                  buf->value      = sym.st_value;
 824  825                  buf->size       = sym.st_size;
 825  826                  buf->type       = GELF_ST_TYPE(sym.st_info);
 826  827                  buf->bind       = GELF_ST_BIND(sym.st_info);
↓ open down ↓ 686 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX