Metadata in ELF shared libraries (`.note.rust`)

I was looking at the size of the libraries in rust installations, and I noticed that .note.rust is a big chuck. AIUI this is metadata that’s only needed at compile time to link to that library. So I have a few questions:

  • This section is marked WA, writable and allocated, which both seem unnecessary. If this data isn’t needed at runtime, then it doesn’t need to be allocated in memory at all, let alone writable, right? It’s probably not a big deal for memory use, since it won’t get paged in if it’s never touched, but it still seems wasteful.

  • If this section is not actually needed at runtime, then it could be stripped from the installed libraries in $libdir used by rustc et al. Only the libraries under rustlib/$target actually need to keep the metadata for linking, right?

  • It doesn’t seem to follow the standard note format (see here), which means commands like readelf -n can’t make sense of it at all. If rust followed this format, it could at least be listed properly, even if the contents are a mystery. Could this be changed?

Thoughts?

2 Likes

https://github.com/rust-lang/rust/issues/26764

https://github.com/rust-lang/rust/issues/27372

I don’t think there’s an existing issue covering stripping the section from installed libraries.

1 Like

Related issue

https://github.com/rust-lang/rust/issues/23366

2 Likes

Aha! Indeed it’s .note.rustc, which is why my search for .note.rust only came up with the original #244. Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.