https://sourceware.org/bugzilla/show_bug.cgi?id=27441
--- Comment #21 from Fangrui Song <i at maskray dot me> --- I made a mistake in #comment 16. In GNU ld, the rule is probably: * it is linked at least once in `--no-as-needed` mode (i.e. `--as-needed a.so --no-as-needed a.so` => needed) * or it has a definition resolving a non-weak reference by a previous input file (it works similar to archive member selection) In gold, the rule is probably: * it is linked at least once in `--no-as-needed` mode (i.e. `--as-needed a.so --no-as-needed a.so` => needed) * or it has a definition resolving a non-weak reference In LLD, a shared object is needed, if one of the following conditions is true: * it is linked at least once in `--no-as-needed` mode (i.e. `--as-needed a.so --no-as-needed a.so` => needed) * or it has a definition resolving a non-weak reference from a live section (not discarded by `--gc-sections`) Yes, the GNU ld behavior matches its documentation. But gold and LLD's behaviors are probably more useful (less reliance on position dependent behaviors - the user has more freedom moving it around on the linker command line without changing symbol resolution) and can make implementation simpler (no need to handle --as-needed shared object similar to the tricky archive member selection) # a.s call foo # b.s .globl foo foo: ret gold --as-needed b.so a.o && readelf -d a.out ... 0x0000000000000001 (NEEDED) Shared library: [b.so] -- You are receiving this mail because: You are on the CC list for the bug.