Skip to content

Instantly share code, notes, and snippets.

@densh
Created October 3, 2018 15:32
Show Gist options
  • Save densh/0465d02c9ef751bb2f813d03f5b26bfe to your computer and use it in GitHub Desktop.
Save densh/0465d02c9ef751bb2f813d03f5b26bfe to your computer and use it in GitHub Desktop.
Hello World size of SN vs statically linked C++
# cat main.cpp
#include <stdio.h>
int main() {
printf("hello, world!");
return 0;
}
# clang++ -c -Os main.cpp
# clang++ -o main main.o -static
# bloaty main
VM SIZE FILE SIZE
-------------- --------------
76.2% 573Ki .text 573Ki 69.5%
13.4% 100Ki .rodata 100Ki 12.2%
0.0% 0 .symtab 42.3Ki 5.1%
5.5% 41.2Ki .eh_frame 41.2Ki 5.0%
0.0% 0 .strtab 26.2Ki 3.2%
1.5% 11.4Ki .data.rel.ro 11.4Ki 1.4%
0.9% 6.73Ki .data 6.73Ki 0.8%
0.8% 5.74Ki .bss 0 0.0%
0.7% 5.28Ki __libc_freeres_fn 5.28Ki 0.6%
0.0% 0 .note.stapsdt 5.20Ki 0.6%
0.6% 4.14Ki __libc_thread_freeres_fn 4.14Ki 0.5%
0.0% 0 [Unmapped] 2.43Ki 0.3%
0.1% 400 [ELF Headers] 2.39Ki 0.3%
0.2% 1.66Ki __libc_IO_vtables 1.66Ki 0.2%
0.1% 552 .rela.plt 552 0.1%
0.0% 374 [15 Others] 408 0.0%
0.0% 0 .shstrtab 355 0.0%
0.0% 248 .got 248 0.0%
0.0% 208 .got.plt 208 0.0%
0.0% 184 .plt 184 0.0%
0.0% 142 .gcc_except_table 142 0.0%
100.0% 752Ki TOTAL 824Ki 100.0%
# cat sandbox/Test.scala
object Test {
def main(args: Array[String]): Unit = {
println("Hello, World!")
}
}
# sbt sandbox/nativeLink
[info] Loading project definition from /home/denys/.src/native/project
[info] Resolving key references (12160 settings) ...
[info] Set current project to native (in build file:/home/denys/.src/native/)
[info] Linking (503 ms)
[info] Discovered 551 classes and 3289 methods
[info] Optimizing (debug mode) (280 ms)
[info] Generating intermediate code (677 ms)
[info] Produced 20 files
[info] Compiling to native code (228 ms)
[info] Linking native code (immix gc, none lto) (106 ms)
[info] Total (1903 ms)
[success] Total time: 2 s, completed Oct 3, 2018 5:31:35 PM
# bloaty sandbox/target/scala-2.11/sandbox-out
VM SIZE FILE SIZE
-------------- --------------
30.9% 367Ki .text 367Ki 22.8%
26.8% 319Ki .rodata 319Ki 19.8%
0.0% 0 .strtab 296Ki 18.3%
20.4% 243Ki .dynstr 243Ki 15.1%
0.0% 0 .symtab 127Ki 7.9%
7.5% 90.0Ki .dynsym 90.0Ki 5.6%
7.4% 88.0Ki .eh_frame 88.0Ki 5.4%
2.8% 33.9Ki .eh_frame_hdr 33.9Ki 2.1%
2.2% 26.4Ki .gnu.hash 26.4Ki 1.6%
0.6% 7.50Ki .gnu.version 7.50Ki 0.5%
0.4% 4.94Ki .bss 0 0.0%
0.3% 3.73Ki .rela.plt 3.73Ki 0.2%
0.2% 2.50Ki .plt 2.50Ki 0.2%
0.0% 568 [ELF Headers] 2.43Ki 0.2%
0.0% 0 [Unmapped] 2.29Ki 0.1%
0.1% 1.27Ki .got.plt 1.27Ki 0.1%
0.1% 712 [13 Others] 802 0.0%
0.1% 708 .gcc_except_table 708 0.0%
0.0% 560 .dynamic 560 0.0%
0.0% 288 .rela.dyn 288 0.0%
0.0% 0 .shstrtab 271 0.0%
100.0% 1.16Mi TOTAL 1.58Mi 100.0%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment