Print this page
3299 file should only care about object capabilities
3300 file should care about all object capabilities

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/file/elf_read.c
          +++ new/usr/src/cmd/file/elf_read.c
↓ open down ↓ 22 lines elided ↑ open up ↑
  23   23  
  24   24  
  25   25  /*      Copyright (c) 1987, 1988 Microsoft Corporation  */
  26   26  /*        All Rights Reserved   */
  27   27  
  28   28  /*
  29   29   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  30   30   * Use is subject to license terms.
  31   31   */
  32   32  
  33      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  34      -
  35   33  /*
  36   34   * ELF files can exceed 2GB in size. A standard 32-bit program
  37   35   * like 'file' cannot read past 2GB, and will be unable to see
  38   36   * the ELF section headers that typically are at the end of the
  39   37   * object. The simplest solution to this problem would be to make
  40   38   * the 'file' command a 64-bit application. However, as a matter of
  41   39   * policy, we do not want to require this. A simple command like
  42   40   * 'file' should not carry such a requirement, especially as we
  43   41   * support 32-bit only hardware.
  44   42   *
↓ open down ↓ 406 lines elided ↑ open up ↑
 451  449                  if (get_shdr(EI, i) == ELF_READ_FAIL)
 452  450                          return (ELF_READ_FAIL);
 453  451  
 454  452                  if (shdr->sh_type == SHT_NULL) {
 455  453                          idx--;
 456  454                          continue;
 457  455                  }
 458  456  
 459  457                  cap_off = shdr->sh_offset;
 460  458                  if (shdr->sh_type == SHT_SUNW_cap) {
      459 +                        char capstr[128];
      460 +
 461  461                          if (shdr->sh_size == 0 || shdr->sh_entsize == 0) {
 462  462                                  (void) fprintf(stderr, ELF_ERR_ELFCAP1,
 463  463                                      File, EI->file);
 464  464                                  return (ELF_READ_FAIL);
 465  465                          }
 466  466                          capn = (shdr->sh_size / shdr->sh_entsize);
 467  467                          for (j = 0; j < capn; j++) {
 468  468                                  /*
 469  469                                   * read cap and xlate the values
 470  470                                   */
 471  471                                  if (pread64(EI->elffd, &Chdr, csize, cap_off)
 472  472                                      != csize ||
 473  473                                      file_xlatetom(ELF_T_CAP, (char *)&Chdr)
 474  474                                      == 0) {
 475  475                                          (void) fprintf(stderr, ELF_ERR_ELFCAP2,
 476  476                                              File, EI->file);
 477  477                                          return (ELF_READ_FAIL);
 478  478                                  }
 479  479  
 480      -                                if (Chdr.c_tag != CA_SUNW_NULL) {
 481      -                                        (void) elfcap_tag_to_str(
 482      -                                            ELFCAP_STYLE_UC, Chdr.c_tag,
 483      -                                            Chdr.c_un.c_val, EI->cap_str,
 484      -                                            sizeof (EI->cap_str),
 485      -                                            ELFCAP_FMT_SNGSPACE, mac);
 486      -                                }
 487  480                                  cap_off += csize;
      481 +
      482 +                                /*
      483 +                                 * Each capatibility group is terminated with
      484 +                                 * CA_SUNW_NULL.  Groups other than the first
      485 +                                 * represent symbol capabilities, and aren't
      486 +                                 * interesting here.
      487 +                                 */
      488 +                                if (Chdr.c_tag == CA_SUNW_NULL)
      489 +                                        break;
      490 +
      491 +                                (void) elfcap_tag_to_str(ELFCAP_STYLE_UC,
      492 +                                    Chdr.c_tag, Chdr.c_un.c_val, capstr,
      493 +                                    sizeof (capstr), ELFCAP_FMT_SNGSPACE,
      494 +                                    mac);
      495 +
      496 +                                if ((*EI->cap_str != '\0') && (*capstr != '\0'))
      497 +                                        (void) strlcat(EI->cap_str, " ",
      498 +                                            sizeof (EI->cap_str));
      499 +
      500 +                                (void) strlcat(EI->cap_str, capstr,
      501 +                                    sizeof (EI->cap_str));
 488  502                          }
 489  503                  }
 490  504  
 491  505                  /*
 492  506                   * Definition time:
 493  507                   *      - "not stripped" means that an executable file
 494  508                   *      contains a Symbol Table (.symtab)
 495  509                   *      - "stripped" means that an executable file
 496  510                   *      does not contain a Symbol Table.
 497  511                   * When strip -l or strip -x is run, it strips the
↓ open down ↓ 42 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX