From 31fef7fa438e8f48ec9efb1c05512bc33962cdc9 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 19 May 2023 04:12:33 -0700 Subject: [PATCH] Update 2001/anonymous - cpp, 32-bit ELF ten.c etc. Add back cpp.c which is a C pre-processed version of anonymous.c. Added comments and tried to format it some. Perhaps I should use a formatted / de-obfuscator from some years ago in the IOCCC (by Dave Burton) but I didn't think of that until much later on: I'll consider it another time. The Makefile builds cpp by default. Works as well as anonymous.c: will modify 32-bit ELF binaries in the right systems (it won't touch them in macOS - I pre-compiled anonymous.ten.c as 32-bit ELF in linux and added it to the repo as anonymous.ten.32 mostly for those who might be able to run 32-bit ELF binaries but have no way to compile them though maybe no system has that but it also allows for partly 'testing' the program in macOS). Change main target to compile to anonymous and not anonymous_tmp. This is because otherwise running make would repeatedly try and build it. I did try changing the target but that didn't want to work possibly due to the cp updating the timestamp though that's a quick thought in the head of someone who's been awake too long at the hour. Instead anonymous.sh is the script to run to 'emulate' the running of the target program (again assuming that's correct which does seem likely but is still unconfirmed). The anonymous.sh script now checks for compiling anonymous.ten.c but uses anonymous.ten.32 as a backup if it exists. Update bugs.md and README.md. Anything else I'm afraid I've forgotten. --- 2001/anonymous/Makefile | 17 +- 2001/anonymous/README.md | 21 +- 2001/anonymous/anonymous.sh | 2 +- 2001/anonymous/anonymous.ten.32 | Bin 0 -> 23380 bytes 2001/anonymous/cpp.c | 383 ++++++++++++++++++++++++++++++++ 2001/anonymous/try.me.sh | 37 +-- bugs.md | 44 +++- 7 files changed, 464 insertions(+), 40 deletions(-) create mode 100755 2001/anonymous/anonymous.ten.32 create mode 100644 2001/anonymous/cpp.c diff --git a/2001/anonymous/Makefile b/2001/anonymous/Makefile index 69c986db9..0e5c926c4 100644 --- a/2001/anonymous/Makefile +++ b/2001/anonymous/Makefile @@ -117,9 +117,9 @@ PROG= ${ENTRY} # OBJ= ${PROG}.o DATA= -TARGET= ${PROG} ${PROG}.ten +TARGET= ${PROG} cpp ${PROG}.ten # -ALT_OBJ= +ALT_OBJ= ALT_TARGET= @@ -139,8 +139,8 @@ ${PROG}: ${PROG}.c X='-DA(X)=#X'; \ warning='-Dprocessor'; \ $$magic $$warning -Dmagic= $$X "-DX=A($$magic \"$$X\")" \ - $< -o $@_tmp ${LIBS} - ${CP} -af anonymous.sh $@ + $< -o $@ ${LIBS} + ${CHMOD} -v +x anonymous.sh ${PROG}.ten: ${PROG}.ten.c @@ -157,6 +157,15 @@ ${PROG}.ten: ${PROG}.ten.c @echo ${CC} ${CFLAGS} -m32 $< -o $@ ${LIBS} +cpp: cpp.c + magic='${CC} ${CFLAGS}'; \ + X='-DA(X)=#X'; \ + warning='-Dprocessor'; \ + $$magic $$warning -Dmagic= $$X "-DX=A($$magic \"$$X\")" \ + $< -o $@ ${LIBS} + ${CHMOD} -v +x anonymous.sh + + # alternative executable # alt: data ${ALT_TARGET} diff --git a/2001/anonymous/README.md b/2001/anonymous/README.md index 82cec013a..bdf3e43d0 100644 --- a/2001/anonymous/README.md +++ b/2001/anonymous/README.md @@ -16,10 +16,10 @@ make ``` [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 -[bugs.md](/bugs.md) for why this is); this is not a bug but a feature inherent -in what it does. +supplementary program and the program itself (but for the program itself see +[bugs.md](/bugs.md), both of which segfaulted. He managed to do this with linux +but it will not work with macOS (see [bugs.md](/bugs.md) for why this is); this +is not a bug but a feature inherent in what it does. Although it took a fair bit of debugging it turns out all that needed to be changed was: @@ -30,8 +30,9 @@ prevented `main()` from entering an infinite loop. Without either of these it would crash and prevent modification of the 32-bit [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) (not elf :-) -) binary. The following change was also made to be more portable, in case the -constants `PROT_READ` and/or `PROT_WRITE` are not standardised: +) binary. But again see [bugs.md](/bugs.md) here. The following change was also +made to be more portable, in case the constants `PROT_READ` and/or `PROT_WRITE` +are not standardised: Change `3` in the call to `mmap()` to be `PROT_READ|PROT_WRITE`: just in case `PROT_READ|PROT_WRITE` does not equal 3 (though it seems to be equal in both @@ -60,9 +61,11 @@ The author suggested that this will somewhat destroy the binaries this touches but Cody did not observe this. It does indeed modify the files as the script below will show you (though not all files are modified: can you figure out why that is?) but Cody did not notice any problems in using them. Perhaps it's -something he's not aware of. If you follow the try commands below you will -notice that although the binaries do differ it's not many differences. See the -author's warning about this. +something he's not aware of possibly including the fact that the modification +might or might not be complete. If you follow the try commands below you will +notice that although the binaries do differ it's not many differences and the +output of the supplementary program both before and after is the same. See the +author's warning about this in their remarks. ### INABIAF - it's not a bug it's a feature! :-) diff --git a/2001/anonymous/anonymous.sh b/2001/anonymous/anonymous.sh index 230aa01e2..0b561f61e 100755 --- a/2001/anonymous/anonymous.sh +++ b/2001/anonymous/anonymous.sh @@ -7,7 +7,7 @@ fi make >/dev/null 2>&1 if [[ -f "$1" ]]; then - ./anonymous_tmp "$1" + ./anonymous "$1" ./"$1" fi diff --git a/2001/anonymous/anonymous.ten.32 b/2001/anonymous/anonymous.ten.32 new file mode 100755 index 0000000000000000000000000000000000000000..582ea5ba8cfde4a34a8bcb1528283010bc354210 GIT binary patch literal 23380 zcmeHPdu$xV8J|1f*%#Y5b{>!rR2Jeu65{hCCQt$)PW()r#5fKlyf){%weQOL&fM)K zc3Y@Z^N1VLCRGIyZAGd!0;!^+C{k(uXbna@R9Xf8Xse1=^nvQAX&c(mrX_Iw{bqOU zy^W2EgaB1L*0(d?e82f-=9}5^?9AMJv8A)s=kp2W{Gv#Z+jTGyYJ~s#c1zMIG*K>= zi>2anQH&_c8b^Qub=|hqKY~O7#F2_X$G{)k8wio+gC|i&-6ZLdR)Ct3fJC{dwB_&x z%0O!O3qcAxP zC+z}HQnGDtnz2)mpMs2Z31lQC?}B_p6Ji8qBS~91qkd#7 zYLkiH+GMOInMmb^!r64V!OD99WVC(TmhIxfPk-h2E06cQ{=&qMzge4odeOe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geBf@rCs+loi&qPt;sieQ0bwlF3AdQEoFc zEc!B$0Yi`F1_p+a#KGz876s6$iHtodLmBx}bNFcOZra?Uw`^&~WJYh^xut1y$3{fs z^RQW(1*!-2 z_#UY1&1R=m_iWy%s!e+d5zY<|n2}!iX2$a4DulV6k-;z}2i5*mF5H_-;L^(k#?h%L zoGlqNGA2es8P&9*qec!rgvWUvB^(=0Aq&elGa^iheF~|7(ILZ|OS}~rOk$*yg+%)e zAkH?TwaaIbe8(1k+7S4Y%qo?v zYdB(>nM7|6Q)E=Y=*{(`m-VGpIMUmjF?K5smw_583=`r%*Z=HzwhdD`%t`D!TfyMF zWXe%Sw-i(YB2M0o3PCl(%JKg;-5QX>$vaYk<9Rvd6s`ji3deaa55;K;1YhBJj_#j0 z@5X$2)^53tQ)hgLBSkNY9?_!vv(Lc=Aj(1ba#Vz z-j4cs*6uU{JlCi4WjyI#5YOi^%rkoD5U4}gnJ-vz05k_g9MAZzLLoR=Qu zZUcyC0vmy2xryUBL4}iFt#-VervOw9UOD3E9tE*ZOkaojOdW76pK{bq>`{=yaUQh` zf}bg4Kt>$h_dp8A`Cc6+kN6^M|fR}roNv5n>Yx^`N|DB?)J0dWn8IL^}pv*1obPTLVD?+gZR z5@EJ49d)tY{tjaKh~r(cr)SakF9(kE@iV~j9H?@td{n0NaULE*qfw?DWpu>|Fn{LD z`EB_uxH4NG#L^MB&kob0KGFg_Sho=n=i6T=4jqp+rBh{CY3s9M@s76(@vdUvQy1MD z7jAKf5MQ-K@~LpmF5DBqeSQX9myJ{PSh`7w$6Yw;B+0&K%U%I)7YctF_|+iRqY}h- gjkZ&6)mGfW%(=hqsE4i!507gzS+@&Et; literal 0 HcmV?d00001 diff --git a/2001/anonymous/cpp.c b/2001/anonymous/cpp.c new file mode 100644 index 000000000..9d3b12559 --- /dev/null +++ b/2001/anonymous/cpp.c @@ -0,0 +1,383 @@ +#include +#include +#include +#include +#include + +#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 +pain(char *ck, char **k) +{ +return (z ? + (stat(M,&t) ? + P+= a+'{' ? + 0 : 3 + : execv(M,k), /* note: M appears to be empty here but this used to be recursive main() + so M might have been modified on additional calls */ + 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)) + ), /* ends sprintf() on line 175 */ + (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 ) /* end sprintf on line 195 */ + ,(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 ), /* ends sprintf() on 242 */ + (char* ) P, + system( + (sprintf(d,"A'",k[1]), + b) /* sprintf IN system() on line 252 (above line) */ + ) /* ends system on 252 */ + ,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 ), /* V(i ) in index from line 274 */ + 0100)/*ends index() on line 274 */ + ?(char*)index(ss + + V(i ), /* V(i) in index() on line 277 */ + 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 ) /* ends sprintf() on line 288 */ + ,(char* ) P + : + (a=(signed char) E( + *L(P++,0) /* *L() in E() from line 301 */ + ) /* ends E() on line * 301 */ + -'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) /* *L() in E() in sprintf() from line 308 */ + ) + ) /* ends sprintf() on line 308 */ + + ,(char* ) P, + system( + (sprintf(d,"A'",k[1]), /* ends sprintf() in system() on line 323 */ + b)) /* ends system() on line 323 but appears that b is what's system()d */ + ,z) + ) + ) + ) + : + (Run( + (z=(char*)&ck, + stat(k[1],&t), /* stat() in Run() on line 331 */ + B = + (l)mmap(0,i=t.st_size,PROT_READ|PROT_WRITE,1, + open(k[1],2),0) /* open() in mmap() (line 325) in Run() (line 331 */ + ) + ), /* ends Run() on line 331 */ + (((B+13)[4] + = + E(B+i/4), + run(), + P = V(-~i), + (B+13)[4] = + E( + V(17)- /* V() in E() on line 345 */ + 4),*(int*)V(021))), /* second V() in E() on line 345 */ + sprintf(M, + ".%s%d",k[1],P), /* ends sprintf() on line 348 */ + 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\"", /* end first string in sprintf() %s from line 350 */ + + "anonymous.c", /* second string in sprintf() on line 350. + note it appears to run the above cpp on 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\"", + /* above line is third string in sprintf() on line 350 */ + M, /* fourth string in sprintf() on 350, possibly running cpp from above line on M */ + fflush(0) ), /* end sprintf() on line 350 */ + (char* ) P) /* ends Run() on line 331 */ + ); + +} +int +main (int cka, char **k) +{ + char *ck = (char *)cka; + + /* main calls exit() which calls E() which has a call to pain() if + ck ((char *)cka - was originally a char * as first arg to main()) with + second arg being argv or k. Otherwise it calls system() with a convoluted sprintf() */ + exit (E( + (ck?pain((char*)cka,k): /* if ck ((char *)argc which used to be a char *) run pain() which used to be main() */ + system( /* otherwise if !ck call system() with ... */ + (sprintf(M,"rm -f .%s*",k[1]),M) /* sprintf() writing to M a convoluted string including itself (which + iirc is undefined but perhaps it's my tiredness: I can't think of what + the '*' does in sprintf()) */ + ), /* ends system() from line 374 */ + z,*(B+13))) /* end E() which calls either pain() or system() (which calls sprintf() on M) from line 372 from exit() on line 372 */ + + ); + +} /* end main() */ diff --git a/2001/anonymous/try.me.sh b/2001/anonymous/try.me.sh index 8d85c58e0..f1d33879a 100755 --- a/2001/anonymous/try.me.sh +++ b/2001/anonymous/try.me.sh @@ -2,30 +2,37 @@ make clobber all >/dev/null 2>&1 -if [[ -f "anonymous.ten" ]]; then - make anonymous 2>/dev/null - echo "$ cp anonymous.ten anonymous.ten.bak" 1>&2 - cp anonymous.ten anonymous.ten.bak - echo "$ ./anonymous anonymous.ten" 1>&2 - ./anonymous anonymous.ten - echo "$ ./anonymous.ten" 1>&2 - ./anonymous.ten - echo "$ diff -s anonymous.ten anonymous.ten.bak" 1>&2 - diff -s anonymous.ten anonymous.ten.bak - echo "$ od -t x1 anonymous.ten > ten.od" 1>&2 - od -t x1 anonymous.ten > ten.od +TARGET="anonymous.ten" + +if [[ ! -f "$TARGET" ]]; then + TARGET="anonymous.ten.32" + echo "cannot compile anonymous.ten.c as 32-BIT, trying anonymous.ten.32 as backup" + echo "if your system cannot run 32-bit ELF binaries this might fail" +fi + +if [[ -f "$TARGET" ]]; then + echo "$ cp $TARGET anonymous.ten.bak" 1>&2 + cp "$TARGET" anonymous.ten.bak + echo "$ ./anonymous $TARGET" 1>&2 + ./anonymous.sh "$TARGET" + echo "$ ./$TARGET" 1>&2 + ./"$TARGET" + echo "$ diff -s $TARGET anonymous.ten.bak" 1>&2 + diff -s "$TARGET" anonymous.ten.bak + echo "$ od -t x1 $TARGET > ten.od" 1>&2 + od -t x1 "$TARGET" > ten.od echo "$ od -t x1 anonymous.ten.bak > ten.bak.od" 1>&2 od -t x1 anonymous.ten.bak > ten.bak.od echo "$ diff ten.bak.od ten.od" 1>&2 diff ten.bak.od ten.od - echo "$ ./anonymous.ten > ten.txt" 1>&2 - ./anonymous.ten > ten.txt + echo "$ ./$TARGET > ten.txt" 1>&2 + ./"$TARGET" > ten.txt echo "$ ./anonymous.ten.bak > ten.bak.txt" 1>&2 ./anonymous.ten.bak > ten.bak.txt echo "$ diff -s ten.txt ten.bak.txt" 1>&2 diff -s ten.txt ten.bak.txt else - echo "cannot compile anonymous.ten.c as 32-bit, sorry." + echo "cannot compile anonymous.ten.c as 32-bit and backup file does not exist, sorry." exit 1 fi diff --git a/bugs.md b/bugs.md index 039bf54c3..e4c50d742 100644 --- a/bugs.md +++ b/bugs.md @@ -1114,24 +1114,46 @@ modifies the program, only works on 32-bit ELF binaries (by design) and the binary still works but we do not know if it's supposed _additionally_ run it. Can you confirm? Please let us know! - ## STATUS: INABIAF - please **DO NOT** fix [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this so that it -works (it segfaulted - but see above) in modern systems but he notes that the -program [anonymous.ten.c](2001/anonymous/anonymous.ten.c) **MUST** be compiled -as a 32-bit ELF binary! This is because the program only works on 32-bit ELF -binaries. If you cannot use `-m32` on the files it acts on the program **will** -almost certainly crash but in no case will it work properly. +doesn't segfault and so that it at least _does_ modify the target executable (but see +below) but he's not sure if it's _also_ supposed to run the program; upon a second +look at the README.md file it _appears_ that it's supposed to but the binary at least +is modified (hopefully in the correct way that the entry is supposed to do but +this cannot be confirmed), at least if 32-bit ELF (that's the only file type +it's supposed to modify). -This means that for macOS it will not work. Why will this not work in macOS? -Because Apple saw to it to make it very hard to compile 32-bit binaries (thanks -Apple for ruining some IOCCC entries! :-) :-( ). This appears to be even harder -with the Apple silicon chip. Thus this entry will not work with macOS unless you -have an older, out of date version. +The [anonymous.sh](2001/anonymous.sh) script, run by +[2001/anonymous/try.me.sh](2001/anonymous/try.me.sh), is for now a workaround +(until it can be ascertained - and addressed if necessary and possible - if the +program is supposed to run the target executable or not); the script runs the +program on the target executable and then runs the target executable after +modification which in effect emulates the original program (if indeed it did run +the executable as seems likely). + +So again this might be only partially resolved but for now this is unknown. + +Cody also fixed the [anonymous.ten.c](2001/anonymous/anonymous.ten.c) program +(it also segfaulted) but notes that it **MUST** be compiled as a **32-bit ELF +binary** so it will NOT work in macOS (for example); if you cannot use `-m32` or +even if you can but it cannot compile as an ELF binary (not elf binary :-) ) +(but see below) then the `anonymous` program itself will very likely crash if +you run it on the compiled [anonymous.ten.c](2001/anonymous/anonymous.ten.c) but +if nothing else it will not modify the target executable (this part of the fix +at least should be correct). + +In fact if you run the program on a 32-bit ELF binary (say compiled from another +system) under macOS it won't even touch it (it shouldn't crash however). + +The file `2001/anonymous/anonymous.ten.32` is a pre-compiled +[2001/anonymous.ten.c](2001/anonymous.ten.c) as a 32-bit ELF binary in case you +can run ELF binaries but cannot compile 32-bit binaries. Other BSD Unices were not tested. +BTW: if something is _partially_ resolved is it impartial ? :-) + ## [2001/bellard](2001/bellard/bellard.c) ([README.md](2001/bellard/README.md)) ## STATUS: doesn't work with some platforms - please help us fix