I'll start:void _start(void) {
__asm__("mov $60, %rax\n" // SYS_EXIT
"mov $0, %rdi\n" // exit code
"syscall");
}
Result: 824 bytes.$ gcc -static -nostdlib -nostartfiles -Os -s main.c
$ ./a.out
$ echo $?
99
$ wc -c a.out
824 a.out
Why is GCC so shit?
>>60865834
sorry, forgot to changemov $0, %rditomov $99, %rdi
use objdump and have a look, GCC is including more than you think.
>>60865883
You meanreadelf -a a.out?
How do I remove build-id for starters?--build-id=nonedoesn't work.
>>60865883
>>60865924
No, I think you meantobjdump -x
>>60865834
There's a lot of boilerplate that gets loaded in on binaries compiled for memory managed platforms, because memory isn't an issue, and neither is disk space.
The ELF format probably has more boilerplate stuff in it than the code you're executing.
>>60865980
Yeah, I think I need to remove 3 sections out of 4:
.note.gnu.build-id
.eh_frame
.comment
And only leave .text - I'll come back when I figure out how to do that
https://developer.xamarin.com/guides/android/advanced_topics/application_package_sizes/
why is xamarin so shit?
>>60865998
Executed these:$ objcopy --remove-section .comment a.out
$ objcopy --remove-section .note.gnu.build-id a.out
$ objcopy --remove-section .eh_frame a.out
Down to 496 bytes. Any more suggestions?
>>60866015
-Os
strip
>>60866015
-fvisibility=hidden -fno-stack-protector -fdata-sections -ffunction-sections -Wl,--gc-sections
>>60866015
use gas instead of gcc, or yasm if you like a non shit tier asm syntax