File: stripsh.c

package info (click to toggle)
euslisp 9.31%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,448 kB
  • sloc: ansic: 41,610; lisp: 3,339; makefile: 286; sh: 238; asm: 138; python: 53
file content (40 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/****************************************************************/
/* stripsh.c
/*	strip off section headers from a.out
/*
/*	(c) T.Matsui, 1986
/****************************************************************/

#include <signal.h>
#include <ctype.h>
#include <sys/file.h>
#include <fcntl.h>
#include <unistd.h>
#include <libelf.h>

#define min(a,b) (a<b)?a:b

main(argc,argv)
int argc;
char *argv[];
{ int infd, outfd;
  int count, size, sh_off;
  int zero=0;
  char buf[8192];

  infd=open(argv[1], O_RDONLY);
  outfd=open(argv[2], O_WRONLY | O_CREAT,0755);
  read(infd, buf, 0x20);
  write(outfd,buf,0x20);
  read(infd, &count, 4);
  write(outfd, &zero, 4);
  count=count-0x24;
  printf("%x\n", count);
  while (count>0) {
    size=read(infd,buf,min(8192,count));
    count-=size;
    write(outfd, buf, size);}
  close(infd); close(outfd);
  }