coff32strip.c (724B)
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #include <scc/mach.h> 5 6 #include "../libmach.h" 7 #include "coff32.h" 8 9 int 10 coff32strip(Obj *obj) 11 { 12 int i; 13 SCNHDR *scn; 14 struct coff32 *coff = obj->data; 15 FILHDR *hdr = &coff->hdr; 16 17 for (i = 0; i < hdr->f_nscns; i++) { 18 scn = &coff->scns[i]; 19 scn->s_nrelloc = 0; 20 scn->s_relptr = 0; 21 scn->s_nlnno = 0; 22 scn->s_lnnoptr = 0; 23 } 24 25 hdr->f_nsyms = 0; 26 hdr->f_symptr = 0; 27 hdr->f_flags |= F_RELFLG | F_LMNO | F_LSYMS; 28 29 for (i = 0; i < coff->hdr.f_nscns; i++) { 30 if (coff->rels) 31 free(coff->rels[i]); 32 if (coff->lines) 33 free(coff->lines[i]); 34 } 35 36 free(coff->ents); 37 free(coff->rels); 38 free(coff->lines); 39 40 coff->ents = NULL; 41 coff->rels = NULL; 42 coff->lines = NULL; 43 44 return 0; 45 }