Print this page
cleanup
libconv

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/dump/common/dump.c
          +++ new/usr/src/cmd/sgs/dump/common/dump.c
↓ open down ↓ 469 lines elided ↑ open up ↑
 470  470                  (void) printf("\n");
 471  471                  ndx++;
 472  472          }
 473  473  }
 474  474  
 475  475  /* demangle C++ names */
 476  476  static char *
 477  477  demangled_name(char *s)
 478  478  {
 479  479          static char     *buf = NULL;
 480      -        const char      *dn;
      480 +        size_t          buflen = 0;
      481 +        char            *dn;
 481  482          size_t          len;
 482  483  
 483      -        dn = conv_demangle_name(s);
      484 +        dn = (char *)conv_demangle_name(s);
 484  485  
 485  486          /*
 486  487           * If not demangled, just return the symbol name
 487  488           */
 488      -        if (strcmp(s, dn) == 0)
      489 +        if (dn == s)
 489  490                  return (s);
 490  491  
      492 +        len = strlen(dn) + strlen(s) + 4;
      493 +
      494 +        if (buflen < len) {
      495 +                free(buf);
      496 +                if ((buf = malloc(len)) == NULL)
      497 +                        return (s);
      498 +                buflen = len;
      499 +        }
      500 +
 491  501          /*
 492  502           * Demangled. Format it
 493  503           */
 494      -        if (buf != NULL)
 495      -                free(buf);
 496      -
 497      -        len = strlen(dn) + strlen(s) + 4;
 498      -        if ((buf = malloc(len)) == NULL)
 499      -                return (s);
 500      -
 501      -        (void) snprintf(buf, len, "%s\t[%s]", dn, s);
      504 +        (void) snprintf(buf, buflen, "%s\t[%s]", dn, s);
      505 +        free(dn);
 502  506          return (buf);
 503  507  }
 504  508  
 505  509  /*
 506  510   * Print the symbol table.  Input is an ELF file descriptor, a
 507  511   * pointer to the symbol table SCNTAB structure,
 508  512   * the number of symbols, a range of symbols to print,
 509  513   * an index which is the number of the
 510  514   * section in the file, and the filename.  The number of sections,
 511  515   * the range, and the index are set in
↓ open down ↓ 7 lines elided ↑ open up ↑
 519  523          int adj = 0;            /* field adjustment for elf64 */
 520  524          Elf32_Word      *symshndx = 0;
 521  525          unsigned int    nosymshndx = 0;
 522  526          Conv_inv_buf_t  inv_buf;
 523  527  
 524  528  
 525  529          if (gelf_getclass(elf_file) == ELFCLASS64)
 526  530                  adj = 8;
 527  531  
 528  532          while (range > 0) {
 529      -                char            *sym_name = (char *)0;
      533 +                char            *sym_name = NULL;
 530  534                  int             type, bind;
 531  535                  int             specsec;
 532  536                  unsigned int    shndx;
 533  537  
 534  538                  (void) gelf_getsym(sym_data, index, &sym);
 535  539                  type = (int)GELF_ST_TYPE(sym.st_info);
 536  540                  bind = (int)GELF_ST_BIND(sym.st_info);
 537  541  
 538  542                  if ((sym.st_shndx == SHN_XINDEX) &&
 539  543                      (symshndx == 0) && (nosymshndx == 0)) {
↓ open down ↓ 1592 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX