Skip to content

Instantly share code, notes, and snippets.

@omasanori
Last active March 9, 2016 00:41
Show Gist options
  • Select an option

  • Save omasanori/ec03deb7449b5de9a33e to your computer and use it in GitHub Desktop.

Select an option

Save omasanori/ec03deb7449b5de9a33e to your computer and use it in GitHub Desktop.
An experiment for the size of hello world.
$ gcc --version | head -n1
gcc (Gentoo Hardened 4.9.3-r99 p1.2, pie-0.6.3) 4.9.3
$ gcc -dumpmachine
x86_64-gentoo-linux-musl
$ cat hello.c
#include <stdio.h>
int main(void)
{
puts("hello, world");
return 0;
}
$ gcc -Os hello.c -static -static-libgcc
$ strip a.out
$ ls -l a.out
-rwxr-xr-x 1 omasanori omasanori 9608 Mar 9 09:30 a.out
$ gcc -Os hello.c -static-libgcc
$ strip a.out
$ ls -l a.out
-rwxr-xr-x 1 omasanori omasanori 5800 Mar 9 09:35 a.out
$ gcc --version | head -n1
gcc (Gentoo Hardened 4.9.3 p1.4, pie-0.6.4) 4.9.3
$ gcc -dumpmachine
x86_64-pc-linux-gnu
$ cat hello.c
#include <stdio.h>
int main(void)
{
puts("hello, world");
return 0;
}
$ gcc -Os hello.c -static -static-libgcc
$ strip a.out
$ ls -l a.out
-rwxr-xr-x 1 omasanori omasanori 767152 Mar 9 09:39 a.out
$ gcc -Os hello.c -static-libgcc
$ strip a.out
$ ls -l a.out
-rwxr-xr-x 1 omasanori omasanori 6048 Mar 9 09:40 a.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment