[BACK]Return to elf.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ctfconv

Diff for /src/usr.bin/ctfconv/elf.c between version 1.7 and 1.8

version 1.7, 2017/10/27 08:33:46 version 1.8, 2017/11/06 14:59:27
Line 104 
Line 104 
   
 ssize_t  ssize_t
 elf_getsymtab(const char *p, size_t filesize, const char *shstab,  elf_getsymtab(const char *p, size_t filesize, const char *shstab,
     size_t shstabsz, const Elf_Sym **symtab, size_t *nsymb)      size_t shstabsz, const Elf_Sym **symtab, size_t *nsymb, const char **strtab,
       size_t *strtabsz)
 {  {
         Elf_Ehdr        *eh = (Elf_Ehdr *)p;          Elf_Ehdr        *eh = (Elf_Ehdr *)p;
         Elf_Shdr        *sh;          Elf_Shdr        *sh, *symsh;
         size_t           snlen;          size_t           snlen;
         ssize_t          i;          ssize_t          i;
   
         snlen = strlen(ELF_SYMTAB);          snlen = strlen(ELF_SYMTAB);
           symsh = NULL;
   
         for (i = 0; i < eh->e_shnum; i++) {          for (i = 0; i < eh->e_shnum; i++) {
                 sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize);                  sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize);
Line 133 
Line 135 
                                 *symtab = (Elf_Sym *)(p + sh->sh_offset);                                  *symtab = (Elf_Sym *)(p + sh->sh_offset);
                         if (nsymb != NULL)                          if (nsymb != NULL)
                                 *nsymb = (sh->sh_size / sh->sh_entsize);                                  *nsymb = (sh->sh_size / sh->sh_entsize);
                           symsh = sh;
   
                         return i;                          break;
                 }                  }
         }          }
   
         return -1;          if (symsh == NULL || (symsh->sh_link >= eh->e_shnum))
                   return -1;
   
           sh = (Elf_Shdr *)(p + eh->e_shoff + symsh->sh_link * eh->e_shentsize);
   
           if ((sh->sh_offset + sh->sh_size) > filesize)
                   return -1;
   
           if (strtab != NULL)
                   *strtab = p + sh->sh_offset;
           if (strtabsz != NULL)
                   *strtabsz = sh->sh_size;
   
           return i;
 }  }
   
 ssize_t  ssize_t
Line 240 
Line 256 
   
         /* Find symbol table location and number of symbols. */          /* Find symbol table location and number of symbols. */
         symtabidx = elf_getsymtab(p, filesize, shstab, shstabsz, &symtab,          symtabidx = elf_getsymtab(p, filesize, shstab, shstabsz, &symtab,
             &nsymb);              &nsymb, NULL, NULL);
         if (symtabidx == -1) {          if (symtabidx == -1) {
                 warnx("symbol table not found");                  warnx("symbol table not found");
                 return;                  return;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8