Print this page
4004 dis(1) can't deal with extended sections

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/dis/dis_target.c
          +++ new/usr/src/cmd/dis/dis_target.c
↓ open down ↓ 438 lines elided ↑ open up ↑
 439  439          if ((tgt->dt_elf_root =
 440  440              elf_begin(tgt->dt_fd, ELF_C_READ, NULL)) == NULL) {
 441  441                  warn("%s: invalid or corrupt ELF file", file);
 442  442                  dis_tgt_destroy(tgt);
 443  443                  return (NULL);
 444  444          }
 445  445  
 446  446          current = tgt;
 447  447          cmd = ELF_C_READ;
 448  448          while ((elf = elf_begin(tgt->dt_fd, cmd, tgt->dt_elf_root)) != NULL) {
      449 +                size_t shnum = 0;
 449  450  
 450  451                  if (elf_kind(tgt->dt_elf_root) == ELF_K_AR &&
 451  452                      (arhdr = elf_getarhdr(elf)) == NULL) {
 452  453                          warn("%s: malformed archive", file);
 453  454                          dis_tgt_destroy(tgt);
 454  455                          return (NULL);
 455  456                  }
 456  457  
 457  458                  /*
 458  459                   * Make sure that this Elf file is sane
↓ open down ↓ 35 lines elided ↑ open up ↑
 494  495                  current->dt_elf = elf;
 495  496                  current->dt_arhdr = arhdr;
 496  497  
 497  498                  if (elf_getshdrstrndx(elf, &current->dt_shstrndx) == -1) {
 498  499                          warn("%s: failed to get section string table for "
 499  500                              "file", file);
 500  501                          dis_tgt_destroy(tgt);
 501  502                          return (NULL);
 502  503                  }
 503  504  
      505 +                if (elf_getshdrnum(elf, &shnum) == -1) {
      506 +                        warn("%s: failed to get number of sections in file",
      507 +                            file);
      508 +                        dis_tgt_destroy(tgt);
      509 +                        return (NULL);
      510 +                }
      511 +
 504  512                  current->dt_shnmap = safe_malloc(sizeof (dis_shnmap_t) *
 505      -                    ehdr.e_shnum);
 506      -                current->dt_shncount = ehdr.e_shnum;
      513 +                    shnum);
      514 +                current->dt_shncount = shnum;
 507  515  
 508  516                  idx = 0;
 509  517                  dis_tgt_section_iter(current, tgt_scn_init, &idx);
 510  518                  current->dt_filename = file;
 511  519  
 512  520                  create_addrmap(current);
 513  521                  if (current->dt_symidx != 0)
 514  522                          construct_symtab(current);
 515  523  
 516  524                  cmd = elf_next(elf);
↓ open down ↓ 444 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX