Format/typo check 2001/anonymous
README.md file format/typo checked. Updated warnings in Makefile as well. I believe this completes the review of 2001/anonymous.
This commit is contained in:
1 parent
8773666f74
commit
6aae9da0d2
2 files changed
+34
-21
No files matched your search
@@ -145,9 +145,9 @@ ${PROG}: ${PROG}.c
|
||||
|
||||
|
||||
${PROG}.ten: ${PROG}.ten.c
|
||||
@echo "WARNING: ${PROG}.ten.c must be compiled as 32-bit to use with the entry itself;"
|
||||
@echo "this is because the program works on 32-bit binaries. If you cannot use -m32 this"
|
||||
@echo "will NOT work!"
|
||||
@echo "WARNING: ${PROG}.ten.c must be compiled as a 32-bit ELF binary to use with"
|
||||
@echo "the entry itself; this is because the program works on 32-bit ELF binaries."
|
||||
@echo "If you cannot use -m32 this will NOT work!"
|
||||
@echo
|
||||
@echo "If you want to use it where this is not possible e.g. with a Mac, say to"
|
||||
@echo "use by itself, try:"
|
||||
@@ -165,9 +165,9 @@ ${PROG}.ten.64: ${PROG}.ten.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
${PROG}.bed: ${PROG}.bed.c
|
||||
@echo "WARNING: ${PROG}.bed.c must be compiled as 32-bit to use with the entry itself;"
|
||||
@echo "this is because the program works on 32-bit binaries. If you cannot use -m32 this"
|
||||
@echo "will NOT work!"
|
||||
@echo "WARNING: ${PROG}.bed.c must be compiled as a 32-bit ELF binary to use with"
|
||||
@echo "the entry itself; this is because the program works on 32-bit ELF binaries."
|
||||
@echo "If you cannot use -m32 this will NOT work!"
|
||||
@echo
|
||||
@echo "If you want to use it where this is not possible e.g. with a Mac, say to"
|
||||
@echo "use by itself, try:"
|
||||
|
||||
+28
-15
@@ -28,20 +28,21 @@ For more detailed information see [2001 anonymous in bugs.md](/bugs.md#2001-anon
|
||||
```sh
|
||||
./try.sh
|
||||
|
||||
./anonymous anonymous.bed # if able to use -m32
|
||||
./anonymous anonymous.bed # if able to compile as a 32-bit (-m32) ELF binary
|
||||
```
|
||||
|
||||
NOTE: if the 32-bit version cannot be compiled the script will at least compile
|
||||
[anonymous.ten](anonymous.ten.c) as a 64-bit program and run it directly.
|
||||
[anonymous.ten](anonymous.ten.c) as a 64-bit program and run it directly. If it
|
||||
can be compiled but it's not an ELF binary the program is likely to crash.
|
||||
|
||||
For fun and so that there's another program that is a bit different (it uses a `char
|
||||
*[]` array for example) that this program will still work on:
|
||||
|
||||
```sh
|
||||
make anonymous.bed # if able to use -m32
|
||||
make anonymous.bed # if able to compile as 32-bit (-m32) ELF binary
|
||||
./anonymous anonymous.bed
|
||||
|
||||
make anonymous.bed.64 # if unable to use -m32
|
||||
make anonymous.bed.64 # if unable to compile as a 32-bit (-m32) ELF binary
|
||||
./anonymous.bed.64
|
||||
```
|
||||
|
||||
@@ -61,7 +62,7 @@ that :-(
|
||||
If the program cannot be run (for instance under macOS as an ELF file) then
|
||||
the program will fail to execute it and might not even touch it.
|
||||
|
||||
This is supposed to happen. As is written in the
|
||||
These are supposed to happen. As is written in the
|
||||
[The Jargon File](http://catb.org/jargon/html/F/feature.html):
|
||||
|
||||
```
|
||||
@@ -79,6 +80,9 @@ no longer known exactly what is supposed to happen and possibly that the
|
||||
modification might not be entirely correct for that reason though it does appear
|
||||
to be correct.
|
||||
|
||||
It appears that the corruption happens only if the modification fails in the
|
||||
middle of doing so so that might be why it's not yet been observed.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
@@ -93,10 +97,13 @@ run x86 programs on any machine (x86 or otherwise).
|
||||
|
||||
I have included a simple [10 Green
|
||||
Bottles](https://www.bbc.co.uk/teach/school-radio/nursery-rhymes-ten-green-bottles/zncyt39)
|
||||
[program](anonymous.ten.c) (try `make anonymous.ten`), meant to be compiled in 32-bit.
|
||||
[program](anonymous.ten.c) (try `make anonymous.ten`), meant to be compiled as a
|
||||
32-bit ELF binary.
|
||||
|
||||
The program `anonymous.ten`, and its source (dull) are included as data
|
||||
files.
|
||||
|
||||
|
||||
### Warning
|
||||
|
||||
Note that the translator screws around with the binary you run on it and *might*
|
||||
@@ -114,7 +121,7 @@ generates a translation for an entire basic block of subject code. Having
|
||||
translated a block once, the target code generated will be stored for the
|
||||
duration that the program is running, so as a program runs its performance will
|
||||
improve, as it hits cached blocks. This can be clearly observed in the example
|
||||
program, [anonymous.ten](anonymous.ten.c) which must be compiled as a 32-bit
|
||||
program, [anonymous.ten](anonymous.ten.c) which must be compiled as a 32-bit ELF
|
||||
binary.
|
||||
|
||||
### Target Library Linking:
|
||||
@@ -136,8 +143,10 @@ There are various problems raised when attempting to run little
|
||||
[PPC](https://en.wikipedia.org/wiki/PowerPC). These problems are dealt
|
||||
with in a manner that is entirely transparent to the user.
|
||||
|
||||
|
||||
### Configuration:
|
||||
|
||||
|
||||
#### Warnings:
|
||||
|
||||
By default the build script should compile the program with a set of
|
||||
@@ -149,6 +158,7 @@ error, or if the program generates any further error when compiled using
|
||||
your C compiler please remove the `-Dwarning='-Dprocessor'` line and the
|
||||
`$$warning` from the compiler invocation.
|
||||
|
||||
|
||||
### Optimization
|
||||
|
||||
The build script contains a `-O1` switch for the compiler. Increasing
|
||||
@@ -156,6 +166,7 @@ the optimization level will make the program run *slower*, while
|
||||
compiling the program without any optimization will allow it to run
|
||||
*faster*.
|
||||
|
||||
|
||||
### Obfuscation
|
||||
|
||||
The most obvious part of the obfuscation is probably the mess of `#define`s at the
|
||||
@@ -170,7 +181,7 @@ not contained within the source code but instead is passed in on the command
|
||||
line.
|
||||
|
||||
Buried under all this, and the fact that the entire program is just a
|
||||
call to `exit()`, there are some nice subtle little obfuscations. For
|
||||
call to `exit(3)`, there are some nice subtle little obfuscations. For
|
||||
example, you may notice that there are a couple of macros that use the
|
||||
`##` preprocessor operator to build pairs of functions. One of these
|
||||
macros is used to build pairs of functions of which only one has
|
||||
@@ -179,11 +190,12 @@ global state, and the other doesn't.
|
||||
|
||||
There is also quite a nice trick where I wave a magic wand, and a chunk of code
|
||||
which should only be run when the program is run for the first time (setting the
|
||||
[PC / IP](https://en.wikipedia.org/wiki/Program_counter) to point at `main()`,
|
||||
etc) gets turned into a `frog^M^M^M^Mstring`. The C compiler sees a string by
|
||||
[PC / IP](https://en.wikipedia.org/wiki/Program_counter) to point at `main()`
|
||||
etc.) gets turned into a <strike>frog</strike>string. The C compiler sees a string by
|
||||
itself in the code, thinks "yup, that's a valid C expression", and quietly moves
|
||||
on to the next line of code.
|
||||
|
||||
|
||||
### Limitations
|
||||
|
||||
Due to space limitations only a handful of instructions are supported; these
|
||||
@@ -200,19 +212,20 @@ turn up - yes the program is unsafe, but it's pretty cool anyway.
|
||||
Despite all this, the translator is not exclusively limited to running the
|
||||
[anonymous.ten](anonymous.ten.c) program. Other trivial **_x86_** programs may
|
||||
run on the translator \- and I have successfully run a wide range of "Hello
|
||||
World" programs, including one of last years IOCCC winners,
|
||||
World" programs, including one of last year's IOCCC winners,
|
||||
[tomx](/2000/tomx/tomx.c).
|
||||
|
||||
|
||||
### Complete Program
|
||||
|
||||
The fact that the program makes calls to `system()` and `execv()` may imply that
|
||||
The fact that the program makes calls to `system(3)` and `execv(3)` may imply that
|
||||
it is not a complete program in its own right, as it relies on other programs.
|
||||
The call to `system()` is a call to ask gcc to recompile the translator with a
|
||||
new set of switches, and the call to `execv()` asks for the newly compiled
|
||||
The call to `system(3)` is a call to ask gcc to recompile the translator with a
|
||||
new set of switches, and the call to `execv(3)` asks for the newly compiled
|
||||
program to be executed. I would point out that almost every other entry to this
|
||||
competition also require a C compiler (well, the published winners at any rate,
|
||||
and I recognize that a few don't). There is little real difference between this
|
||||
program and one like last years entry [dhyang](/2000/dhyang/dhyang.c); both are
|
||||
program and one like last year's entry [dhyang](/2000/dhyang/dhyang.c); both are
|
||||
just C programs that generate C code as their output.
|
||||
|
||||
Enjoy and thanks!
|
||||
|
||||
Reference in new issue
Block a user