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

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 21 08:47:10 PST 2026


================
@@ -3811,29 +3812,34 @@ VersionNeedSection<ELFT>::VersionNeedSection(Ctx &ctx)
 
 template <class ELFT> void VersionNeedSection<ELFT>::finalizeContents() {
   for (SharedFile *f : ctx.sharedFiles) {
-    if (f->vernauxs.empty())
+    if (f->verneedInfo.empty())
       continue;
     verneeds.emplace_back();
     Verneed &vn = verneeds.back();
     vn.nameStrTab = getPartition(ctx).dynStrTab->addString(f->soName);
     bool isLibc = ctx.arg.relrGlibc && f->soName.starts_with("libc.so.");
     bool isGlibc2 = false;
-    for (unsigned i = 0; i != f->vernauxs.size(); ++i) {
-      if (f->vernauxs[i] == 0)
+    for (unsigned i = 0; i != f->verneedInfo.size(); ++i) {
+      if (f->verneedInfo[i].id == 0)
         continue;
+      // Each Verdef has one or more Verdaux entries. The first Verdaux gives
+      // the version name; subsequent entries (if any) are parent versions
+      // (e.g., v2 {} v1;). We only use the first one, as parent versions have
+      // not rtld behavior difference in practice.
----------------
smithp35 wrote:

typo not -> no
```
// no rtldb behavior difference in practice.
```

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


More information about the llvm-commits mailing list