Bug 32720 - ld: add --why-live
Summary: ld: add --why-live
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-19 06:02 UTC by Fangrui Song
Modified: 2025-08-22 02:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2025-02-19 06:02:35 UTC
Apple ld64 implements -why_live sym

> Logs a chain of references to symbol_name. Only applicable with -dead_strip . It can help debug why something that you think should be dead strip removed is not removed.

I have some notes at https://maskray.me/blog/2022-02-27-analysis-and-introspection-options-in-linkers

The feature has been ported to LLVM linker's Mach-O port (https://reviews.llvm.org/D120377) and the ELF port feature is being worked on (https://github.com/llvm/llvm-project/pull/127112).

Would be nice to have a similar feature in GNU ld.
Comment 1 Drea Pinski 2025-02-20 21:47:12 UTC
Seems badly named option.

why_referenced seems like a better name.