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> &F : Symtab::X->getSharedFiles()) if (F->isNeeded()) - Add({DT_NEEDED, Out::DynStrTab->addString(F->getSoName())}); + Add({DT_NEEDED, Out::DynStrTab->addString( + sys::path::filename(F->getSoName()))}); if (!Config->SoName.empty()) Add({DT_SONAME, Out::DynStrTab->addString(Config->SoName)}); 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: 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