cargo-bloat icon indicating copy to clipboard operation
cargo-bloat copied to clipboard

Analyze .rodata too

Open shufps opened this issue 3 years ago • 6 comments

I have troubles finding where this insane amount of .rodata is coming from ...

...
.text                 66898   131072
.rodata               33136   197976
...

Would be great, if cargo bloat also could support eg rodata :)

shufps avatar Mar 24 '21 12:03 shufps

This is planned.

RazrFalcon avatar Mar 24 '21 16:03 RazrFalcon

Ok, so the problem with .rodata is that its content is not defined. Only the app itself during execution knows what data is what. So we cannot "index" it beforehand without relying on disassembling, which is far from trivial.

RazrFalcon avatar Mar 28 '21 16:03 RazrFalcon

Is this where debuginfo is stored? I just cut down a test binary's size from ~450MB to ~60MB by setting profile.dev.debug = 0 in Cargo.toml, would have been nice if cargo bloat had told me before that it was such a huge part of the binary.

jplatte avatar Jun 03 '22 15:06 jplatte

FWIW, with --symbols-section .rodata and a patch to binfarce for it not to filter out STT_FUNC symbols in https://github.com/Shnatsel/binfarce/blob/ff619127bd1400d3589fec0ff067b4edb3b45d9c/src/elf64.rs#L247-L252, you can get useful results, like in https://github.com/unicode-rs/unicode-normalization/pull/86#issuecomment-1164910121

glandium avatar Jun 24 '22 00:06 glandium

@glandium are you sure this is enough? It might help a bit in case of ELF, but still not a general solution.

RazrFalcon avatar Jun 24 '22 11:06 RazrFalcon

It's not enough, but it's already helpful. I've seen cases where [unknown] stays high, though.

glandium avatar Jun 24 '22 20:06 glandium