logoalt Hacker News

Show HN: A (marginally) useful x86-64 ELF executable in 301 bytes

54 pointsby meriboldlast Monday at 8:14 PM16 commentsview on HN

Comments

anonymous67453today at 10:40 AM

Dell 5440

    $ git clone https://github.com/meribold/btry
    ...
    $ make
    as -mx86-used-note=no btry.s -o btry.o
    objcopy -O binary btry.o btry
    chmod +x btry

    $ ./btry 
    Segmentation fault         ./btry

    $ strace -f ./btry 
    execve("./btry", ["./btry"], 0x7ffc1a562078 /* 57 vars */) = -1 ENOMEM (Cannot allocate memory)

    $ file btry
    btry: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, corrupted section header size
show 1 reply
vparsevaltoday at 4:23 AM

Love it! It's entirely inapplicable and useless to me but it embodies the spirit of Show HN and what the spirit of programming in the 80s and 90s was.

captn3m0today at 4:12 AM

I have a use for this: A somewhat portable one-liner to go in my waybar/sway/i3 configs!

emanuele-emlast Monday at 9:16 PM

301 bytes! The base64 one-liner install is a nice flex. Accepting an infinite loop when energy_full doesn't exist is peak code golf, perfectly reasonable when every byte counts. Is there a writeup on the assembly somewhere?

show 2 replies
userbinatortoday at 6:43 AM

It doesn't even look like particularly optimised Asm (could immediately spot a few savings, despite how horrible GAS syntax is to read...), but is definitely not "compiler slop"[1] either, which shows just how inefficient the majority of programs actually are. Of course even the ELF header takes up a significant amount of space, but this reminds me of how PC magazines would print short listings of utilities like this, often a few dozen up to a few hundred bytes at most --- in DOS .COM format, which is headerless and thus pure machine instructions.

[1] In the late 80s and early 90s, the battle between those writing handwritten Asm and those using compiled HLLs has many similarities to AI-generated vs non-AI code today.

show 1 reply
bregmatoday at 9:55 AM

As always with these admirable hacks, I feel compelled to point out these are not really ELF executables but just small files you can trick the x86_64 Linux kernel into loading.

I mean they're very clever and legit and kudos to the people who develop these exploits, but they're not ELF.

show 2 replies
Eric_Xuatoday at 5:47 AM

Love this kind of tiny, over‑engineered hack—totally impractical, but pure Show HN energy.

darioterrortoday at 4:46 AM

[dead]