[lld] r190758 - Output soname.
Joerg Sonnenberger
joerg at bec.de
Sat Sep 14 12:53:52 PDT 2013
Author: joerg
Date: Sat Sep 14 14:53:51 2013
New Revision: 190758
URL: http://llvm.org/viewvc/llvm-project?rev=190758&view=rev
Log:
Output soname.
Added:
lld/trunk/test/elf/soname.test
Modified:
lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=190758&r1=190757&r2=190758&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Sat Sep 14 14:53:51 2013
@@ -176,6 +176,12 @@ public:
/// linker command line, using the -fini option.
range<const StringRef *> finiFunctions() const { return _finiFunctions; }
+ void setSharedObjectName(StringRef soname) {
+ _soname = soname;
+ }
+
+ StringRef sharedObjectName() const { return _soname; }
+
/// \brief Set path to the system root
void setSysroot(StringRef path) {
_sysrootPath = path;
@@ -230,6 +236,7 @@ protected:
StringRefVector _initFunctions;
StringRefVector _finiFunctions;
StringRef _sysrootPath;
+ StringRef _soname;
StringRefVector _rpathList;
StringRefVector _rpathLinkList;
};
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=190758&r1=190757&r2=190758&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Sat Sep 14 14:53:51 2013
@@ -322,6 +322,10 @@ bool GnuLdDriver::parse(int argc, const
ctx->setSysroot(inputArg->getValue());
break;
+ case OPT_soname:
+ ctx->setSharedObjectName(inputArg->getValue());
+ break;
+
default:
break;
} // end switch on option ID
Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=190758&r1=190757&r2=190758&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h Sat Sep 14 14:53:51 2013
@@ -169,6 +169,13 @@ void OutputELFWriter<ELFT>::buildDynamic
dyn.d_un.d_val = _dynamicStringTable->addString(*rpath);
_dynamicTable->addEntry(dyn);
}
+ StringRef soname = _context.sharedObjectName();
+ if (!soname.empty() && _context.getOutputType() == llvm::ELF::ET_DYN) {
+ Elf_Dyn dyn;
+ dyn.d_tag = DT_SONAME;
+ dyn.d_un.d_val = _dynamicStringTable->addString(soname);
+ _dynamicTable->addEntry(dyn);
+ }
// The dynamic symbol table need to be sorted earlier because the hash
// table needs to be built using the dynamic symbol table. It would be
// late to sort the symbols due to that in finalize. In the dynamic symbol
Added: lld/trunk/test/elf/soname.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/soname.test?rev=190758&view=auto
==============================================================================
--- lld/trunk/test/elf/soname.test (added)
+++ lld/trunk/test/elf/soname.test Sat Sep 14 14:53:51 2013
@@ -0,0 +1,6 @@
+RUN: lld -flavor gnu -shared -target i386 -e main %p/Inputs/writersyms.o \
+RUN: -o %t -soname libtest.so
+RUN: llvm-readobj -dynamic-table %t | FileCheck %s
+
+CHECK: LoadName: libtest.so
+CHECK: 0x0000000E SONAME LibrarySoname (libtest.so)
More information about the llvm-commits
mailing list