Fix 2001/anonymous - it now works!

This was a fun one to figure out. There were a few steps. Amongst them
was adding the include for mmap(). Another part that might or might not
be relevant was having main() call a new function rather than main()
itself. This seemingly solved an infinite recursion call to main()
(according to gcc).

I changed the third arg in the call to mmap() to be
PROT_READ|PROT_WRITE. This might not have been necessary as it might
evaluate to 3 which is what it was.

I regret that some macros were removed and some formatting was changed.
This was not intentional but I want to get the fix in and then I can fix
the formatting and macros (or try to - some of it might or might not
cause a problem).

Note that it will crash on any binary that's not 32-bit/x86. In other
words this won't work in macOS unless you have an old enough Mac that
supports 32-bit binaries. With gcc (which is clang in macOS so that
won't work either) one can do -m32 and that's what is done for
anonymous.ten. It probably should be built by default but it's currently
not.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-21 08:36:21 -07:00
1 parent 1685f8e2ee
commit efdee208a2
5 files changed
+61 -482

No files matched your search

+2 -10
View File
@@ -70,7 +70,7 @@ CINCLUDE=
# Optimization
#
OPT=
OPT=
# Default flags for ANSI C compilation
#
@@ -117,7 +117,7 @@ PROG= ${ENTRY}
#
OBJ= ${PROG}.o
DATA=
TARGET= ${PROG} cpp
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
@@ -142,14 +142,6 @@ ${PROG}: ${PROG}.c
$$magic $$warning -Dmagic= $$X "-DX=A($$magic \"$$X\")" \
$< -o $@ ${LIBS}
cpp: cpp.c
@echo "NOTE: this entry seems to no longer work."
magic='${CC} ${CFLAGS}'; \
X='-DA(X)=#X'; \
warning='-Dprocessor'; \
$$magic $$warning -Dmagic= $$X "-DX=A($$magic \"$$X\")" \
$< -o $@ ${LIBS}
${PROG}.ten: ${PROG}.ten.c
@echo "NOTE: this program must be compiled as 32-bit to use with the entry itself."