[PATCH] D24363: [ELF] Fix DT_NEEDED value

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 13:02:28 PDT 2016


davide created this revision.
davide added a reviewer: ruiu.
davide added a subscriber: llvm-commits.

The absolute path value might not exist at runtime.
To quote Eric Van Gyzen who reported the bug:

```
18:52 < vangyzen> That path is a build area on the build host.
18:53 < vangyzen> e.g. /build/product/X.Y.Z/lib/libfoo.so
18:54 < vangyzen> On the running product, it's simply /lib.
```

https://llvm.org/bugs/show_bug.cgi?id=30330

https://reviews.llvm.org/D24363

Files:
  ELF/OutputSections.cpp
  test/ELF/as-needed-no-reloc.s
  test/ELF/shared.s

Index: test/ELF/shared.s
===================================================================
--- test/ELF/shared.s
+++ test/ELF/shared.s
@@ -119,7 +119,7 @@
 // CHECK-NEXT:   EntrySize: 8
 // CHECK-NEXT:   SectionData (
 // CHECK:        )
-// CHECK-NEXT: }
+// CHECK: }
 
 // CHECK:      Name: .symtab
 // CHECK-NEXT: Type: SHT_SYMTAB
Index: test/ELF/as-needed-no-reloc.s
===================================================================
--- test/ELF/as-needed-no-reloc.s
+++ test/ELF/as-needed-no-reloc.s
@@ -16,7 +16,7 @@
 # CHECK-NEXT: Other: 0
 # CHECK-NEXT: Section: Undefined
 
-# CHECK: NEEDED SharedLibrary ({{.*}}2.so)
+# CHECK: NEEDED SharedLibrary (as-needed-no-reloc{{.*}}2.so)
 
         .globl _start
 _start:
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -18,8 +18,9 @@
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/Support/SHA1.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/RandomNumberGenerator.h"
+#include "llvm/Support/SHA1.h"
 
 using namespace llvm;
 using namespace llvm::dwarf;
@@ -685,7 +686,8 @@
   for (const std::unique_ptr<SharedFile<ELFT>> &F :
        Symtab<ELFT>::X->getSharedFiles())
     if (F->isNeeded())
-      Add({DT_NEEDED, Out<ELFT>::DynStrTab->addString(F->getSoName())});
+      Add({DT_NEEDED, Out<ELFT>::DynStrTab->addString(
+                          sys::path::filename(F->getSoName()))});
   if (!Config->SoName.empty())
     Add({DT_SONAME, Out<ELFT>::DynStrTab->addString(Config->SoName)});
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24363.70745.patch
Type: text/x-patch
Size: 1642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160908/bd329c3c/attachment.bin>


More information about the llvm-commits mailing list