News for hackers. Stuff that matters.

mcountryman

I had to picture someone opening a window and throwing it into orbit haha
Re:Statement of SEC Regarding Recent Market Volatility on Friday January 29, 2021 @11:11AM (#25958775)
Not a financial expert however, Citadel is a market maker rather than just a hedge fund like Melvin.

Money is lost when a retail investor holds onto their shares not just when the stock price rises.

Re:Show HN: Tiny 1k Rust binary on Windows on Wednesday December 02, 2020 @06:31PM (#25283266)
I'm a little short on time so I didn't read through all of it but, comptime generics sounds similar to how rust compiles generics and comptime parameters are similar to const fns although zig appears to have more control over what is deamed "compile time".
Re:Show HN: Tiny 1k Rust binary on Windows on Wednesday December 02, 2020 @04:31PM (#25281912)
I completely forgot stdout handle is in the PEB! Thanks! After learning how the windows x64 syscall calling convention works I got it working on win10.

https://i.imgur.com/ErHU7Kr.png https://github.com/mcountryman/min-sized-rust-windows/commit...

Re:Show HN: Tiny 1k Rust binary on Windows on Wednesday December 02, 2020 @03:51PM (#25281443)
Very well optimized inlined functions?

I didn't actually check the zig std source. I was referring to what I was seeing in radare2 :)

Re:Show HN: Tiny 1k Rust binary on Windows on Wednesday December 02, 2020 @08:30AM (#25276150)
Yeah my choice of words wasn't great. It seams as if the zig std acts as a macro rather than a wrapper. That could just be the aggressive optimization though
Re:Show HN: Tiny 1k Rust binary on Windows on Tuesday December 01, 2020 @04:05PM (#25269885)
@Edit2 I saw that, and that's pretty cool in regards to how the zig std is a wrapper rather than a rewrite. Although, if we were optimizing for size in this case it might be more optimal to have only one entry in the import table :D
Re:Show HN: Tiny 1k Rust binary on Windows on Tuesday December 01, 2020 @04:00PM (#25269838)
Between a 40b strcmp method (If I had/if it was more widely supported I could use sse4.2 strcmp) and ~74b of resolving said exports a couple syscalls sounds pretty nice provided the context switch isn't more expensive than resolving the imports.
Re:Show HN: Tiny 1k Rust binary on Windows on Tuesday December 01, 2020 @03:53PM (#25269752)
I thought of that but couldn't figure out how to get the syscalls for my system and the assembly around it. Being on win10, kernel32 links to api-console-... and I haven't been able to find it on my system. A few online downloads had it but, they don't export `GetStdHandle` and `WriteFile`. I thought maybe there was dynamic export generation going on because they did have those names as strings.

Edit: Also I believe ntdll doesn't export `GetStdHandle` anymore.

Re:Show HN: Tiny 1k Rust binary on Windows on Tuesday December 01, 2020 @10:57AM (#25266250)
In order to get that to 1Kb you would probably have to drop the `.idata` section and resolve syscalls from the PEB like I did.
Re:Show HN: Tiny 1k Rust binary on Windows on Tuesday December 01, 2020 @10:43AM (#25266114)
Ah, yeah, I wasn't trying to shrug off the usefulness of zig, sorry. I think when it comes to compile size zig does it a bit better due to it's smaller std although, when compiling rust with just a link to libc and a printf call I believe you get an exe ~2048b when optimizing for size so I'm not certain how well that scales.

The 100 line hack I used was to noop out the `.idata` section which link.exe refused to merge/shrink, that only saved me 1Kb in the end.

Looking at the section info of the zig exe it looks like there is some black magic going on with it's alignment so I may have to dig deeper to see what zig is doing here. Also thank you both for pointing zig out, I haven't heard of it until now and it may come in handy for something else I'm planning on making :)

Re:Show HN: Tiny 1k Rust binary on Windows on Tuesday December 01, 2020 @09:36AM (#25265493)
Just for fun, the compiled rust exe has 480 non-zero bytes, the zig exe had 512 bytes.
Re:Show HN: Tiny 1k Rust binary on Windows on Tuesday December 01, 2020 @08:52AM (#25265084)
I couldn't get it working and was familiar with the `llvm_asm!` syntax. Although, I may have to go back and switch it around again.
Re:Show HN: Tiny 1k Rust binary on Windows on Tuesday December 01, 2020 @08:47AM (#25265048)
I linked these guys here https://github.com/pts/pts-tinype. They managed to do something similar with the PE headers, and I might have to try that next although I'm doubtful win64 exes are permitted to run if they are >1Kb
Re:Show HN: Tiny 1k Rust binary on Windows on Monday November 30, 2020 @03:26PM (#25258515)
This is my attempt at making the smallest exe with rust for windows using the msvc toolchain. If y'all have any pointers how to get it smaller let me know :)
Re:Apple fans returning new MacBook Pros with Core i9 on Friday July 20, 2018 @03:21PM (#17578061)
From 200+ comments "cancel" was listed 4 times in that reddit thread and "return" was listed 5 times. Some repeats in there.