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

Diff for /src/usr.bin/strip/Attic/strip.c between version 1.16 and 1.17

version 1.16, 2002/02/16 21:27:53 version 1.17, 2002/08/21 15:51:08
Line 69 
Line 69 
   
 #define strx    n_un.n_strx  #define strx    n_un.n_strx
   
 int s_stab(const char *, int, EXEC *, struct stat *);  int s_stab(const char *, int, EXEC *, struct stat *, off_t *);
 int s_sym(const char *, int, EXEC *, struct stat *);  int s_sym(const char *, int, EXEC *, struct stat *, off_t *);
 void usage(void);  void usage(void);
   
 int xflag = 0;  int xflag = 0;
Line 83 
Line 83 
         int fd;          int fd;
         EXEC *ep;          EXEC *ep;
         struct stat sb;          struct stat sb;
         int (*sfcn)(const char *, int, EXEC *, struct stat *);          int (*sfcn)(const char *, int, EXEC *, struct stat *, off_t *);
         int ch, errors;          int ch, errors;
         char *fn;          char *fn;
           off_t newsize;
   
         sfcn = s_sym;          sfcn = s_sym;
         while ((ch = getopt(argc, argv, "dx")) != -1)          while ((ch = getopt(argc, argv, "dx")) != -1)
Line 131 
Line 132 
                    for dealing with data in memory, and a second time for out                     for dealing with data in memory, and a second time for out
                  */                   */
                 fix_header_order(ep);                  fix_header_order(ep);
                 errors |= sfcn(fn, fd, ep, &sb);                  newsize = 0;
                   errors |= sfcn(fn, fd, ep, &sb, &newsize);
                 fix_header_order(ep);                  fix_header_order(ep);
                 munmap((caddr_t)ep, sb.st_size);                  munmap((caddr_t)ep, sb.st_size);
                   if (newsize  && ftruncate(fd, newsize)) {
                           warn("%s", fn);
                           errors = 1;
                   }
                 if (close(fd)) {                  if (close(fd)) {
                         ERROR(errno);                          ERROR(errno);
                 }                  }
Line 143 
Line 149 
 }  }
   
 int  int
 s_sym(fn, fd, ep, sp)  s_sym(fn, fd, ep, sp, sz)
         const char *fn;          const char *fn;
         int fd;          int fd;
         EXEC *ep;          EXEC *ep;
         struct stat *sp;          struct stat *sp;
           off_t *sz;
 {  {
         char *neweof;          char *neweof;
 #if     0  #if     0
Line 203 
Line 210 
         ep->a_syms = ep->a_trsize = ep->a_drsize = 0;          ep->a_syms = ep->a_trsize = ep->a_drsize = 0;
   
         /* Truncate the file. */          /* Truncate the file. */
         if (ftruncate(fd, neweof - (char *)ep)) {          *sz = neweof - (char *)ep;
                 warn("%s", fn);  
                 return 1;  
         }  
   
         return 0;          return 0;
 }  }
   
 int  int
 s_stab(fn, fd, ep, sp)  s_stab(fn, fd, ep, sp, sz)
         const char *fn;          const char *fn;
         int fd;          int fd;
         EXEC *ep;          EXEC *ep;
         struct stat *sp;          struct stat *sp;
           off_t *sz;
 {  {
         int cnt, len;          int cnt, len;
         char *nstr, *nstrbase, *p, *strbase;          char *nstr, *nstrbase, *p, *strbase;
Line 276 
Line 281 
                                 continue;                                  continue;
                         }                          }
                         len = strlen(p) + 1;                          len = strlen(p) + 1;
                           if (N_STROFF(*ep) + sym->strx + len > sp->st_size) {
                                   warnx("%s: bad symbol table", fn);
                                   return 1;
                           }
                         bcopy(p, nstr, len);                          bcopy(p, nstr, len);
                         nstr += len;                          nstr += len;
                         fix_nlist_order(nsym++, mid);                          fix_nlist_order(nsym++, mid);
Line 297 
Line 306 
         free(nstrbase);          free(nstrbase);
   
         /* Truncate to the current length. */          /* Truncate to the current length. */
         if (ftruncate(fd, (char *)nsym + len - (char *)ep)) {          *sz = (char *)nsym + len - (char *)ep;
                 warn("%s", fn);  
                 return 1;  
         }  
   
         return 0;          return 0;
 }  }

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17