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

*** 444,453 **** --- 444,454 ---- } current = tgt; cmd = ELF_C_READ; while ((elf = elf_begin(tgt->dt_fd, cmd, tgt->dt_elf_root)) != NULL) { + size_t shnum = 0; if (elf_kind(tgt->dt_elf_root) == ELF_K_AR && (arhdr = elf_getarhdr(elf)) == NULL) { warn("%s: malformed archive", file); dis_tgt_destroy(tgt);
*** 499,511 **** "file", file); dis_tgt_destroy(tgt); return (NULL); } current->dt_shnmap = safe_malloc(sizeof (dis_shnmap_t) * ! ehdr.e_shnum); ! current->dt_shncount = ehdr.e_shnum; idx = 0; dis_tgt_section_iter(current, tgt_scn_init, &idx); current->dt_filename = file; --- 500,519 ---- "file", file); dis_tgt_destroy(tgt); return (NULL); } + if (elf_getshdrnum(elf, &shnum) == -1) { + warn("%s: failed to get number of sections in file", + file); + dis_tgt_destroy(tgt); + return (NULL); + } + current->dt_shnmap = safe_malloc(sizeof (dis_shnmap_t) * ! shnum); ! current->dt_shncount = shnum; idx = 0; dis_tgt_section_iter(current, tgt_scn_init, &idx); current->dt_filename = file;