Slashdot Mirror


PPK debuts the tiny programming challenge

kernelistic writes "Looks like the great folks at properkernel.com are running a developer challenge. They're looking for smallest executables that match the posted criteria. The rules look fairly straightforward. Anyone up for some fun?"

67 comments

  1. Sparse on details by Anonymous Coward · · Score: 0

    They don't say which platform it must run on. FreeBSD with Linux emulation? What architecture - i386? And are we writing for FreeBSD or Linux syscalls?

    1. Re:Sparse on details by kernelistic · · Score: 2, Informative
      From http://properkernel.com/tiny/ ...

      We're looking for the smallest binary that will accomplish the task at hand without causing any problems or crashes. We'll be testing the binary out on a FreeBSD machine using native FreeBSD, SVR4 and Linux ABI support. Entries using either Linux or FreeBSD syscalls will be accepted.

    2. Re:Sparse on details by Anonymous Coward · · Score: 0

      Hmm, they just added that last sentence now. I have the page open from fifteen minutes ago, and it isn't there then.

  2. howto of sorts... by raulmazda · · Score: 5, Informative

    Looks like they want a binary similar to the one described in A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux , except it has to print text and not just return 42.

    If only I had some spare time to play along at home...

    1. Re:howto of sorts... by jericho4.0 · · Score: 3, Interesting
      His solution was 45 bytes. I think the 2500 byte limit in the rules is going to encourage some solutions whose writers will be crushed by the winner.

      It's a nice challenge, but I think they should have been a bit more specific in the rules ('Preferably no fastcall binaries') and stated a more challenging task than putting out a string.

      --
      "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
  3. Eh, why? by Ivan+the+Terrible · · Score: 0, Troll

    Why is this challenge interesting?

    1. Re:Eh, why? by *xpenguin* · · Score: 2

      Why is this challenge interesting?

      Because it's fun to see who can make the smallest excecutable.

    2. Re:Eh, why? by 0x0d0a · · Score: 3, Funny

      Because it keeps people who would otherwise be writing tiny exploit code to take advantage of buffer overflows otherwise occupied.

    3. Re:Eh, why? by jericho4.0 · · Score: 3, Informative

      Because it's a challenge, of course. Why are you reading the developers section?

      --
      "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
  4. Linux syscalls by Anonymous Coward · · Score: 2, Interesting

    Hang on a sec .. they say they'll accept Linux syscalls being used, but to call them you need to use the 'fastcall' approach, that is, put your arguments in the registers and run an interrupt (int 0x80 in Linux.)

    But rule 3 states that you have to use a stack-based approach, no fastcall allowed! Wtf?

    1. Re:Linux syscalls by Anonymous Coward · · Score: 0

      They only stated "Preferably no fastcall binaries". That doesn't seem to say that they won't accept them.

    2. Re:Linux syscalls by Anonymous Coward · · Score: 0

      They just changed that. It previously said "No fastcall binaries!"

  5. Interesting challenge. by AJWM · · Score: 5, Interesting

    Just for comparison's sake, the quick'n'dirty approach:

    main()
    {
    char *msg = "The deep gray mouse runs after the holy yellow cheese.\n";
    write(1, msg, 56);
    }

    produces, stripped, a 3200 byte binary -- too big to qualify by 700 bytes.

    --
    -- Alastair
    1. Re:Interesting challenge. by kernelistic · · Score: 2, Interesting

      Using GCC 3.2 with -O3 -s gets things down to 2900 bytes. 400 bytes to go.

    2. Re:Interesting challenge. by AJWM · · Score: 2

      Okay. That 3200 number was with GCC 2.95.

      Tweaking the generated assembler and doing my own _start and -nostartfiles gets it down to about 1700 (yay!) except that I can't get it to exit cleanly, it segfaults after printing the string, even with a call to _exit (boo!).

      Ah well, enough playing for one evening.

      --
      -- Alastair
    3. Re:Interesting challenge. by Anonymous Coward · · Score: 1, Interesting
      Put it in an infinite loop. All they said was:

      • 5. Returns control to the operating system without causing any segmentation violations.


      That doesn't mean you have to return control to the OS. All it means is that if you do choose to return control to the OS, you have to do so without causing a segfault.
    4. Re:Interesting challenge. by 0x0d0a · · Score: 2

      No, it means that you have to return control to the operating system and not cause any segmentation violations while doing so. I can't see where you're coming from on this.

    5. Re:Interesting challenge. by Anonymous Coward · · Score: 0

      Obviously English is not your first language, as you are quite incorrect! Please read it again until you see sense.

    6. Re:Interesting challenge. by Anonymous Coward · · Score: 0

      00000000 <_start>:
      0: 31 c0 xor %eax,%eax
      2: 40 inc %eax
      3: cd 80 int $0x80

      versus

      00000000 <_start>:
      0: e9 fc ff ff ff jmp 1 <_start+0x1>

      Both are 5 bytes.

  6. Re:Is this for i386, or .... by Anonymous Coward · · Score: 1, Informative


    We're looking for the smallest binary that will accomplish the task at hand without causing any problems or crashes. We'll be testing the binary out on a FreeBSD machine using native FreeBSD, SVR4 and Linux ABI support. Entries using either Linux or FreeBSD syscalls will be accepted.


    FreeBSD only runs on i386 and Alpha. FreeBSD's Linux ABI support only emulates i386. I think that narrows things down a little.

  7. I think these guys must be reading Slashdot ... by Anonymous Coward · · Score: 3, Informative
    After some of the comments on here:

    • 3. Uses a stack-based approach (ie. No fastcall binaries!).
    has changed to:

    • 3. Uses a stack-based approach (ie. Preferably no fastcall binaries).
    And:

    • ... as long as the output is a valid ELF image.
    has changed to:

    • as long as the output is a valid x86 ELF image.
    Also they added:

    • Hate bloatware? This is your chance to show it!
    for some reason. Probably a slur against Microsoft, knowing what this lot is like.
    1. Re:I think these guys must be reading Slashdot ... by Anonymous Coward · · Score: 0

      And now they just took out the "ie." in rule 3. This is exciting!!

    2. Re:I think these guys must be reading Slashdot ... by Anonymous Coward · · Score: 0

      They've updated the page. Look the blurb at the bottom. It reads:


      Updated on Mon Nov 25 04:30:44 UTC 2002:

      We've update the rules to resolve a couple of ambiguities that some readers pointed out. Thanks for all the email guys.

    3. Re:I think these guys must be reading Slashdot ... by Anonymous Coward · · Score: 0
      At least they've admitted to changing the rules, the sneaky buggers:

      • Updated on Mon Nov 25 04:30:44 UTC 2002:
        We've update the rules to resolve a couple of ambiguities that some readers pointed out. Thanks for all the email guys.

    4. Re:I think these guys must be reading Slashdot ... by Anonymous Coward · · Score: 0

      Yeah, they added that bit a few minutes after sneakily updating the rules.

      Note that they have changed "update" to "updated" now. Sneaky or what!!

    5. Re:I think these guys must be reading Slashdot ... by jericho4.0 · · Score: 2

      I get the gist of the challenge, but 'preferably' is pretty vague. They might have an argument on their hands when they announce the winner.

      --
      "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
  8. link to a library by Anonymous Coward · · Score: 0

    They dont say you can link to a library, so you make a big fat library and link to it.

    The binayr is still elf etc etc.

    1. Re:link to a library by Anonymous Coward · · Score: 0

      That's just cheating, and anyway it takes many many bytes to link to a library - so much overheard it's not worth it!

  9. Beat this... by andfarm · · Score: 3, Interesting
    At one point I wrote a Mac OS (Classic) program that displayed the phase of the moon (as text AND a graphic) in a dialog box.

    The catch? I did it in 5,038 bytes, including a nifty color icon.

    Beat that.

    --

    TANSTAAFI: There Ain't No Such Thing As A Free iPod.

    1. Re:Beat this... by Anonymous Coward · · Score: 0

      And if having webpages encouraging the use of "man holes" wasn't bad enough, look at his domain name. "Menloschool"?? Obviously an abbreviation for "Men lovers' school", the premier homo-gay institution in North-West America! Ew!

    2. Re:Beat this... by Anonymous Coward · · Score: 0
      Good for you and your little Mac. How does this relate to x86 ELF? If you didn't mention the mac then it may have been anecdotally relevant. The fact you did it on a mac has no relevance, yet you insist on qualifing. Hell I've written 500 byte binaries on old antequated OS's woopee-farken-dooo.

      the Question is can you do it on Linux, freeBSD (or if you insist OSX)

    3. Re:Beat this... by Anonymous Coward · · Score: 0

      Also notice the username in the URL: http://thibs.menloschool.org/~andfarm/

      and here is clearly short for the Greek root andr, meaning man. So andfarm is short for man farm or man sex farm. The ancient Greeks BTW were notorious homos and would no doubt have felt at home with a Macintoshes.

    4. Re:Beat this... by satanami69 · · Score: 1, Offtopic

      Bravo to this thread. This is the most I've seen someone pay attention in an offtopic post. Applause all around.

      --
      I really hate Dan Patrick.
    5. Re:Beat this... by photon317 · · Score: 3, Interesting


      Heh, a freind of mine and I, about 8 years ago we had an x86 assembler programming contest between us. This contest was to reproduce a pager program under DOS (like the "more" command) that would take a filename argument and page it to the screen, one page per keystroke. He beat me just barely, the final numbers of bytes were like 97 and 102.

      --
      11*43+456^2
    6. Re:Beat this... by ProlificSage · · Score: 1

      What is this, reverse penis envy? Leave it to geeks to be proud of whose is smaller.... :-)

      --
      Real software engineers regret the existence of COBOL, FORTRAN and BASIC.
    7. Re:Beat this... by cant_get_a_good_nick · · Score: 2

      Hmm, smaller gets Tiger Woods a couple or 3 or 10 million a year...

    8. Re:Beat this... by Anonymous Coward · · Score: 0

      Well does a flythrough of the first level of Descent with music in 4095 bytes sound more complex than that? Should be somewhere on scene.org...

    9. Re:Beat this... by andfarm · · Score: 1
      I grovel at thy feet, oh .

      No, I didn't try *that* hard on this project.

      --

      TANSTAAFI: There Ain't No Such Thing As A Free iPod.

    10. Re:Beat this... by Eil · · Score: 2


      The DOS demo scene had a lively following in the mid 90's. One thing they liked to do was show off their assembly skills by packing the most visual effects they could into a little tiny binary.

      My favorite is called digi.com. It's little more than a 320x200x256 display of a rolling, rotating, reflecting, textured, light-sourced torus with some MIDI synth for background music. After you exit the demo, there's an additional full screen of ASCII art before you get your prompt back. The most impressive part was that the torus did all of it's stuff in realtime with no slowdown at all on my 16MHz 386SX. To this day I'm not sure how they did it since that machine can't even run DOOM acceptably. (This demo is a bit skippy but works under dosemu, minus sound.)

      Another one I have is of several (5 or 6) seemingly random (but impressive) 3D scenes stitched together. No sound or anything, but it clocks in at exactly 4096 bytes.

      Tried to find web or ftp links to both of these, but no luck. If you want them, track down my email address and just ask. They're really tiny so I have no problem sending them.

    11. Re:Beat this... by Anonymous Coward · · Score: 0

      Hell, that's nothing! When I was young, I wrote a multi-threaded microkernel. I added some developer tools (C compiler, text editor, and debugger), a primative GUI and even a game of Tetris. I did this all before breakfast and it was only 2 BYTES long!! Beat that! ;-)

    12. Re:Beat this... by Anonymous Coward · · Score: 0

      8 years ago - so this was before you started dating the Playmate?

      (BTW - still waiting for that proof.)

    13. Re:Beat this... by photon317 · · Score: 2


      Did I say Playmate? get off it slashstalker

      --
      11*43+456^2
    14. Re:Beat this... by Anonymous Coward · · Score: 0

      Funny how now you don't want to send that "proof"...

      Still trying to doctor up that pic in photoshop?

    15. Re:Beat this... by photon317 · · Score: 2


      I did send it, check the mailbox

      --
      11*43+456^2
    16. Re:Beat this... by Anonymous Coward · · Score: 0

      Actually, no, you didn't.

    17. Re:Beat this... by photon317 · · Score: 2


      Yes, I did.

      --
      11*43+456^2
    18. Re:Beat this... by Anonymous Coward · · Score: 0

      Sorry, it hadn't delivered it when I checked before. I just saw it though. I believe you now. I'm not much into all that fetish stuff but she does look cute in that picture where you're both drunk. Nice work.

      BTW, thanks for biting. It was fun.

  10. Re:First Post by Anonymous Coward · · Score: 0

    Learn to spell, you pitiful excuse for a wankshaft monkey. It's "wasted", not "waisted".

    For fuck's sake, can you not even get a first post right? Jesus fucking Christ! I pity you.

  11. Deep gray mouse runs after the holy yellow cheese by wcbarksdale · · Score: 4, Funny

    At least they've chosen a challenge with practical implications.

  12. Put it in the kernel. by Trusty+Penfold · · Score: 2, Funny


    Submit a kernel patch that prints the stuff about the mouse on a certain syscall.

    ASM
    mov eax 0xbaadca11
    syscall
    ret

    8 bytes. I win.

  13. super easy to beat the limit... by Just6979 · · Score: 5, Interesting

    justin@joker:~/tmp[1]$ cat small.s
    ; Justin White
    ; http://properkernel.com/tiny/ entry

    %define STDOUT 0
    %define SYS_exit 1
    %define SYS_write 4

    section data
    msg db "The deep gray mouse runs after the holy yellow cheese.", 0x0A
    msg_size equ $-msg

    section text
    global _start
    _start:
    ; write
    push dword msg_size
    push dword msg
    push dword STDOUT
    mov eax, SYS_write
    push eax
    int 0x80
    ; exit
    push dword 0
    mov eax, SYS_exit
    push eax
    int 0x80
    ; end _start

    ;EOF
    justin@joker:~/tmp[0]$ nasm -f elf small.s
    justin@joker:~/tmp[0]$ ld -x -s -o small -nostdlib --stats small.o
    /usr/libexec/elf/ld: total time in link: 0.006606
    /usr/libexec/elf/ld: data size 184328
    justin@joker:~/tmp[0]$ ll small
    -rwxrwxr-x 1 justin justin 516 Nov 25 03:22 small*
    justin@joker:~/tmp[0]$ ./small
    The deep gray mouse runs after the holy yellow cheese.
    justin@joker:~/tmp[0]$

    that's using FreeBSD kernel calls.

    that's the smallest it'll be without doing ELF header tweaking like in that tiny binary tutorial.

    actually, can save like 8 bytes by using just AL and not all of EAX to hold the syscall numbers.

    now, if they said, do it without using the kernel, that would have been a challenge :P

    --
    --Justin
    1. Re:super easy to beat the limit... by andfarm · · Score: 2
      I've done it in 169 bytes now. It's still a valid ELF image.

      No, I'm not telling you how I did it. [grin] Figure it out on your own. Or improve on my attempt. Whichever.

      Just tell me if you improve on it.

      --

      TANSTAAFI: There Ain't No Such Thing As A Free iPod.

  14. We've already been through this, sorta... by Jugalator · · Score: 2

    Smallest Possible ELF Executable?

    The answer was 45 bytes, but probably don't fulfill the criterias set in this challenge.

    --
    Beware: In C++, your friends can see your privates!
  15. How is 99 bytes? by mikemacd · · Score: 1

    I've managed to tweak a solution down to 99 bytes. Hows that?

    1. Re:How is 99 bytes? by aminorex · · Score: 2

      That sounds about right. You may have the
      optimal solution there, if you disallow schemes
      which algorithmically compress the output string.

      Now that you've done your homework and
      applied all the basic published techniques to
      shrink the straighforward write of static data down
      to it's minimum size, you can start to *think*
      *creatively* and work on dynamically allocating the
      buffer and generating its contents from code in
      fewer than 56 bytes.

      --
      -I like my women like I like my tea: green-
  16. Solved by Anonymous Coward · · Score: 1, Funny

    I have just discovered a 35 byte solution.

    Unfortunately, the source is too long to give here.

  17. Packed Tighter than that! by krakrjak · · Score: 1

    [krakrjak@krakrjak tinyASM]$ cat waaytiny.asm
    ; For entry in http://properkernel.com/tiny/entry
    ; Zac Slade
    ; waaaytiny.asm
    BITS 32
    org 00001000h
    db 7Fh, 'ELF'
    dd 1
    dd 0
    dd WW
    dw 3
    dd filesize
    dd _start
    dd 4
    _start:
    xor ebx, ebx
    inc ebx
    xor edx, edx
    jmp short Contin
    db 0
    dw 34h
    dw 20h
    dw 1 PLEASELETMEPOSTMYCODE
    dw 0 I'MASKINGNICELY
    dw 0
    dw 0
    StrLen EQU 55
    Strng db 'The deep gray mouse runs after the holy yellow cheese.', 0Ah
    Contin: mov Dl, StrLen
    xor eax, eax
    xor al, 4
    mov ecx, Strng
    intsta: int 80h
    xchg eax, ebx
    jmp short intsta
    filesize EQU W - WW
    [krakrjak@krakrjak tinyASM]$ nasm -f bin -o itstiny waaytiny.asm
    [krakrjak@krakrjak tinyASM]$ ll itstiny
    -rw-rw-r-- 1 krakrjak krakrjak 123 Nov 27 10:58 itstiny
    [krakrjak@krakrjak tinyASM]$ chmod +x itstiny
    [krakrjak@krakrjak tinyASM]$ ./itstiny
    The deep gray mouse runs after the holy yellow cheese.
    [krakrjak@krakrjak tinyASM]$

    There's My entry. Maybe someone else's entry is better than that but I'm hard pressed to get any better than that. That is using fastcalls, but it get's the job done.

    Stupid lameness filter.... I'll just ramble and see if it'll let me in...

    Perhaps maybe the Dollar Signs. I'll replace those with the letter W. Now the compression Filter. That's okay another paragraph here outta do it. I've taken most tabs and also added some CAPS stuff to get through the Filter.

    Has anyone heard of a better way for this one yet. Someone told me they had it smaller but they wouldn't show me how. Maybe if you can use some of the characters in the string as instructions then maybe it's possible to get some of it done that way. The only real problem is jumping into memory takes space too and doesn't save anything if you only execute one instruction.