3 # 'False True' -- An Example of How Not To Write Code
5 # (c) 1998 Martin Mares <mj@ucw.cz>, GPL'ed
7 # This is an attempt to write a shortest possible program which is still
8 # useful. I decided to make a replacement for `true' (anyway, `false' would
9 # fit in the same space as well). It is _NOT_ a correct ELF program (the
10 # headers are a bit messy and we have non-zero values in reserved fields
11 # and certain mandatory parts are missing), but `file' still recognizes
12 # it as ELF (although `objdump' doesn't) and, which is much more important,
13 # Linux kernel still runs it. Share and enjoy...
16 open X, ">true" or die "No write access, no truth";
18 s/#.*$//; s/\b(\w{4})(\w{4})\b/$2 $1/g; s/\b(\w\w)(\w\w)\b/$2 $1/g;
19 foreach $a (split /\s+/) { print X pack("c",hex $a); }
20 } chmod 0755, "true" or die "Executables aren't";
24 7f 45 4c 46 # Identification
28 # Next 9 bytes are ELF header padding and RFU, but we dare to put
30 31 c0 # xor eax,eax (offset 9)
34 4d 4a # Author's Signature :-)
35 0002 # Type: Executable File
37 00000001 # Version: Current :)
38 10000007 # Entry point
41 00000000 # Machine-specific flags
43 0020 # Size of single PH entry
44 0001 # Number of PH entries
45 0000 # Size of single SH entry
46 0000 # Number of SH entries
47 0000 # String table offset
49 # Offset 2C: Program Header
51 # These two entries are overlaid with the ELF header
52 #00000001 # Type: Loadable
53 #00000000 # Offset of section start
54 10000000 # Virtual address
55 10000000 # Physical address: ignored
56 0000004c # File image size
57 0000004c # Memory image size
59 # Linux doesn't use alignment, so we can omit it. The kernel will try
60 # to read the full header size and get 4 bytes less, but it won't
61 # complain and it will use whatever was left in the memory. Ugly.
62 #00001000 # Align to page size