stripsh.c
Go to the documentation of this file.
00001 /****************************************************************/
00002 /* stripsh.c
00003 /*      strip off section headers from a.out
00004 /*
00005 /*      (c) T.Matsui, 1986
00006 /****************************************************************/
00007 
00008 #include <signal.h>
00009 #include <ctype.h>
00010 #include <sys/file.h>
00011 #include <fcntl.h>
00012 #include <unistd.h>
00013 #include <libelf.h>
00014 
00015 #define min(a,b) (a<b)?a:b
00016 
00017 main(argc,argv)
00018 int argc;
00019 char *argv[];
00020 { int infd, outfd;
00021   int count, size, sh_off;
00022   int zero=0;
00023   char buf[8192];
00024 
00025   infd=open(argv[1], O_RDONLY);
00026   outfd=open(argv[2], O_WRONLY | O_CREAT,0755);
00027   read(infd, buf, 0x20);
00028   write(outfd,buf,0x20);
00029   read(infd, &count, 4);
00030   write(outfd, &zero, 4);
00031   count=count-0x24;
00032   printf("%x\n", count);
00033   while (count>0) {
00034     size=read(infd,buf,min(8192,count));
00035     count-=size;
00036     write(outfd, buf, size);}
00037   close(infd); close(outfd);
00038   }
00039 
00040 


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Sep 3 2015 10:36:20