4004 dis(1) can't deal with extended sections
Reviewed by: Jason King <
[email protected]>
Reviewed by: Josef 'Jeff' Sipek <
[email protected]>
Approved by: Robert Mustacchi <
[email protected]>
--- a/usr/src/cmd/dis/dis_target.c Tue Aug 06 21:29:05 2013 -0400
+++ b/usr/src/cmd/dis/dis_target.c Tue Aug 06 21:49:47 2013 -0400
@@ -446,6 +446,7 @@
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) {
@@ -501,9 +502,16 @@
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) *
- ehdr.e_shnum);
- current->dt_shncount = ehdr.e_shnum;
+ shnum);
+ current->dt_shncount = shnum;
idx = 0;
dis_tgt_section_iter(current, tgt_scn_init, &idx);