[lld] r175208 - [Core, Driver, ELF] Differentiate static and dynamic executables.
Michael J. Spencer
bigcheesegs at gmail.com
Thu Feb 14 12:32:00 PST 2013
Author: mspencer
Date: Thu Feb 14 14:32:00 2013
New Revision: 175208
URL: http://llvm.org/viewvc/llvm-project?rev=175208&view=rev
Log:
[Core,Driver,ELF] Differentiate static and dynamic executables.
This also adds a simple relocation change for dynamic executables to
x86-64 ELF.
Modified:
lld/trunk/include/lld/Core/LinkerOptions.h
lld/trunk/lib/Driver/CoreOptions.td
lld/trunk/lib/Driver/Drivers.cpp
lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h
lld/trunk/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
lld/trunk/lib/ReaderWriter/MachO/MachOTargetInfo.cpp
lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp
lld/trunk/test/Driver/lib-search.test
lld/trunk/test/elf/common.test
lld/trunk/test/elf/dynamic-library.test
lld/trunk/test/elf/gotpcrel.test
lld/trunk/test/elf/ifunc.test
lld/trunk/test/elf/init_array.test
lld/trunk/test/elf/phdr.objtxt
lld/trunk/test/elf/rodata.test
lld/trunk/test/elf/tls.test
lld/trunk/test/elf/x86_64-kinds.test
lld/trunk/tools/lld-core/lld-core.cpp
Modified: lld/trunk/include/lld/Core/LinkerOptions.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkerOptions.h?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkerOptions.h (original)
+++ lld/trunk/include/lld/Core/LinkerOptions.h Thu Feb 14 14:32:00 2013
@@ -83,7 +83,9 @@ private:
};
enum OutputKind {
- Executable,
+ Invalid,
+ StaticExecutable,
+ DynamicExecutable,
Relocatable,
Shared,
SharedStubs,
@@ -96,7 +98,7 @@ enum OutputKind {
struct LinkerOptions {
LinkerOptions()
: _baseAddress(0)
- , _outputKind(OutputKind::Executable)
+ , _outputKind(OutputKind::Invalid)
, _outputCommands(false)
, _outputYAML(false)
, _noInhibitExec(true)
Modified: lld/trunk/lib/Driver/CoreOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CoreOptions.td?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CoreOptions.td (original)
+++ lld/trunk/lib/Driver/CoreOptions.td Thu Feb 14 14:32:00 2013
@@ -8,6 +8,7 @@ def mllvm : Separate<["-"], "mllvm">, He
def output : Joined<["-"], "output=">;
def entry : Joined<["-"], "entry=">;
def input_search_path : Joined<["-"], "input-search-path=">;
+def output_type : Joined<["-"], "output-type=">;
def relocatable : Flag<["-"], "relocatable">;
def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
Modified: lld/trunk/lib/Driver/Drivers.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Drivers.cpp?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Drivers.cpp (original)
+++ lld/trunk/lib/Driver/Drivers.cpp Thu Feb 14 14:32:00 2013
@@ -254,6 +254,19 @@ LinkerOptions lld::generateOptions(const
ret._input.push_back(LinkerInput((*it)->getValue()));
}
+ StringRef outputType = args.getLastArgValue(core::OPT_output_type);
+ ret._outputKind = llvm::StringSwitch<OutputKind>(outputType)
+ .Case("static", OutputKind::StaticExecutable)
+ .Case("dynamic", OutputKind::DynamicExecutable)
+ .Case("relocatable", OutputKind::Relocatable)
+ .Case("shared", OutputKind::Shared)
+ .Case("stubs", OutputKind::SharedStubs)
+ .Case("core", OutputKind::Core)
+ .Case("debug-symbols", OutputKind::DebugSymbols)
+ .Case("bundle", OutputKind::Bundle)
+ .Case("preload", OutputKind::Preload)
+ .Default(OutputKind::Invalid);
+
ret._inputSearchPaths = args.getAllArgValues(core::OPT_input_search_path);
ret._llvmArgs = args.getAllArgValues(core::OPT_mllvm);
ret._target = llvm::Triple::normalize(args.getLastArgValue(core::OPT_target));
Modified: lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h Thu Feb 14 14:32:00 2013
@@ -119,8 +119,9 @@ private:
StringRef _soname;
struct SymAtomPair {
- const typename llvm::object::ELFObjectFile<ELFT>::Elf_Sym *_symbol;
- const SharedLibraryAtom *_atom;
+ const typename llvm::object::ELFObjectFile<ELFT>::Elf_Sym *_symbol =
+ nullptr;
+ const SharedLibraryAtom *_atom = nullptr;
};
mutable std::unordered_map<StringRef, SymAtomPair> _nameToSym;
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFTargetInfo.cpp?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFTargetInfo.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFTargetInfo.cpp Thu Feb 14 14:32:00 2013
@@ -23,7 +23,8 @@ ELFTargetInfo::ELFTargetInfo(const Linke
uint16_t ELFTargetInfo::getOutputType() const {
switch (_options._outputKind) {
- case OutputKind::Executable:
+ case OutputKind::StaticExecutable:
+ case OutputKind::DynamicExecutable:
return llvm::ELF::ET_EXEC;
case OutputKind::Relocatable:
return llvm::ELF::ET_REL;
@@ -36,6 +37,8 @@ uint16_t ELFTargetInfo::getOutputType()
case OutputKind::Bundle:
case OutputKind::Preload:
break;
+ case OutputKind::Invalid:
+ llvm_unreachable("Invalid output kind!");
}
llvm_unreachable("Unhandled OutputKind");
}
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp Thu Feb 14 14:32:00 2013
@@ -118,67 +118,46 @@ public:
/// \brief Create GOT and PLT entries for relocations. Handles standard GOT/PLT
/// along with IFUNC and TLS.
-///
-/// This currently assumes a static relocation model. Meaning GOT and PLT
-/// entries are not created for references that can be directly resolved. These
-/// are converted to a direct relocation. For entries that do require a GOT or
-/// PLT entry, that entry is statically bound.
-///
-/// TLS always assumes module 1 and attempts to remove indirection.
-class GOTPLTPass LLVM_FINAL : public Pass {
+template <class Derived> class GOTPLTPass : public Pass {
/// \brief Handle a specific reference.
- ///
- /// There are multiple different types of references and just the reference
- /// kind is not enough to know if a got entry has to be created. We have the
- /// following non-standard cases:
- /// Relocation -> target type
- /// R_X86_64_PC32 -> typeResover = a call to an IFUNC function. Needs PLT.
void handleReference(const DefinedAtom &atom, const Reference &ref) {
const DefinedAtom *da = dyn_cast_or_null<const DefinedAtom>(ref.target());
switch (ref.kind()) {
case R_X86_64_PLT32:
- // __tls_get_addr is handled elsewhere.
- if (ref.target() && ref.target()->name() == "__tls_get_addr") {
- const_cast<Reference &>(ref).setKind(R_X86_64_NONE);
- break;
- }
- else
- // Static code doesn't need PLTs.
- const_cast<Reference &>(ref).setKind(R_X86_64_PC32);
- // Fall through.
- case R_X86_64_PC32: // IFUNC
- if (da && da->contentType() == DefinedAtom::typeResolver)
- handlePC32IFUNC(ref, *da);
+ static_cast<Derived *>(this)->handlePLT32(ref);
+ break;
+ case R_X86_64_PC32:
+ static_cast<Derived *>(this)->handleIFUNC(ref, da);
break;
case R_X86_64_GOTTPOFF: // GOT Thread Pointer Offset
- if (da)
- handleGOTTPOFF(ref, *da);
+ static_cast<Derived *>(this)->handleGOTTPOFF(ref, da);
break;
case R_X86_64_GOTPCREL:
- handleGOTPCREL(ref);
+ static_cast<Derived *>(this)->handleGOTPCREL(ref);
break;
}
}
+protected:
/// \brief get the PLT entry for a given IFUNC Atom.
///
/// If the entry does not exist. Both the GOT and PLT entry is created.
- const PLTAtom *getIFUNCPLTEntry(const DefinedAtom &da) {
- auto plt = _pltMap.find(&da);
+ const PLTAtom *getIFUNCPLTEntry(const DefinedAtom *da) {
+ auto plt = _pltMap.find(da);
if (plt != _pltMap.end())
return plt->second;
auto ga = new (_file._alloc) GOTAtom(_file, ".got.plt");
- ga->addReference(R_X86_64_IRELATIVE, 0, &da, 0);
+ ga->addReference(R_X86_64_IRELATIVE, 0, da, 0);
auto pa = new (_file._alloc) PLTAtom(_file, ".plt");
pa->addReference(R_X86_64_PC32, 2, ga, -4);
#ifndef NDEBUG
ga->_name = "__got_ifunc_";
- ga->_name += da.name();
+ ga->_name += da->name();
pa->_name = "__plt_ifunc_";
- pa->_name += da.name();
+ pa->_name += da->name();
#endif
- _gotMap[&da] = ga;
- _pltMap[&da] = pa;
+ _gotMap[da] = ga;
+ _pltMap[da] = pa;
return pa;
}
@@ -186,21 +165,23 @@ class GOTPLTPass LLVM_FINAL : public Pas
///
/// This create a PLT and GOT entry for the IFUNC if one does not exist. The
/// GOT entry and a IRELATIVE relocation to the original target resolver.
- void handlePC32IFUNC(const Reference &ref, const DefinedAtom &target) {
- const_cast<Reference &>(ref).setTarget(getIFUNCPLTEntry(target));
+ ErrorOr<void> handleIFUNC(const Reference &ref, const DefinedAtom *target) {
+ if (target && target->contentType() == DefinedAtom::typeResolver)
+ const_cast<Reference &>(ref).setTarget(getIFUNCPLTEntry(target));
+ return error_code::success();
}
/// \brief Create a GOT entry for the TP offset of a TLS atom.
- const GOTAtom *getGOTTPOFF(const DefinedAtom &atom) {
- auto got = _gotMap.find(&atom);
+ const GOTAtom *getGOTTPOFF(const DefinedAtom *atom) {
+ auto got = _gotMap.find(atom);
if (got == _gotMap.end()) {
auto g = new (_file._alloc) GOTAtom(_file, ".got");
- g->addReference(R_X86_64_TPOFF64, 0, &atom, 0);
+ g->addReference(R_X86_64_TPOFF64, 0, atom, 0);
#ifndef NDEBUG
g->_name = "__got_tls_";
- g->_name += atom.name();
+ g->_name += atom->name();
#endif
- _gotMap[&atom] = g;
+ _gotMap[atom] = g;
return g;
}
return got->second;
@@ -208,7 +189,7 @@ class GOTPLTPass LLVM_FINAL : public Pas
/// \brief Create a TPOFF64 GOT entry and change the relocation to a PC32 to
/// the GOT.
- void handleGOTTPOFF(const Reference &ref, const DefinedAtom &target) {
+ void handleGOTTPOFF(const Reference &ref, const DefinedAtom *target) {
const_cast<Reference &>(ref).setTarget(getGOTTPOFF(target));
const_cast<Reference &>(ref).setKind(R_X86_64_PC32);
}
@@ -224,16 +205,16 @@ class GOTPLTPass LLVM_FINAL : public Pas
return _null;
}
- const GOTAtom *getGOT(const DefinedAtom &da) {
- auto got = _gotMap.find(&da);
+ const GOTAtom *getGOT(const DefinedAtom *da) {
+ auto got = _gotMap.find(da);
if (got == _gotMap.end()) {
auto g = new (_file._alloc) GOTAtom(_file, ".got");
- g->addReference(R_X86_64_64, 0, &da, 0);
+ g->addReference(R_X86_64_64, 0, da, 0);
#ifndef NDEBUG
g->_name = "__got_";
- g->_name += da.name();
+ g->_name += da->name();
#endif
- _gotMap[&da] = g;
+ _gotMap[da] = g;
return g;
}
return got->second;
@@ -246,7 +227,7 @@ class GOTPLTPass LLVM_FINAL : public Pas
if (isa<UndefinedAtom>(ref.target()))
const_cast<Reference &>(ref).setTarget(getNullGOT());
else if (const DefinedAtom *da = dyn_cast<const DefinedAtom>(ref.target()))
- const_cast<Reference &>(ref).setTarget(getGOT(*da));
+ const_cast<Reference &>(ref).setTarget(getGOT(da));
}
public:
@@ -275,20 +256,85 @@ public:
mf.addAtom(*plt.second);
}
-private:
+protected:
/// \brief Owner of all the Atoms created by this pass.
ELFPassFile _file;
/// \brief Map Atoms to their GOT entries.
- llvm::DenseMap<const DefinedAtom *, const GOTAtom *> _gotMap;
+ llvm::DenseMap<const Atom *, const GOTAtom *> _gotMap;
/// \brief Map Atoms to their PLT entries.
- llvm::DenseMap<const DefinedAtom *, const PLTAtom *> _pltMap;
+ llvm::DenseMap<const Atom *, const PLTAtom *> _pltMap;
/// \brief GOT entry that is always 0. Used for undefined weaks.
GOTAtom *_null;
};
+
+/// This implements the static relocation model. Meaning GOT and PLT entries are
+/// not created for references that can be directly resolved. These are
+/// converted to a direct relocation. For entries that do require a GOT or PLT
+/// entry, that entry is statically bound.
+///
+/// TLS always assumes module 1 and attempts to remove indirection.
+class StaticGOTPLTPass LLVM_FINAL : public GOTPLTPass<StaticGOTPLTPass> {
+public:
+ StaticGOTPLTPass(const elf::X86_64TargetInfo &ti) : GOTPLTPass(ti) {}
+
+ ErrorOr<void> handlePLT32(const Reference &ref) {
+ // __tls_get_addr is handled elsewhere.
+ if (ref.target() && ref.target()->name() == "__tls_get_addr") {
+ const_cast<Reference &>(ref).setKind(R_X86_64_NONE);
+ return error_code::success();
+ } else
+ // Static code doesn't need PLTs.
+ const_cast<Reference &>(ref).setKind(R_X86_64_PC32);
+ // Handle IFUNC.
+ if (const DefinedAtom *da = dyn_cast_or_null<const DefinedAtom>(ref.target()))
+ if (da->contentType() == DefinedAtom::typeResolver)
+ return handleIFUNC(ref, da);
+ return error_code::success();
+ }
+};
+
+class DynamicGOTPLTPass LLVM_FINAL : public GOTPLTPass<DynamicGOTPLTPass> {
+public:
+ DynamicGOTPLTPass(const elf::X86_64TargetInfo &ti) : GOTPLTPass(ti) {}
+
+ const PLTAtom *getPLTEntry(const Atom *a) {
+ auto plt = _pltMap.find(a);
+ if (plt != _pltMap.end())
+ return plt->second;
+ auto ga = new (_file._alloc) GOTAtom(_file, ".got.plt");
+ ga->addReference(R_X86_64_RELATIVE, 0, a, 0);
+ auto pa = new (_file._alloc) PLTAtom(_file, ".plt");
+ pa->addReference(R_X86_64_PC32, 2, ga, -4);
+#ifndef NDEBUG
+ ga->_name = "__got_";
+ ga->_name += a->name();
+ pa->_name = "__plt_";
+ pa->_name += a->name();
+#endif
+ _gotMap[a] = ga;
+ _pltMap[a] = pa;
+ return pa;
+ }
+
+ ErrorOr<void> handlePLT32(const Reference &ref) {
+ // Turn this into a PC32 to the PLT entry.
+ const_cast<Reference &>(ref).setKind(R_X86_64_PC32);
+ // Handle IFUNC.
+ if (const DefinedAtom *da = dyn_cast_or_null<const DefinedAtom>(ref.target()))
+ if (da->contentType() == DefinedAtom::typeResolver)
+ return handleIFUNC(ref, da);
+ const_cast<Reference &>(ref).setTarget(getPLTEntry(ref.target()));
+ return error_code::success();
+ }
+};
} // end anon namespace
void elf::X86_64TargetInfo::addPasses(PassManager &pm) const {
- pm.add(std::unique_ptr<Pass>(new GOTPLTPass(*this)));
+ if (_options._outputKind == OutputKind::StaticExecutable)
+ pm.add(std::unique_ptr<Pass>(new StaticGOTPLTPass(*this)));
+ else if (_options._outputKind == OutputKind::DynamicExecutable ||
+ _options._outputKind == OutputKind::Shared)
+ pm.add(std::unique_ptr<Pass>(new DynamicGOTPLTPass(*this)));
}
#define LLD_CASE(name) .Case(#name, llvm::ELF::name)
Modified: lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp Thu Feb 14 14:32:00 2013
@@ -31,7 +31,8 @@ public:
CRuntimeFile(const MachOTargetInfo &ti)
: SimpleFile(ti, "C runtime"), _undefMain(*this, "_main") {
// only main executables need _main
- if (ti.getLinkerOptions()._outputKind == OutputKind::Executable)
+ if (ti.getLinkerOptions()._outputKind == OutputKind::StaticExecutable ||
+ ti.getLinkerOptions()._outputKind == OutputKind::DynamicExecutable)
this->addAtom(_undefMain);
}
Modified: lld/trunk/lib/ReaderWriter/MachO/MachOTargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOTargetInfo.cpp?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOTargetInfo.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOTargetInfo.cpp Thu Feb 14 14:32:00 2013
@@ -47,7 +47,8 @@ uint32_t MachOTargetInfo::getCPUSubType(
bool MachOTargetInfo::addEntryPointLoadCommand() const {
switch (_options._outputKind) {
- case OutputKind::Executable:
+ case OutputKind::StaticExecutable:
+ case OutputKind::DynamicExecutable:
return true;
default:
return false;
@@ -56,7 +57,8 @@ bool MachOTargetInfo::addEntryPointLoadC
bool MachOTargetInfo::addUnixThreadLoadCommand() const {
switch (_options._outputKind) {
- case OutputKind::Executable:
+ case OutputKind::StaticExecutable:
+ case OutputKind::DynamicExecutable:
return true;
default:
return false;
Modified: lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp Thu Feb 14 14:32:00 2013
@@ -640,7 +640,8 @@ uint32_t MachHeaderChunk::magic(uint32_t
uint32_t MachHeaderChunk::filetype(OutputKind kind) {
switch ( kind ) {
- case OutputKind::Executable:
+ case OutputKind::StaticExecutable:
+ case OutputKind::DynamicExecutable:
return MH_EXECUTE;
case OutputKind::Relocatable:
return MH_OBJECT;
@@ -654,6 +655,8 @@ uint32_t MachHeaderChunk::filetype(Outpu
case OutputKind::DebugSymbols:
case OutputKind::Core:
break;
+ case OutputKind::Invalid:
+ llvm_unreachable("Invalid output kind!");
}
llvm_unreachable("file OutputKind not supported");
return 0;
@@ -1390,7 +1393,9 @@ void MachOWriter::buildAtomToAddressMap(
DEBUG_WITH_TYPE("WriterMachO-layout", llvm::dbgs()
<< "assign atom addresses:\n");
const bool lookForEntry = _targetInfo.getLinkerOptions()._outputKind ==
- OutputKind::Executable;
+ OutputKind::StaticExecutable ||
+ _targetInfo.getLinkerOptions()._outputKind ==
+ OutputKind::DynamicExecutable;
for (SectionChunk *chunk : _sectionChunks ) {
for (const SectionChunk::AtomInfo &info : chunk->atoms() ) {
_atomToAddress[info.atom] = chunk->address() + info.offsetInSection;
Modified: lld/trunk/test/Driver/lib-search.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/Driver/lib-search.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/Driver/lib-search.test (original)
+++ lld/trunk/test/Driver/lib-search.test Thu Feb 14 14:32:00 2013
@@ -3,4 +3,4 @@ RUN: | FileCheck %s
CHECK: -input-search-path={{[^ ]+}}elf/Inputs
CHECK: b.o
-CHECK: {{[^ ]+}}elf/Inputs/libfnarchive.a
+CHECK: {{[^ ]+}}elf/Inputs{{[\\/]}}libfnarchive.a
Modified: lld/trunk/test/elf/common.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/common.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/common.test (original)
+++ lld/trunk/test/elf/common.test Thu Feb 14 14:32:00 2013
@@ -1,4 +1,5 @@
-RUN: lld -flavor ld -target x86_64-linux -o %t %p/Inputs/relocs.x86-64 \
-RUN: && llvm-readobj %t | FileCheck %s
+RUN: lld -core -target x86_64-linux -output=%t %p/Inputs/relocs.x86-64 \
+RUN: -output-type=static
+RUN: llvm-readobj %t | FileCheck %s
CHECK: i DATA
Modified: lld/trunk/test/elf/dynamic-library.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/dynamic-library.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/dynamic-library.test (original)
+++ lld/trunk/test/elf/dynamic-library.test Thu Feb 14 14:32:00 2013
@@ -1,7 +1,18 @@
RUN: lld -core -target x86_64-linux %p/Inputs/use-shared.x86-64 \
RUN: %p/Inputs/shared.so-x86-64 -emit-yaml -output=- -noinhibit-exec \
+RUN: -output-type=dynamic \
RUN: | FileCheck %s
+CHECK: name: main
+CHECK: kind: R_X86_64_PC32
+CHECK: target: [[PLTNAME:[-a-zA-Z0-9_]+]]
+
+CHECK: type: got
+CHECK: R_X86_64_RELATIVE
+
+CHECK: name: [[PLTNAME]]
+CHECK: type: stub
+
CHECK: shared-library-atoms:
CHECK: name: foo
CHECK: load-name: shared.so-x86-64
Modified: lld/trunk/test/elf/gotpcrel.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/gotpcrel.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/gotpcrel.test (original)
+++ lld/trunk/test/elf/gotpcrel.test Thu Feb 14 14:32:00 2013
@@ -1,4 +1,4 @@
-RUN: lld -core -target x86_64-linux -output=- -entry=main \
+RUN: lld -core -target x86_64-linux -output=- -entry=main -output-type=static \
RUN: %p/Inputs/gotpcrel.x86-64 -emit-yaml -noinhibit-exec \
RUN: | FileCheck %s -check-prefix=YAML
Modified: lld/trunk/test/elf/ifunc.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/ifunc.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/ifunc.test (original)
+++ lld/trunk/test/elf/ifunc.test Thu Feb 14 14:32:00 2013
@@ -1,13 +1,13 @@
-RUN: lld -core -target x86_64-linux -emit-yaml -output=- \
+RUN: lld -core -target x86_64-linux -emit-yaml -output=- -output-type=static \
RUN: %p/Inputs/ifunc.x86-64 -noinhibit-exec | FileCheck %s
-RUN: lld -core -target x86_64-linux -emit-yaml -output=- \
+RUN: lld -core -target x86_64-linux -emit-yaml -output=- -output-type=static \
RUN: %p/Inputs/ifunc.x86-64 -noinhibit-exec %p/Inputs/ifunc.cpp.x86-64 \
RUN: | FileCheck %s --check-prefix=PLT
-RUN: lld -core -target x86_64-linux -output=%t %p/Inputs/ifunc.x86-64 -entry=main \
-RUN: %p/Inputs/ifunc.cpp.x86-64 && llvm-objdump -d -s %t| FileCheck %s \
-RUN: --check-prefix=BIN
+RUN: lld -core -target x86_64-linux -output=%t %p/Inputs/ifunc.x86-64 \
+RUN: -entry=main -output-type=static %p/Inputs/ifunc.cpp.x86-64 \
+RUN: && llvm-objdump -d -s %t| FileCheck %s --check-prefix=BIN
CHECK: name: hey
CHECK: scope: global
Modified: lld/trunk/test/elf/init_array.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/init_array.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/init_array.test (original)
+++ lld/trunk/test/elf/init_array.test Thu Feb 14 14:32:00 2013
@@ -1,4 +1,5 @@
-RUN: lld -flavor ld -target x86_64-linux -o %t %p/Inputs/init_array.x86-64
+RUN: lld -core -target x86_64-linux -output=%t %p/Inputs/init_array.x86-64 \
+RUN: -output-type=static
RUN: llvm-objdump -t -section-headers %t | FileCheck %s
CHECK: .init_array {{[0-9]+}} [[ADDR:[0-9]+]]
Modified: lld/trunk/test/elf/phdr.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/phdr.objtxt?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/phdr.objtxt (original)
+++ lld/trunk/test/elf/phdr.objtxt Thu Feb 14 14:32:00 2013
@@ -1,7 +1,8 @@
RUN: lld-core -reader ELF -writer ELF -o %t1 %p/Inputs/phdr.i386 | elf-dump %t1 | FileCheck -check-prefix=ED %s
RUN: lld -core -target x86_64-linux -output=%t1 %p/Inputs/relocs.x86-64 \
-RUN: && llvm-objdump -p %t1 | FileCheck %s -check-prefix=X86_64
+RUN: -output-type=static && llvm-objdump -p %t1 \
+RUN: | FileCheck %s -check-prefix=X86_64
ED: (('p_type', 0x00000001)
Modified: lld/trunk/test/elf/rodata.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/rodata.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/rodata.test (original)
+++ lld/trunk/test/elf/rodata.test Thu Feb 14 14:32:00 2013
@@ -1,4 +1,5 @@
-RUN: lld -flavor ld -target x86_64-linux -o %t %p/Inputs/constdata.x86-64
+RUN: lld -core -target x86_64-linux -output=%t %p/Inputs/constdata.x86-64 \
+RUN: -output-type=static
RUN: llvm-objdump -s %t | FileCheck %s
CHECK: Hellooooooooo
Modified: lld/trunk/test/elf/tls.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/tls.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/tls.test (original)
+++ lld/trunk/test/elf/tls.test Thu Feb 14 14:32:00 2013
@@ -1,8 +1,10 @@
RUN: lld -core -target x86_64-linux %p/Inputs/tls.x86-64 -output=- \
-RUN: -noinhibit-exec -entry=main -emit-yaml | FileCheck %s -check-prefix=YAML
+RUN: -noinhibit-exec -entry=main -emit-yaml -output-type=static \
+RUN: | FileCheck %s -check-prefix=YAML
RUN: lld -core -target x86_64-linux %p/Inputs/tls.x86-64 -output=%t \
-RUN: -noinhibit-exec -entry=main && llvm-objdump -d %t | FileCheck %s
+RUN: -noinhibit-exec -entry=main -output-type=static && llvm-objdump -d %t \
+RUN: | FileCheck %s
// Verify that the TLS accesses have the correct offsets.
Modified: lld/trunk/test/elf/x86_64-kinds.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/x86_64-kinds.test?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/test/elf/x86_64-kinds.test (original)
+++ lld/trunk/test/elf/x86_64-kinds.test Thu Feb 14 14:32:00 2013
@@ -1,7 +1,8 @@
-RUN: lld -flavor ld -target x86_64-linux -o %t1 %p/Inputs/relocs.x86-64 \
-RUN: && llvm-objdump -d %t1 | FileCheck %s -check-prefix=RELOCS
+RUN: lld -core -target x86_64-linux -output=%t1 %p/Inputs/relocs.x86-64 \
+RUN: -output-type=static
+RUN: llvm-objdump -d %t1 | FileCheck %s -check-prefix=RELOCS
-RUN: lld -core -target x86_64-linux -output=- -emit-yaml \
+RUN: lld -core -target x86_64-linux -output=- -emit-yaml -output-type=static \
RUN: %p/Inputs/relocs.x86-64 | FileCheck %s -check-prefix=X86_64
RELOCS: ELF64-x86-64
Modified: lld/trunk/tools/lld-core/lld-core.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld-core/lld-core.cpp?rev=175208&r1=175207&r2=175208&view=diff
==============================================================================
--- lld/trunk/tools/lld-core/lld-core.cpp (original)
+++ lld/trunk/tools/lld-core/lld-core.cpp Thu Feb 14 14:32:00 2013
@@ -233,7 +233,7 @@ int main(int argc, char *argv[]) {
lo._deadStrip = cmdLineDeadStrip;
lo._globalsAreDeadStripRoots = cmdLineGlobalsNotDeadStrip;
lo._forceLoadArchives = cmdLineForceLoad;
- lo._outputKind = OutputKind::Executable;
+ lo._outputKind = OutputKind::StaticExecutable;
lo._entrySymbol = cmdLineEntryPoint;
lo._mergeCommonStrings = cmdLineDoMergeStrings;
More information about the llvm-commits
mailing list