[lld] [ELF] Set vna_flags to VER_FLG_WEAK if all references are weak (PR #176673)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 18 14:35:58 PST 2026


MaskRay wrote:

Additional context from 
https://maskray.me/blog/2020-11-26-all-about-symbol-versioning , which is itself linked by https://sourceware.org/bugzilla/show_bug.cgi?id=24718#c20

> ld.lld assigns version indexes as follows: first, each Verdef entry gets an index starting from 2; then, for each dynamic symbol resolving to a shared object definition, a new Verneed/Vernaux index is assigned if the (file, version) pair hasn't been seen.

> GNU ld sets VER_FLG_WEAK in Verdef::vd_flags when a version node has no associated symbol, matching Solaris behavior. [BZ24718#c15](https://sourceware.org/bugzilla/show_bug.cgi?id=24718#c15) proposed "set VER_FLG_WEAK on version reference if all symbols are weak" but was rejected. A [2026 comment](https://sourceware.org/bugzilla/show_bug.cgi?id=24718#c19) requires to revisit whether VER_FLG_WEAK version references should support optional dependencies—e.g., an executable with a weak reference to foo links against libA.so.1 (which provides `foo@@v1`), but at runtime runs with a libA.so.1 that lacks the version definition for v1. Currently this causes an rtld error.

https://github.com/llvm/llvm-project/pull/176673


More information about the llvm-commits mailing list