News for hackers. Stuff that matters.
Re:151-byte static Linux binary in Rust by userbinator on Sunday January 11, 2015 @01:10AM (#8869231)
That main() can still be improved... try this:

    push 1
    pop eax
    mov edi, eax
    mov esi, 400008h
    push 7
    pop edx
    syscall
    push 3ch
    pop eax
    xor edi, edi
    syscall
It should be 10 bytes shorter.
Re:151-byte static Linux binary in Rust by ekimekim on Sunday January 11, 2015 @03:17AM (#8869435)
Yes, but the point was that it could be done in rust, using rust's language features (type safety and so forth). Making your main inline assembly isn't really using the language very much.
Re:151-byte static Linux binary in Rust by userbinator on Sunday January 11, 2015 @11:02AM (#8870266)
From the Github page: https://github.com/kmcallister/tiny-rust-demo

All of the machine code comes out of rustc. (Although all of the instructions that survive optimization went in as inline assembly.)

So while his main() is written in (unsafe) Rust, he's basically using it as a macroassembler.

Re:151-byte static Linux binary in Rust by omega_rythm on Sunday January 11, 2015 @04:10AM (#8869510)
You really should have a look at the rust code this guy wrote. I would not call that last optimization type safe.
Re:151-byte static Linux binary in Rust by the_mitsuhiko on Sunday January 11, 2015 @04:18AM (#8869518)
How so? The only unsafe part is the transmute which only saves 7 bytes anyways :P
Re:151-byte static Linux binary in Rust by exprL on Sunday January 11, 2015 @10:43AM (#8870213)
Even that is still type safe, just not portable. After all, every part of the memory is a collection of bytes (that is, a slice of u8) – whether you can access them is another story.
Re:151-byte static Linux binary in Rust by taralx on Monday January 12, 2015 @02:56AM (#8872879)
LLVM currently does not optimize for size, so things like the small-integer push/pop trick aren't goign to happen.