gold has an option --print-symbol-counts= which prints:
// For each archive archive $archive $members $fetched_members // For each object file symbols $object $defined_symbols $used_defined_symbols
In most cases, $defined_symbols = $used_defined_symbols unless weak
symbols are present. Strangely $used_defined_symbols includes symbols defined relative to --gc-sections discarded sections.
The symbols lines do not appear to be useful.
archive lines are useful: $fetched_members=0 lines correspond to
unused archives. The information can be used to trim dependencies.
This patch implements --print-archive-stats= which prints the number of
members and the number of fetched members for each archive.
if this vector is not modified outside of this class then probably it would be good to keep it private and provide a read-only accessor instead.