This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12 #include <stdio.h>
13 #include <unistd.h>
14 #include <a.out.h>
15
16 int main(int argc, char *argv[])
17 {
18 int c, n=0, len=0;
19 char tmp_buf[512*1024];
20
21 struct exec obj = {0x00640107};
22 char string_names[] = {"_input_data\0_input_len\0"};
23
24 struct nlist var_names[2] =
25 {
26 {
27 (char *)4, 7, 0, 0, 0
28 },
29 {
30 (char *)16, 7, 0, 0, 0
31 }
32 };
33
34
35 len = 0;
36 while ((n = read(0, &tmp_buf[len], sizeof(tmp_buf)-len+1)) > 0)
37 len += n;
38
39 if (n==-1)
40 {
41 perror("stdin");
42 exit(-1);
43 }
44
45 if (len >= sizeof(tmp_buf))
46 {
47 fprintf(stderr, "%s: Input too large\n", argv[0]);
48 exit(-1);
49 }
50
51 fprintf(stderr, "Compressed size %d.\n", len);
52
53
54
55
56 obj.a_data = len + sizeof(long);
57 obj.a_syms = sizeof(var_names);
58 write(1, (char *)&obj, sizeof(obj));
59
60
61
62
63 write(1, tmp_buf, len);
64 write(1, (char *)&len, sizeof(len));
65
66
67
68
69 var_names[1].n_value = len;
70 write(1, (char *)&var_names, sizeof(var_names));
71
72
73
74
75 len = sizeof(string_names) + sizeof(len);
76 write(1, (char *)&len, sizeof(len));
77 write(1, string_names, sizeof(string_names));
78
79 exit(0);
80
81 }