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."
+19 -15
View File
@@ -12,25 +12,29 @@ make
## To run:
```sh
./anonymous program
./anonymous x86_program
```
NOTE: [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the
supplementary program which is necessary to test the program. He C pre-processed
and cleaned it up as well as commented it some as it heavily uses the ternary
operator and recursive calls. It is not consistent but if you look at it you
should understand why that is! Thank you Cody for your assistance! He notes
however that this entry seems to no longer work and has offered some tips in the
[bugs.md](/bugs.md) file for anyone who mights want to try and fix this but it
does seem to require a lot of parsing, debugging, an x86 system and possibly
knowing the internals of the ELF format (x86 specific if there are any?). You
need to run the program on a binary to test. See the try section below for the
above mentioned program that you can test the entry on. Thank you and we will
happily credit you if you fix this.
NOTE: [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed both the
supplementary program and the program itself, both of which segfaulted. He
managed to do this with linux but it will not work with macOS (see below why);
this is not a bug but a feature inherent in what it does. He said this took
serious debugging and skill (shameless self promotion but it's true :-) ) and we
thank him _very much_!
WARNING: if you do get this to work **IT WILL _DESTROY FILES__ that it is used
on!** See the author's warning on this.
Why does this not work on macOS? Because Apple has made it very hard to compile
32-bit programs. It's even harder with the Apple silicon chip. Thus this will
have to remain for linux only. BSD was not tested.
WARNING: this will somewhat destroy files that it is used on. See the author's
warning about this.
### INABIAF - it's not a bug it's a feature! :-)
This entry will not work on 64-bit binaries! The program itself can be compiled
as 64-bit but the files it processes must be 32-bit binaries. Not doing this
will likely cause a crash or cause your computer [halt and catch
fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)! :-)
## Try:
+40 -25
View File
@@ -1,41 +1,56 @@
#define processor x86
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/mman.h>
#define l int*
#define F char
struct stat t;
struct stat t;
#define c return
#define I (P+=4,*L(P-4,0))
#define G (signed F)E(*L(P++,0))
#define C(O,D)E (D[B+V(010)/4+O*10])
#define C(O,D) E (D[B+V(010)/4+O*10])
#define U R[4]=E(V(17)-4),*(l)V(021)=
F M [99],Q[99],b[9999],*ss,*d=b,*z;
char M [99],Q[99],b[15000],*ss,*d=b, *z;
#define O =(n=*(l)V(021),R[4]=E(V(17)+4),n)
#define p(a,b,c) system((sprintf(a,b,k[1]),c)),z
#define g (y/010&7)
#define R (B+13)
#define x86 (F*)index\
(ss+V(i ),0100)
#define D(y,n,a,m,i,c )d+=sprintf( d,y,n,a,m,i,c ),(F*\
) P
l B,i,n,a,r,y ,
P ;
#define Tr(an,sl,at,or) l an##i(d,sl){ c at? an##i(d,r):or; } \
l an(d, sl){ c \
r=V(014 )&63,an##i(d,sl); }
#define add(Ev,Gv) Ev(){ i=((a-=16)+C(r,4))/4,(\
Gv?Ev() :0) ; } Ev##n(){ a=C(r,5),Ev(); }
Tr(L,r, C(r,3)&&C(r,3)<=d?(l)(((int)B)+d+C(r,4)-C(r,3)):(((int)B)^d)>>24&&--\
r,(l)d) Tr(Run,a,(ss=strcmp((F*)B+C((V(12)>>16),4)+C(--r,0),A(.strtab))?ss:(F\
*)B+C(r ,4),C(r,1)-2),0) add(Sca ,V(-~i)-P+2) add(ru,strcmp(ss+V(i),A(main)))
E(DX) { c *z? DX:DX <<030|(DX&65280)<<010|DX>>8&65280|DX>>24&0377; } l K(k){
c L(E(k [(l)V(17)]),0); } V(v){ c E(B[v]); }
#define g (y/010&7)
#define R (B+13)
#define x86 (F*)index(ss+V(i ),0100)
#define D(y,n,a,m,i,c) d+=sprintf( d,y,n,a,m,i,c ),(F* ) P
int *B, i,n,a,r,y ,
P ;
int* Li(d,r){ return E (3[B+V(010)/4+r*10])&&E (3[B+V(010)/4+r*10])<=d?(int*)(((int)B)+d+E (4[B+V(010)/4+r*10])-E (3[B+V(010)/4+r*10])):(((int)B)^d)>>24&&--r? Li(d,r):(int*)d; } int* L(d, r){ return r=V(014 )&63,Li(d,r); }
int* Runi(d,a){ return (ss=strcmp((char*)B+E (4[B+V(010)/4+(V(12)>>16)*10])+E (0[B+V(010)/4+--r*10]),".strtab")?ss:(char*)B+E (4[B+V(010)/4+r*10]),E (1[B+V(010)/4+r*10])-2)? Runi(d,r):0; } int* Run(d, a){ return r=V(014 )&63,Runi(d,a); }
Sca(){ i=((a-=16)+E (4[B+V(010)/4+r*10]))/4,(V(-~i)-P+2?Sca() :0) ; } Scan(){ a=E (5[B+V(010)/4+r*10]),Sca(); } ru(){ i=((a-=16)+E (4[B+V(010)/4+r*10]))/4,(strcmp(ss+V(i),"main")?ru() :0) ; } run(){ a=E (5[B+V(010)/4+r*10]),ru(); }
E(DX)
{
return *z?
DX : DX <<030 |
(DX&65280)<<010 |
DX>>8 & 65280 |
DX>>24&0377;
}
int* K(k){
return L(E(k [(int*)V(17)]),0); }
V(v){
return E (B[v]);
}
int
main (int cka, char **k) { char *ck = (char *)cka;
exit(E((ck?main((z?(stat(M,&t)?P+=a+'{'?0:3:execv(M,k),a=G,i=P,y=G&255,sprintf(Q,y/'@'-3?A(*L(V(%d+%d)+%d,0)):A(R[%d]),(y&7),'\r',y/0100-1?0:G),(a+127&&a+'}'&&a+1?(a+61&&a+24&&a+025?(P=a+'H'&&a%061<=0?P:i,D(a>0?" R[%d]=E(~-E(R[%d])),\0 U R[%d],\0 R[%d] O,\0 U %d,\0R[%d]=0,"+(a&'8')*3:a <- 'c'?" %d, %c%s = R[%d], \0 %d, *R=%c%s==R[%d], \0 R[%d]=(int)%c%s,"-a%'w'%'j'*5:"%d,%d,%s=%d,",a>0?a-'h'?a-49?a&7:g:I:g,a>0?a&7:"& "[a%3%2+1],a+72?Q:A(*R),a>0|a<-99?g:I,0)):(P=i,i=a+61?a+21?E(I):G:0,D(a%' '+29+"P O,\0 U %d,P=%d,",P,P+i,0,0,0),p(d,"A'",b))):(n=g-4?g%5-1?a+127?G:I:0:(Scan(),*( x86?processor :d)=0,(int)(ss+V(i))),g%5<2?D(g%5?" %s=E(~-E(%s)), \0 U %s,"+4*g:"%s=E(E(%s)%c%d),",Q,Q,"+ - "[g],n,0):(a=G-'u'?'!':'=',D(g-4?"P=%d%c=%s?%d:%d,":"*R=E(((int(*)(l,l,l))%s)(K(1),K(2),K(3))),P O,",n,a,Q,P,P+G),p(d,"A'",b))))):(Run((z=(F*)&ck,stat(k[1],&t),B=(l)mmap(0,i=t.st_size,3,1,open(k[1],2),0))),magic((R[4]=E(B+i/4),run(),P=V(-~i),U 0)),sprintf(M,A(.%s%d),k[1],P),D("%s %s '-DX=A(%s)' -o %s '-Dmagic=",X,__FILE__,X,M,fflush(0)))),k):p(M,A(rm -f .%s*),M),*R)));
pain(char *ck, char **k)
{
return (z?(stat(M,&t)?P+=a+'{'?0:3:execv(M,k),a=(signed char)E(*L(P++,0)),i=P,y=(signed char)E(*L(P++,0))&255,sprintf(Q,y/'@'-3?"*L(V(%d+%d)+%d,0)":"R[%d]",(y&7),'\r',y/0100-1?0:(signed char)E(*L(P++,0))),(a+127&&a+'}'&&a+1?(a+61&&a+24&&a+025?(P=a+'H'&&a%061<=0?P:i,d+=sprintf( d,a>0?" R[%d]=E(~-E(R[%d])),\0 U R[%d],\0 R[%d] O,\0 U %d,\0R[%d]=0,"+(a&'8')*3:a <- 'c'?" %d, %c%s = R[%d], \0 %d, *R=%c%s==R[%d], \0 R[%d]=(int)%c%s,"-a%'w'%'j'*5:"%d,%d,%s=%d,",a>0?a-'h'?a-49?a&7:(y/010&7):(P+=4,*L(P-4,0)):(y/010&7),a>0?a&7:"& "[a%3%2+1],a+72?Q:"*R",a>0|a<-99?(y/010&7):(P+=4,*L(P-4,0)),0 ),(char* ) P):(P=i,i=a+61?a+21?E((P+=4,*L(P-4,0))):(signed char)E(*L(P++,0)):0,d+=sprintf( d,a%' '+29+"P O,\0 U %d,P=%d,",P,P+i,0,0,0 ),(char* ) P,system((sprintf(d,"A'",k[1]),b)),z)):(n=(y/010&7)-4?(y/010&7)%5-1?a+127?(signed char)E(*L(P++,0)):(P+=4,*L(P-4,0)):0:(Scan(),*( (char*)index(ss+V(i ),0100)?(char*)index(ss+V(i ),0100) :d)=0,(int)(ss+V(i))),(y/010&7)%5<2?d+=sprintf( d,(y/010&7)%5?" %s=E(~-E(%s)), \0 U %s,"+4*(y/010&7):"%s=E(E(%s)%c%d),",Q,Q,"+ - "[(y/010&7)],n,0 ),(char* ) P:(a=(signed char)E(*L(P++,0))-'u'?'!':'=',d+=sprintf( d,(y/010&7)-4?"P=%d%c=%s?%d:%d,":"*R=E(((int(*)(l,l,l))%s)(K(1),K(2),K(3))),P O,",n,a,Q,P,P+(signed char)E(*L(P++,0)) ),(char* ) P,system((sprintf(d,"A'",k[1]),b)),z)))):(Run((z=(char*)&ck,stat(k[1],&t),B=(l)mmap(0,i=t.st_size,PROT_READ|PROT_WRITE,1,open(k[1],2),0))),(((B+13)[4]=E(B+i/4),run(),P=V(-~i),(B+13)[4]=E(V(17)-4),*(int*)V(021))),sprintf(M,".%s%d",k[1],P),d+=sprintf( d,"%s %s '-DX=A(%s)' -o %s '-Dmagic=","cpp -std=gnu99 -Wall -Wextra -pedantic -Winfinite-recursion -Wno-bitwise-conditional-parentheses -Wno-error -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-to-pointer-cast -Wno-macro-redefined -Wno-pedantic -Wno-pointer-to-int-cast -Wno-return-type -Wno-string-plus-int -Wno-bitwise-op-parentheses -Wno-format -Wno-format-extra-args -Wno-int-conversion -Wno-unused-parameter -Wno-unsequenced -E \"-DA(X)=#X\"","anonymous.c","cpp -std=gnu99 -Wall -Wextra -pedantic -Winfinite-recursion -Wno-bitwise-conditional-parentheses -Wno-error -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-to-pointer-cast -Wno-macro-redefined -Wno-pedantic -Wno-pointer-to-int-cast -Wno-return-type -Wno-string-plus-int -Wno-bitwise-op-parentheses -Wno-format -Wno-format-extra-args -Wno-int-conversion -Wno-unused-parameter -Wno-unsequenced -E \"-DA(X)=#X\"",M,fflush(0) ),(char* ) P));
}
int
main (int cka, char **k) { char *ck = (char *)cka;
exit(E((ck?pain((char*)cka,k):system((sprintf(M,"rm -f .%s*",k[1]),M)),z,*(B+13))));
}
-346
View File
@@ -1,346 +0,0 @@
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <strings.h>
#define l int*
#define F char
struct stat t;
#define c return
#define I (P+=4,*L(P-4,0))
#define G (signed F)E(*L(P++,0))
#define C(O,D) E (D[B+V(010)/4+O*10])
#define U R[4]=E(V(17)-4),*(l)V(021)=
char M [99],Q[99],b[15000],*ss,*d=b, *z;
#define O =(n=*(l)V(021),R[4]=E(V(17)+4),n)
#define p(a,b,c) system((sprintf(a,b,k[1]),c)),z
#define g (y/010&7)
#define R (B+13)
#define x86 (F*)index(ss+V(i ),0100)
#define D(y,n,a,m,i,c) d += \
sprintf(d, \
y,n,a,m,i,c ), \
(F* ) P
int* B,i,n,a,r,y,P ;
V(v){
return E(B[v]) /* end E() */;
}
int *Li(d,r)
{
return E (3[B+
V(010) /* end V() */
/4+r*10]
) &&
E (3 [B+
V(010) /* end V() in E() */
/4+r*10]) /* end E() */
<=d ?
(int*)(((int)B) + d +
E(4[B+
V (010) /* end V() in E() */
/4+r*10]) /* end E() */ -
E (3[B +
V(010) /* end V() in E() */
/4+r*10]) /* end E() */
) :
(((int)B)^d)>>24&&--r?
Li(d,r) /* end Li() */:
(int*)d;
}
int *L(d, r){
return r =
V(014 ) /* end V() */&
63,
Li(d,r) /* end Li() */
;
}
int *Runi(d,a)
{
return (ss = strcmp((char*)B+
E (4[B+
V(010)/* end V() *//4+
(V(12) /* end V() */
>>16)*10])+
E(0[B+
V(010) /* end V() */
/4+--r*10]), /* end E() */
".strtab") /* end strcmp() */ ?
ss:(char*)B+
E (4[B+
V(010) /* end V() in E() */
/4+r*10]) /* end E() */ ,
E (1[B+
V(010) /* end V() in E() */
/4+r*10]) /* end E() */ -
2) ?
Runi(d,r) :
0;
}
int *Run(d, a)
{
return r=
V(014 ) /* end V() */
&63,
Runi(d,a);
}
Sca()
{
i=((a-=16)+
E (4[B +
V (010) /* end V() in E() */
/4+r*10]) /* end E() */
)/4,
(V(-~i) /* end V() */
-P+2 ?
Sca() :
0
);
}
Scan()
{
a=
E(5[B+
V(010) /* end V() */
/4+r*10]) /* end E() */
, Sca();
}
ru()
{
i=((a-=16)+
E(4[B+
V(010) /* end V() */ /
4+r*10]) /* end E() */
)/4,
(strcmp(ss +
V(i),
"main") /* end strcmp() */ ?
ru() :
0)
;
}
run(){
a=
E(5[B +
V(010) /* end V() in E() */
/4+r*10]) /* end E() */,
ru();
}
E(DX)
{
return *z /* z at this point appeared to be '\002' if I (Cody) recalls correctly */ ?
DX : DX <<030 |
(DX&65280)<<010 |
DX>>8 & 65280 |
DX>>24&0377;
}
int* K(k)
{
return L(
E(
k [
(int*)V(17) /* end V() in E() in L() */
]) /* end E() in L() */ ,
0) /* end L() */;
}
int
main (int cka, char **k) { char *ck = (char *)cka;
exit(
E((ck
?main((z?
(stat(M,&t)?
P+=a+'{'?0
:3
:execv(M,k),
a=(signed char)
E(
*L(P++,0)
),
i=P,
y=(signed char)
E(
*L(P++,0)
)&255,
sprintf(Q,y/'@'-3?"*L(V(%d+%d)+%d,0)":"R[%d]",(y&7),'\r',y/0100-1?0
:
(signed char)E(
*L(P++,0)
)),
(a+127 &&
a+'}' &&
a+1 ?
(a+61 &&
a + 24 &&
a +
025 ?
(P=a+'H' &&
a%061 <=0 ?
P :i ,
d += sprintf
(d,a>0 ?
" R[%d]=E(~-E(R[%d])),\0 U R[%d],\0 R[%d] O,\0 U %d,\0R[%d]=0,"+(a&'8')*3:a <- 'c'?" %d, %c%s = R[%d], \0 %d, *R=%c%s==R[%d], \0 R[%d]=(int)%c%s,"-a%'w'%'j'*5:"%d,%d,%s=%d,",
a>0 ?
a-'h' ?
a-49 ?
a&7 :
(y/010&7)
:(P +=4,
*L(P-4,0)
):(y/010&7),
a>0 ?
a&7 :
"& "[a%3%2+1],
a + 72 ?
Q :
"*R", a>0 | a<-99 ?
(y/010&7) :
(P+=4,
*L(P-4,0)),
0)
,(char*)P) :
(P=i,
i = a + 61 ?
a +21?
E((P+=4,
*L(P-4,0))) :
(signed char) E(
*L(P++,0)) :
0,
d += sprintf( d,a%' '+29+"P O,\0 U %d,P=%d,"
, P,
P+i,
0,
0,
0),
(char* )P,
system((
sprintf
(d,
"A'",
k[1]),
b)
),
z)
) :
(n =
(y/010&7) - 4
? (y/010&7)%
5-1 ?
a+127 ?
(signed char)E(
*L(P++,0)) :
(P+=4,
*L(P-4,0)
) : 0 :
(Scan(),
*(
(char*)index
(ss+
V(i ),
0100) ?
(char*) index (ss+
V(i ),
0100) : d) =
0,
(int) (ss+
V(i)
)),
(y/010&7) %
5<2 ?
d += sprintf(d,
(y/010&7) %
5
?" %s=E(~-E(%s)), \0 U %s," +
4*
(y/010&7):
"%s=E(E(%s)%c%d),",
Q,
Q,
"+ - "[(y/010&7)],
n,
0),
(char* )P :
( a= (signed char)E(
*L(P++,0) /* end *L() */
) /* end E */ -
'u' ?
'!' :
'=',
d +=
sprintf(d,
(y/010&7)
- 4
? "P=%d%c=%s?%d:%d,":
"*R=E(((int(*)(l,l,l))%s)(K(1),K(2),K(3))),P O,"
,n,a,Q,P,P+
(signed char)E(
*L(P++,0) /* end *L() */
) /* end E */
) /* end sprintf */
,(char* ) P,
system(
(sprintf (d,
"A'",
k[1]
),
b)) /* end system */
,z))))
:
(Run
((z=(char*)&ck,stat(k[1],&t),B=(int*)mmap(0,i=t.st_size,3,1,open(k[1],2),0))
) /* end Run() */
,((
(B+13)[4] =
E(B+i/4) /* end E() */
,run(), /* end run() */
P=V(-~i), /* end V() */
(B+13)[4] =
E (
V(17) /* end V() */
-4
), /* end E() */
*(int*)
V(021) /* end V() */
= 0)),
sprintf(M,
".%s%d",k[1],
P) /* end sprintf() */,
d +=
sprintf(d,"%s %s '-DX=A(%s)' -o %s '-Dmagic=","cpp -std=gnu99 -Wall -Wextra -pedantic -Winfinite-recursion -Wno-bitwise-conditional-parentheses -Wno-error -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-to-pointer-cast -Wno-macro-redefined -Wno-pedantic -Wno-pointer-to-int-cast -Wno-return-type -Wno-string-plus-int -Wno-bitwise-op-parentheses -Wno-format -Wno-format-extra-args -Wno-int-conversion -Wno-unused-parameter -Wno-unsequenced -ggdb3 -E \"-DA(X)=#X\"","anonymous.c","cpp -std=gnu99 -Wall -Wextra -pedantic -Winfinite-recursion -Wno-bitwise-conditional-parentheses -Wno-error -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-to-pointer-cast -Wno-macro-redefined -Wno-pedantic -Wno-pointer-to-int-cast -Wno-return-type -Wno-string-plus-int -Wno-bitwise-op-parentheses -Wno-format -Wno-format-extra-args -Wno-int-conversion -Wno-unused-parameter -Wno-unsequenced -ggdb3 -E \"-DA(X)=#X\"",
M,
fflush(0)
) /* end sprintf() */
,(char* )P)
),k):
system(
(sprintf(M,
"rm -f .%s*",
k[1]),
M)/* end sprintf() in system() */
),z,*(B+13)
) /* end ck?main()... in exit() */
) /* end E() in exit() */
); /* end exit() */
} /* end main() */
-86
View File
@@ -1030,92 +1030,6 @@ fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing))! :-) ).
# 2001
## [2001/anonymous](2001/anonymous/anonymous.c) ([README.md](2001/anonymous/README.md))
## STATUS: known bug - please help us fix
This entry seems to no longer work and we would appreciate any help from anyone
who can fix this. [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) has
the following hints that might help but he has no system where he could test
it. [Yusuke Endoh](/winners.html#Yusuke_Endoh) [wrote a little bit about
it](https://mame-github-io.translate.goog/ioccc-ja-spoilers/2001/anonymous.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp) that
might or might not help but he too could not get it to work.
Tips from Cody:
- The original main() started like: `main (char *ck, char **k)` but we made it
compilable for clang by changing it to be: `main (int cka, char **k) { char *ck
= (char *)cka;` which might or might not be good.
- `gcc` reports an infinite recursive call of `main()`. My (Cody's) guess is
that this is the root of the problem of the crash but it might be other things.
I'm not sure how to stop this from happening. This happens before and after the
above fix for `clang`!
- Try a beautifier on the original C code. This might or might not work; see
next point.
- Use `cpp -E` (see [cpp.c](2001/anonymous/cpp.c)) and clean it up first. I
(Cody) did this for convenience though there are still macros. This is because
it was done via a hackish make rule:
cpp: ${PROG}.c
@echo "NOTE: this entry seems to no longer work."
magic='cpp ${CFLAGS} -E'; \
X='-DA(X)=#X'; \
$$magic -Dmagic= $$X "-DX=A($$magic \"$$X\")" \
$< ${LIBS} > anonymous.cpp.c
- (If beautifying) After beautifying it try changing references of the macros
(where not too complicated) to their definitions. For instance in vim you might
do: `:%s/\<l\>/int */g` and then delete the line that was changed to `#define
int * int*` (or else do a range substitute so it's not changed). You might not
need this if you use the cpp. This might be useful anyway to more easily test
things.
- If your system has a `setarch` tool that might or might not be of help (I'm
not too familiar with its internals).
- The code appears to do everything from one call to `exit(3)` but it makes use
of the ternary operator and possibly the comma operator Check the Makefile for
the defines but also observe that those are in the source file. It appears that
the entry might try compiling as well but that's from a quick glance.
- The author warns that only simple source (once compiled) would work so make
use of the provided source file
[2001/anonymous/anonymous.ten.c](2001/anonymous/anonymous.ten.c). To compile try
`make anonymous.ten` from the entry directory which you can then run the entry
on. Note that it needs to be compiled as a x86 program.
- The `Tr` macro appears (at a glance when very tired) to create another
function and when C pre-processed it seems like at least the function `L()` is
there twice. However this is actually a bit different: one is `L##i()` and the
other is `L()`. `L##i()` calls itself and `L()` calls `L##i()`. You might have luck
renaming it e.g. `Li()` instead but I (Cody) had some problems renaming some of
these functions (some but not all).
- Pray, cast a spell or just wish yourself good luck, depending on your
beliefs/personality/whatever! :-) It seems you'll need it! :-) (and also :-( )
Here are some additional warnings on different platforms:
```c
anonymous.c:12:13: warning: operation on 'P' may be undefined [-Wsequence-point]
#define I (P+=4,*L(P-4,0))
^
```
With `gdb` I determined that in the function `Runi()` appears to be NULL. I'm
not sure if this is relevant or not.
With `gdb` it appears that the crash happens with:
```
V (v@entry=<optimized out>) at anonymous.c:44
44 return E (B[v]);
```
(see [cpp.c](cpp.c)).
## [2001/bellard](2001/bellard/bellard.c) ([README.md](2001/bellard/README.md))
## STATUS: probable bug (possibly depending on system) - please help test and if necessary fix