3 ms·
That's because it links dynamically to the standard library.
by BubRoss 7y ago
That's because it links dynamically to the standard library.
- Dylan16807 7y agoIs that a problem? It's there whether you use it or not, and it's not like the asm is running in a vacuum either. If you go to an embedded point of view where there is nothing already supplied, you can get a hello world, even with a basic printf, down to that size.
- snvzz 7y agoEspecially since you use external libraries to do the bulk of the work, 6KB is a lot. It is an order of magnitude bigger than the assembly version.
- deleted 7y ago[deleted]
- SomeoneFromCA 7y agoAfter some manipulations with the linker, I was able to cut the size down to 750 bytes. You cannot go below this, without hacking the ELF file format.
- snvzz 7y agoI got my asm one down to 268 without even trying. It prints (via write syscall) "hello world.\n" and then calls exit(0). Assembled with fasm, linked with ld -n, then stripped.
- SomeoneFromCA 7y agoOk fine, I've used the tool called sstrip from a suite called ELFKickers. Now my hello_world.cpp (yes, c++) is 380 bytes long. I could not make it any shorter, so yeah, it is 120 bytes (50%) bigger than yours.
- snvzz 7y agoRegarding sstrip, I am familiar with it. Be careful that you know what it actually does.
- SomeoneFromCA 7y agoSo, not order of magnitude then?
- snvzz 7y agoYes, just look into how much effort you had to put vs my five minutes attempt. The difference is between just using asm, or going out of the way to try to coerce a C toolchain to minimize the bloat.
- SomeoneFromCA 7y agoYea, large effort (objcopy, strip, sstrip), that I need to do only once, after that I already know how to do this an can just put it in a shell script. Now, I would like to know how quickly you'll be able to write a quicksort implementaion, that would outperform my C code, while being at least 25% smaller . Yeah, and how big your binary will become, once you link libc or opengl or whatever to make it able to do actual work.
- deleted 7y ago[deleted]