[lld] [LLD] dtNeeded name should consistent with soNames (PR #72857)

Longsheng Mou via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 04:04:07 PST 2023


https://github.com/CoTinker updated https://github.com/llvm/llvm-project/pull/72857

>From 544ba9f45aa2d95466c3f255c65f9964859567b0 Mon Sep 17 00:00:00 2001
From: Longsheng Mou <moulongsheng at huawei.com>
Date: Mon, 20 Nov 2023 19:43:42 +0800
Subject: [PATCH] [LLD] dtNeeded name should consistent with soNames

If dtNeeded name is inconsistent with soNames, lld can not report error right.
---
 lld/ELF/InputFiles.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 7ac737dab0519a8..75dfa40eb7068f9 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1439,7 +1439,7 @@ template <class ELFT> void SharedFile::parse() {
       uint64_t val = dyn.getVal();
       if (val >= this->stringTable.size())
         fatal(toString(this) + ": invalid DT_NEEDED entry");
-      dtNeeded.push_back(this->stringTable.data() + val);
+      dtNeeded.push_back(path::filename(this->stringTable.data() + val));
     } else if (dyn.d_tag == DT_SONAME) {
       uint64_t val = dyn.getVal();
       if (val >= this->stringTable.size())
@@ -1451,8 +1451,8 @@ template <class ELFT> void SharedFile::parse() {
   // DSOs are uniquified not by filename but by soname.
   DenseMap<CachedHashStringRef, SharedFile *>::iterator it;
   bool wasInserted;
-  std::tie(it, wasInserted) =
-      symtab.soNames.try_emplace(CachedHashStringRef(soName), this);
+  std::tie(it, wasInserted) = symtab.soNames.try_emplace(
+      CachedHashStringRef(path::filename(soName)), this);
 
   // If a DSO appears more than once on the command line with and without
   // --as-needed, --no-as-needed takes precedence over --as-needed because a



More information about the llvm-commits mailing list