Print this page
7029 want per-process exploit mitigation features (secflags)
7030 want basic address space layout randomization (aslr)
7031 noexec_user_stack should be a secflag
7032 want a means to forbid mappings around NULL.

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 ↓ 273 lines elided ↑ open up ↑
 274  274  
 275  275  /*
 276  276   * Print relocation data of type SHT_RELA
 277  277   * If d_flag, print data corresponding only to
 278  278   * the section or range of sections specified.
 279  279   * If n_flag, print data corresponding only to
 280  280   * the named section.
 281  281   */
 282  282  static void
 283  283  print_rela(Elf *elf_file, SCNTAB *p_scns, Elf_Data *rdata, Elf_Data *sym_data,
 284      -        GElf_Ehdr * p_ehdr, size_t reloc_size, size_t sym_size, char *filename,
 285      -        SCNTAB *reloc_symtab)
      284 +    GElf_Ehdr * p_ehdr, size_t reloc_size, size_t sym_size, char *filename,
      285 +    SCNTAB *reloc_symtab)
 286  286  {
 287  287          GElf_Rela rela;
 288  288          GElf_Sym sym;
 289  289          size_t no_entries;
 290  290          size_t rel_entsize;
 291  291          size_t no_syms;
 292  292          int type, symid;
 293  293          static int n_title = 0;
 294  294          int ndx = 0;
 295  295          char *sym_name;
↓ open down ↓ 83 lines elided ↑ open up ↑
 379  379  
 380  380  /*
 381  381   * Print relocation data of type SHT_REL.
 382  382   * If d_flag, print data corresponding only to
 383  383   * the section or range of sections specified.
 384  384   * If n_flag, print data corresponding only to
 385  385   * the named section.
 386  386   */
 387  387  static void
 388  388  print_rel(Elf *elf_file, SCNTAB *p_scns, Elf_Data *rdata, Elf_Data *sym_data,
 389      -        GElf_Ehdr *p_ehdr, size_t reloc_size, size_t sym_size, char *filename,
 390      -        SCNTAB *reloc_symtab)
      389 +    GElf_Ehdr *p_ehdr, size_t reloc_size, size_t sym_size, char *filename,
      390 +    SCNTAB *reloc_symtab)
 391  391  {
 392  392          GElf_Rel rel;
 393  393          GElf_Sym sym;
 394  394          size_t no_entries;
 395  395          size_t rel_entsize;
 396  396          int type, symid;
 397  397          size_t no_syms;
 398  398          static int n_title = 0;
 399  399          int ndx = 0;
 400  400          char *sym_name;
↓ open down ↓ 105 lines elided ↑ open up ↑
 506  506   * Print the symbol table.  Input is an ELF file descriptor, a
 507  507   * pointer to the symbol table SCNTAB structure,
 508  508   * the number of symbols, a range of symbols to print,
 509  509   * an index which is the number of the
 510  510   * section in the file, and the filename.  The number of sections,
 511  511   * the range, and the index are set in
 512  512   * dump_symbol_table, depending on whether -n or -T were set.
 513  513   */
 514  514  static void
 515  515  print_symtab(Elf *elf_file, SCNTAB *p_symtab, Elf_Data *sym_data,
 516      -        long range, int index)
      516 +    long range, int index)
 517  517  {
 518  518          GElf_Sym sym;
 519  519          int adj = 0;            /* field adjustment for elf64 */
 520  520          Elf32_Word      *symshndx = 0;
 521  521          unsigned int    nosymshndx = 0;
 522  522          Conv_inv_buf_t  inv_buf;
 523  523  
 524  524  
 525  525          if (gelf_getclass(elf_file) == ELFCLASS64)
 526  526                  adj = 8;
↓ open down ↓ 225 lines elided ↑ open up ↑
 752  752   * the SCNTAB structure, the number of sections, and a filename.
 753  753   * Set up necessary information to print relocation information
 754  754   * and call the appropriate print function depending on the
 755  755   * type of relocation information.  If the symbol table is
 756  756   * absent, no relocation data is processed.  Input is an
 757  757   * ELF file descriptor, the ELF header, the SCNTAB structure,
 758  758   * and the filename.  Set range of d_flag and name if n_flag.
 759  759   */
 760  760  static void
 761  761  dump_reloc_table(Elf *elf_file, GElf_Ehdr *p_ehdr,
 762      -        SCNTAB *p_scns, int num_scns, char *filename)
      762 +    SCNTAB *p_scns, int num_scns, char *filename)
 763  763  {
 764  764          Elf_Data *rel_data;
 765  765          Elf_Data *sym_data;
 766  766          size_t    sym_size;
 767  767          size_t    reloc_size;
 768  768          SCNTAB *reloc_symtab;
 769  769          SCNTAB *head_scns;
 770  770          int r_title = 0;
 771  771          int adj = 0;
 772  772          size_t shnum;
↓ open down ↓ 445 lines elided ↑ open up ↑
1218 1218                          case DT_SYMINENT:
1219 1219                          case DT_VERNEEDNUM:
1220 1220                          case DT_SPARC_REGISTER:
1221 1221                          case DT_SUNW_SYMSZ:
1222 1222                          case DT_SUNW_SORTENT:
1223 1223                          case DT_SUNW_SYMSORTSZ:
1224 1224                          case DT_SUNW_TLSSORTSZ:
1225 1225                          case DT_SUNW_STRPAD:
1226 1226                          case DT_SUNW_CAPCHAINENT:
1227 1227                          case DT_SUNW_CAPCHAINSZ:
     1228 +                        case DT_SUNW_ASLR:
1228 1229                                  (void) printf(pdyn_Fmtptr,
1229 1230                                      EC_XWORD(p_dyn.d_un.d_val));
1230 1231                                  break;
1231 1232  
1232 1233                          /*
1233 1234                           * Integer items that are bitmasks, or which
1234 1235                           * can be otherwise formatted in symbolic form.
1235 1236                           */
1236 1237                          case DT_FLAGS:
1237 1238                          case DT_FEATURE_1:
↓ open down ↓ 219 lines elided ↑ open up ↑
1457 1458   * the ELF header, the SCNTAB structure,
1458 1459   * the number of symbols, and the filename.
1459 1460   * The number of sections,
1460 1461   * and the offset into the SCNTAB structure will be
1461 1462   * set in dump_section if d_flag or n_flag are set.
1462 1463   * If v_flag is set, sections which can be interpreted will
1463 1464   * be interpreted, otherwise raw data will be output in hexidecimal.
1464 1465   */
1465 1466  static void
1466 1467  print_section(Elf *elf_file,
1467      -        GElf_Ehdr *p_ehdr, SCNTAB *p, int num_scns, char *filename)
     1468 +    GElf_Ehdr *p_ehdr, SCNTAB *p, int num_scns, char *filename)
1468 1469  {
1469 1470          unsigned char    *p_sec;
1470 1471          int     i;
1471 1472          size_t  size;
1472 1473  
1473 1474          for (i = 0; i < num_scns; i++, p++) {
1474 1475                  GElf_Shdr shdr;
1475 1476  
1476 1477                  size = 0;
1477 1478                  if (s_flag && !v_flag)
↓ open down ↓ 46 lines elided ↑ open up ↑
1524 1525   * of the sections but sets up the parameters and then calls
1525 1526   * print_section to print the contents.  Calling another function to print
1526 1527   * the contents allows both -d and -n to work correctly
1527 1528   * simultaneously. Input is an ELF file descriptor, the ELF header,
1528 1529   * the SCNTAB structure, the number of sections, and the filename.
1529 1530   * Set the range of sections if d_flag, and set section name if
1530 1531   * n_flag.
1531 1532   */
1532 1533  static void
1533 1534  dump_section(Elf *elf_file,
1534      -        GElf_Ehdr *p_ehdr, SCNTAB *s, int num_scns, char *filename)
     1535 +    GElf_Ehdr *p_ehdr, SCNTAB *s, int num_scns, char *filename)
1535 1536  {
1536 1537          SCNTAB *n_range, *d_range; /* for use with -n and -d modifiers */
1537 1538          int i;
1538 1539          int found_it = 0;  /* for use with -n section_name */
1539 1540  
1540 1541          if (n_flag) {
1541 1542                  n_range = s;
1542 1543  
1543 1544                  for (i = 0; i < num_scns; i++, n_range++) {
1544 1545                          if ((strcmp(name, n_range->scn_name)) != 0)
↓ open down ↓ 188 lines elided ↑ open up ↑
1733 1734                      num_scns, filename);
1734 1735          }
1735 1736  }
1736 1737  
1737 1738  /*
1738 1739   * Load the archive string table(s) (for extended-length strings)
1739 1740   * into an in-core table/list
1740 1741   */
1741 1742  static struct stab_list_s *
1742 1743  load_arstring_table(struct stab_list_s *STabList,
1743      -        int fd, Elf *elf_file, Elf_Arhdr *p_ar, char *filename)
     1744 +    int fd, Elf *elf_file, Elf_Arhdr *p_ar, char *filename)
1744 1745  {
1745 1746          off_t here;
1746 1747          struct stab_list_s *STL_entry, *STL_next;
1747 1748  
1748 1749          if (p_ar) {
1749 1750                  STL_entry = malloc(sizeof (struct stab_list_s));
1750 1751                  STL_entry->next    = 0;
1751 1752                  STL_entry->strings = 0;
1752 1753                  STL_entry->size    = 0;
1753 1754  
↓ open down ↓ 377 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX