News for hackers. Stuff that matters.
Re:Go gets preliminary WebAssembly support by brobinson on Saturday April 14, 2018 @02:54AM (#16836249)
Half the size of Go binaries you encounter in the wild are debugging symbols. Compile without them and use `upx --ultra-brute` and the binary will be about ~15% of its original size. You still get goroutine stack traces from panics without the debugging symbols.
Re:Go gets preliminary WebAssembly support by mappu on Saturday April 14, 2018 @08:06AM (#16836972)
Even building without debugging symbols, a lot of the remaining size comes from runtime type information and method/function/struct names, used in reflection, which there's no way to remove. That also has some reverse-engineering implications.
Re:Go gets preliminary WebAssembly support by oelmekki on Saturday April 14, 2018 @04:29AM (#16836487)
I didn't know go compiler allowed to build without those, thanks.

I've just tried on a go binary that was 2.4MO. After building it with `go build -ldflags=-s .`, it's 1.6MO. After stripping with upx, it's 480ko (and still works, and has panic stack traces).

Re:Go gets preliminary WebAssembly support by killercup on Saturday April 14, 2018 @06:27AM (#16836743)
Please note that upx also compresses your binary contents and decompresses it at runtime.

When downloading a WASM file over HTTP, the server can gzip it transparently. It'd be interesting to compare the effects on the size with what upx does (which is more specialized than gzip).

Re:Go gets preliminary WebAssembly support by oelmekki on Saturday April 14, 2018 @06:47AM (#16836778)
I see, thanks. I used vanilla `strip` on my binary and it did not produce any size gain (so the strip flag of go compiler is plenty enough).

Indeed, given how browsers already handle gunziping resources, it's probably best to rely on it. My binary, stripped by the go compiler and gziped, is 525ko (against 480ko using upx).

Re:Go gets preliminary WebAssembly support by yjftsjthsd-h on Saturday April 14, 2018 @10:11AM (#16837374)
Could it also be that Go encodes symbols in a way that strip can't read, or is is just standard ELF stuff?
Re:Go gets preliminary WebAssembly support by brobinson on Saturday April 14, 2018 @06:44PM (#16839991)
Don't forget the "-w" linker flag, too.
Re:Go gets preliminary WebAssembly support by codetrotter on Saturday April 14, 2018 @11:24AM (#16837691)
I remember UPX packed binaries would trigger some antivirus software in the past because packing was so frequently used by virus authors. Does anyone know if this is still the case?

Also, can you use UPX on WebAssembly binaries? If so, will that trigger any widely used antivirus software?

Re:Go gets preliminary WebAssembly support by infogulch on Saturday April 14, 2018 @08:22PM (#16840365)
UPX just compresses the machine code on disk and decompresses it in memory before execution. WebAssembly executables are delivered via http and can just be compressed with gzip/brotli etc as part of the existing protocols, completely transparently to WA itself.

Granted, UPX is specialized so it might have a slight compression edge over gzip. But layering UPX over WA will require three passes over all the code before it's ready to start (1: browser downloads and executes UPX stub and compressed data. 2: UPX unpacks and reloads uncompressed code. 3: browser re-compiles and executes unpacked code again.) This would completely decimate browsers attempts to make WA startup fast like firefox's streaming compiler [1] that starts compiling it before it's even done downloading.

[1]: https://hacks.mozilla.org/2018/01/making-webassembly-even-fa...

Re:Go gets preliminary WebAssembly support by MikusR on Saturday April 14, 2018 @10:33AM (#16837457)
Upx also breaks memory mapping.