Description
extern crate rusoto_core;
const REGION: rusoto_core::Region = rusoto_core::Region::UsEast1;
fn main() {
println!("Hello, region {:?}", ®ION);
}
rusoto_core::Region
is a very simple enum type. This doesn't run any interesting code. The resulting Linux debug-build binary is 41MB. If I replace ®ION
with 0
the binary is 7.5MB.
readelf -a
shows that .text
is 370,558 bytes. .debug_info
is 10,541,677 bytes. The other debug sections account for most of the rest.
Inspecting the debuginfo shows DWARF compilation units for rusoto_core
and lots of its dependencies that are entirely dead code. For example:
COMPILE_UNIT<header overall offset = 0x0034b008>:
< 0><0x0000000b> DW_TAG_compile_unit
DW_AT_producer clang LLVM (rustc version 1.30.1 (1433507eb 2018-11-07))
DW_AT_language DW_LANG_Rust
DW_AT_name /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33/src/lib.rs
DW_AT_stmt_list 0x001534c8
DW_AT_comp_dir /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33
DW_AT_GNU_pubnames yes(1)
DW_AT_low_pc 0x00000000
DW_AT_ranges 0x000a7120
ranges: 89 at .debug_ranges offset 684320 (0x000a7120)
[ 0] <offset pair low-off: 0x00000001 addr 0x00000001 high-off: 0x00000001 addr 0x00000001>
[ 1] <offset pair low-off: 0x00000001 addr 0x00000001 high-off: 0x00000001 addr 0x00000001>
[ 2] <offset pair low-off: 0x00000001 addr 0x00000001 high-off: 0x00000001 addr 0x00000001>
[ 3] <offset pair low-off: 0x00000001 addr 0x00000001 high-off: 0x00000001 addr 0x00000001>
... followed by 85 more identical ranges. These all indicate empty code ranges; all code for this CU has been stripped by the linker. However, this CU still has a ton of debuginfo for types and for functions. E.g.:
< 4><0x00001802> DW_TAG_subprogram
DW_AT_low_pc 0x00000000
DW_AT_high_pc <offset-from-lowpc>262
DW_AT_frame_base len 0x0001: 57: DW_OP_reg7
DW_AT_linkage_name _ZN91_$LT$core..slice..Iter$LT$$u27$a$C$$u20$T$GT$$u20$as$u20$core..iter..iterator..Iterator$GT$4next1
7hc6f1932985554eebE
DW_AT_name next<serde_json::value::Value>
DW_AT_decl_file 0x00000005 /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33/libcore/slice/m
od.rs
DW_AT_decl_line 0x00000978
DW_AT_type <0x000007b0>
< 5><0x00001820> DW_TAG_formal_parameter
DW_AT_location len 0x0002: 9128: DW_OP_fbreg 40
DW_AT_name self
DW_AT_decl_file 0x00000003 /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33/src/lib.rs
DW_AT_decl_line 0x00000001
DW_AT_type <0x00002f94>
< 5><0x0000182e> DW_TAG_inlined_subroutine
DW_AT_abstract_origin <0x00001a7d>
DW_AT_low_pc 0x00000000
DW_AT_high_pc <offset-from-lowpc>123
DW_AT_call_file 0x00000005 /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33/libcore/slice/mod.rs
DW_AT_call_line 0x00000982
< 6><0x00001842> DW_TAG_formal_parameter
DW_AT_location len 0x0002: 9138: DW_OP_fbreg 56
DW_AT_abstract_origin <0x00001a97>
< 6><0x0000184a> DW_TAG_formal_parameter
DW_AT_location len 0x0003: 91c000: DW_OP_fbreg 64
DW_AT_abstract_origin <0x00001aa2>
< 6><0x00001853> DW_TAG_lexical_block
DW_AT_low_pc 0x00000000
DW_AT_high_pc <offset-from-lowpc>36
< 7><0x00001860> DW_TAG_variable
DW_AT_location len 0x0003: 91d000: DW_OP_fbreg 80
DW_AT_abstract_origin <0x00001aae>
< 5><0x0000186b> DW_TAG_template_type_parameter
DW_AT_type <0x00000064>
DW_AT_name T
All DW_AT_low_pc
s of DW_TAG_subprogram
, DW_TAG_lexical_block
and DW_TAG_inlined_subroutine
in this CU are zero. There are a lot of CUs like this.