[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

ITT: we try to COMPILE a non-bloated program

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 13
Thread images: 1

File: gcc.png (127KB, 999x799px) Image search: [Google]
gcc.png
127KB, 999x799px
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 change
mov $0, %rdi
to
mov $99, %rdi
>>
use objdump and have a look, GCC is including more than you think.
>>
>>60865883
You mean
readelf -a a.out
?
>>
How do I remove build-id for starters?
--build-id=none
doesn't work.
>>
>>60865883
>>60865924
No, I think you meant
objdump -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
Thread posts: 13
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.