<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Shankar,<div>This is causing a test failure on one of our internal buildbots.</div><div><br></div><div><pre style="font-family: 'Courier New', courier, monotype;"><span class="stdout">******************** TEST 'LLVM :: Object/coff-archive.test' FAILED ********************Script:
--
Release+Asserts/bin/llvm-nm -s llvm/test/Object/Inputs/coff_archive.lib | Release+Asserts/bin/FileCheck -check-prefix=CHECKIDX llvm/test/Object/coff-archive.test
--
Exit Code: 1
Command Output (stderr):
--
llvm/test/Object/coff-archive.test:159:11: error: expected string not found in input
CHECKIDX: U ??_Glogic_error@std@@UAEPAXI@Z
^
<stdin>:156:1: note: scanning from here
00000000 D ??_R0?AVexception@std@@@8
^
<stdin>:173:10: note: possible intended match here
00000000 R ??_R4logic_error@std@@6B@
^
--
********************</span></pre><div>Regards,</div></div><div> Chad</div><div><br><div><div>On Nov 13, 2012, at 10:39 AM, Shankar Easwaran <<a href="mailto:shankare@codeaurora.org">shankare@codeaurora.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Author: shankare<br>Date: Tue Nov 13 12:39:10 2012<br>New Revision: 167854<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=167854&view=rev">http://llvm.org/viewvc/llvm-project?rev=167854&view=rev</a><br>Log:<br>Adding support to resolve symbols with archive libraries in lld<br><br>Added:<br> lld/trunk/include/lld/ReaderWriter/ReaderArchive.h<br> lld/trunk/lib/ReaderWriter/ReaderArchive.cpp<br> lld/trunk/test/elf/Inputs/libfnarchive.x86_64 (with props)<br> lld/trunk/test/elf/Inputs/mainobj.x86_64 (with props)<br> lld/trunk/test/elf/archive-elf-forceload.objtxt<br> lld/trunk/test/elf/archive-elf.objtxt<br>Modified:<br> lld/trunk/include/lld/ReaderWriter/ReaderELF.h<br> lld/trunk/lib/ReaderWriter/CMakeLists.txt<br> lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp<br> lld/trunk/tools/lld-core/lld-core.cpp<br><br>Added: lld/trunk/include/lld/ReaderWriter/ReaderArchive.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ReaderArchive.h?rev=167854&view=auto">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ReaderArchive.h?rev=167854&view=auto</a><br>==============================================================================<br>--- lld/trunk/include/lld/ReaderWriter/ReaderArchive.h (added)<br>+++ lld/trunk/include/lld/ReaderWriter/ReaderArchive.h Tue Nov 13 12:39:10 2012<br>@@ -0,0 +1,80 @@<br>+//===- ReaderWriter/ReaderArchive.h - Archive Library Reader ------------===//<br>+//<br>+// The LLVM Linker<br>+//<br>+// This file is distributed under the University of Illinois Open Source<br>+// License. See LICENSE.TXT for details.<br>+//<br>+//===--------------------------------------------------------------------===//<br>+<br>+#ifndef LLD_READER_ARCHIVE_H<br>+#define LLD_READER_ARCHIVE_H<br>+<br>+#include "lld/Core/ArchiveLibraryFile.h"<br>+#include "llvm/Object/ObjectFile.h"<br>+#include "llvm/ADT/OwningPtr.h"<br>+#include "llvm/ADT/StringRef.h"<br>+#include "llvm/Support/MemoryBuffer.h"<br>+#include "llvm/Support/system_error.h"<br>+#include "llvm/Object/Archive.h"<br>+#include "lld/Core/File.h"<br>+#include "lld/Core/LLVM.h"<br>+#include "lld/ReaderWriter/Reader.h"<br>+#include "lld/ReaderWriter/ReaderArchive.h"<br>+#include <memory><br>+#include <bits/unique_ptr.h><br>+#include <vector><br>+<br>+namespace lld<br>+{<br>+///<br>+/// The ReaderOptionsArchive encapsulates the options used by the ReaderArchive.<br>+/// The option objects are the only way to control the behaviour of Readers.<br>+///<br>+class ReaderOptionsArchive<br>+{<br>+public:<br>+ ReaderOptionsArchive(bool is_force_load=false): _isForceLoad(is_force_load),<br>+ _reader(nullptr)<br>+ { }<br>+ <br>+ bool isForceLoad() const {<br>+ return _isForceLoad;<br>+ }<br>+ <br>+ Reader *reader() const {<br>+ return _reader;<br>+ }<br>+<br>+ void setReader(Reader *r) {<br>+ _reader = r;<br>+ }<br>+ <br>+private:<br>+ bool _isForceLoad;<br>+ Reader *_reader;<br>+};<br>+<br>+// ReaderArchive is a class for reading archive libraries<br>+class ReaderArchive final<br>+{<br>+public:<br>+ ReaderArchive(ReaderOptionsArchive &options) : _options(options),<br>+ _archive()<br>+ { }<br>+<br>+ // Returns a vector of Files that are contained in the archive file <br>+ // pointed to by the Memorybuffer<br>+ virtual error_code parseFile(std::unique_ptr<llvm::MemoryBuffer> mb,<br>+ std::vector<std::unique_ptr<File>> &result);<br>+<br>+ virtual ~ReaderArchive() { }<br>+<br>+private:<br>+ ReaderOptionsArchive &_options;<br>+ std::unique_ptr<llvm::object::Archive> _archive;<br>+};<br>+<br>+} // namespace lld<br>+<br>+#endif // LLD_READER_ARCHIVE_H<br><br>Modified: lld/trunk/include/lld/ReaderWriter/ReaderELF.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ReaderELF.h?rev=167854&r1=167853&r2=167854&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ReaderELF.h?rev=167854&r1=167853&r2=167854&view=diff</a><br>==============================================================================<br>--- lld/trunk/include/lld/ReaderWriter/ReaderELF.h (original)<br>+++ lld/trunk/include/lld/ReaderWriter/ReaderELF.h Tue Nov 13 12:39:10 2012<br>@@ -11,6 +11,7 @@<br> #define LLD_READERWRITER_READER_ELF_H_<br><br> #include "lld/ReaderWriter/Reader.h"<br>+#include "lld/ReaderWriter/ReaderArchive.h"<br> #include "lld/Core/LLVM.h"<br><br><br>@@ -56,7 +57,8 @@<br> /// ReaderOptionsELF object supplied, so the objects object must not be <br> /// destroyed before the Reader object. <br> ///<br>-Reader* createReaderELF(const ReaderOptionsELF &options);<br>+Reader* createReaderELF(const ReaderOptionsELF &options, <br>+ ReaderOptionsArchive &optionsArchive);<br><br><br><br><br>Modified: lld/trunk/lib/ReaderWriter/CMakeLists.txt<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CMakeLists.txt?rev=167854&r1=167853&r2=167854&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CMakeLists.txt?rev=167854&r1=167853&r2=167854&view=diff</a><br>==============================================================================<br>--- lld/trunk/lib/ReaderWriter/CMakeLists.txt (original)<br>+++ lld/trunk/lib/ReaderWriter/CMakeLists.txt Tue Nov 13 12:39:10 2012<br>@@ -6,4 +6,5 @@<br> add_lld_library(lldReaderWriter<br> Reader.cpp<br> Writer.cpp<br>+ ReaderArchive.cpp<br> )<br><br>Modified: lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp?rev=167854&r1=167853&r2=167854&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp?rev=167854&r1=167853&r2=167854&view=diff</a><br>==============================================================================<br>--- lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp (original)<br>+++ lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp Tue Nov 13 12:39:10 2012<br>@@ -12,9 +12,9 @@<br> //<br> //===----------------------------------------------------------------------===//<br> #include "lld/ReaderWriter/ReaderELF.h"<br>+#include "lld/ReaderWriter/ReaderArchive.h"<br> #include "lld/Core/File.h"<br> #include "lld/Core/Reference.h"<br>-<br> #include "llvm/ADT/ArrayRef.h"<br> #include "llvm/ADT/SmallString.h"<br> #include "llvm/ADT/StringRef.h"<br>@@ -30,6 +30,7 @@<br> #include "llvm/Support/MemoryBuffer.h"<br> #include "llvm/Support/raw_ostream.h"<br> #include "llvm/Support/system_error.h"<br>+#include "llvm/Support/Path.h"<br><br><br> #include <map><br>@@ -751,43 +752,72 @@<br><br> class ReaderELF: public Reader {<br> public:<br>- ReaderELF(const ReaderOptionsELF &) {}<br>+ ReaderELF(const ReaderOptionsELF &readerELFOptions,<br>+ ReaderOptionsArchive &readerOptionsArchive)<br>+ : _readerELFOptions(readerELFOptions),<br>+ _readerOptionsArchive(readerOptionsArchive),<br>+ _readerArchive(_readerOptionsArchive) { <br>+ _readerOptionsArchive.setReader(this);<br>+ }<br>+<br> error_code parseFile(std::unique_ptr<MemoryBuffer> mb, std::vector<<br>- std::unique_ptr<File> > &result) {<br>+ std::unique_ptr<File> > &result) {<br>+ llvm::error_code ec; <br>+ std::unique_ptr<File> f;<br>+ std::pair<unsigned char, unsigned char> Ident;<br><br>- std::pair<unsigned char, unsigned char> Ident =<br>- llvm::object::getElfArchType(&*mb);<br>- llvm::error_code ec;<br>- // Instantiate the correct FileELF template instance<br>- // based on the Ident pair. Once the File is created<br>- // we push the file to the vector of files already<br>- // created during parser's life.<br>+ llvm::sys::LLVMFileType fileType = <br>+ llvm::sys::IdentifyFileType(mb->getBufferStart(),<br>+ static_cast<unsigned>(mb->getBufferSize()));<br>+ switch (fileType) {<br>+<br>+ case llvm::sys::ELF_Relocatable_FileType:<br>+<br>+ Ident = llvm::object::getElfArchType(&*mb);<br>+ // Instantiate the correct FileELF template instance<br>+ // based on the Ident pair. Once the File is created<br>+ // we push the file to the vector of files already<br>+ // created during parser's life.<br>+<br>+ if (Ident.first == llvm::ELF::ELFCLASS32 && Ident.second<br>+ == llvm::ELF::ELFDATA2LSB) {<br>+ f.reset(new FileELF<llvm::support::little, false>(std::move(mb), ec));<br>+<br>+ } else if (Ident.first == llvm::ELF::ELFCLASS32 && Ident.second<br>+ == llvm::ELF::ELFDATA2MSB) {<br>+ f.reset(new FileELF<llvm::support::big, false> (std::move(mb), ec));<br>+<br>+ } else if (Ident.first == llvm::ELF::ELFCLASS64 && Ident.second<br>+ == llvm::ELF::ELFDATA2MSB) {<br>+ f.reset(new FileELF<llvm::support::big, true> (std::move(mb), ec));<br>+<br>+ } else if (Ident.first == llvm::ELF::ELFCLASS64 && Ident.second<br>+ == llvm::ELF::ELFDATA2LSB) {<br>+ f.reset(new FileELF<llvm::support::little, true> (std::move(mb), ec));<br>+ }<br>+ if (!ec)<br>+ result.push_back(std::move(f));<br>+ break;<br><br>- std::unique_ptr<File> f;<br>+ case llvm::sys::Archive_FileType:<br>+ ec = _readerArchive.parseFile(std::move(mb), result);<br>+ break;<br><br>- if (Ident.first == llvm::ELF::ELFCLASS32 && Ident.second<br>- == llvm::ELF::ELFDATA2LSB) {<br>- f.reset(new FileELF<llvm::support::little, false>(std::move(mb), ec));<br>-<br>- } else if (Ident.first == llvm::ELF::ELFCLASS32 && Ident.second<br>- == llvm::ELF::ELFDATA2MSB) {<br>- f.reset(new FileELF<llvm::support::big, false> (std::move(mb), ec));<br>-<br>- } else if (Ident.first == llvm::ELF::ELFCLASS64 && Ident.second<br>- == llvm::ELF::ELFDATA2MSB) {<br>- f.reset(new FileELF<llvm::support::big, true> (std::move(mb), ec));<br>-<br>- } else if (Ident.first == llvm::ELF::ELFCLASS64 && Ident.second<br>- == llvm::ELF::ELFDATA2LSB) {<br>- f.reset(new FileELF<llvm::support::little, true> (std::move(mb), ec));<br>+ default:<br>+ llvm_unreachable("not supported format");<br>+ break;<br> }<br><br> if (ec)<br> return ec;<br><br>- result.push_back(std::move(f));<br> return error_code::success();<br> }<br>+<br>+private:<br>+ const ReaderOptionsELF &_readerELFOptions;<br>+ ReaderOptionsArchive &_readerOptionsArchive;<br>+ ReaderArchive _readerArchive;<br> };<br><br> } // namespace anonymous<br>@@ -800,8 +830,9 @@<br> ReaderOptionsELF::~ReaderOptionsELF() {<br> }<br><br>-Reader *createReaderELF(const ReaderOptionsELF &options) {<br>- return new ReaderELF(options);<br>+Reader *createReaderELF(const ReaderOptionsELF &options,<br>+ ReaderOptionsArchive &optionsArchive) {<br>+ return new ReaderELF(options, optionsArchive);<br> }<br><br> } // namespace LLD<br><br>Added: lld/trunk/lib/ReaderWriter/ReaderArchive.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ReaderArchive.cpp?rev=167854&view=auto">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ReaderArchive.cpp?rev=167854&view=auto</a><br>==============================================================================<br>--- lld/trunk/lib/ReaderWriter/ReaderArchive.cpp (added)<br>+++ lld/trunk/lib/ReaderWriter/ReaderArchive.cpp Tue Nov 13 12:39:10 2012<br>@@ -0,0 +1,160 @@<br>+//===- lib/ReaderWriter/ReaderArchive.cpp - Archive Library Reader--------===//<br>+//<br>+// The LLVM Linker<br>+//<br>+// This file is distributed under the University of Illinois Open Source<br>+// License. See LICENSE.TXT for details.<br>+//<br>+//===---------------------------------------------------------------------===//<br>+#include "lld/ReaderWriter/ReaderArchive.h"<br>+<br>+namespace lld <br>+{<br>+// The FileArchive class represents an Archive Library file<br>+class FileArchive : public ArchiveLibraryFile {<br>+public:<br>+<br>+ virtual ~FileArchive() { }<br>+<br>+ /// Check if any member of the archive contains an Atom with the<br>+ /// specified name and return the File object for that member, or nullptr.<br>+ virtual const File *find(StringRef name, bool dataSymbolOnly) const {<br>+ error_code ec; <br>+ llvm::object::Archive::child_iterator ci;<br>+<br>+ ci = _archive.get()->findSym(name);<br>+ if (ci == _archive->end_children()) <br>+ return nullptr;<br>+ <br>+ if (dataSymbolOnly && (ec = isDataSymbol(ci->getBuffer(), name)))<br>+ return nullptr;<br>+ <br>+ std::vector<std::unique_ptr<File>> result;<br>+<br>+ if ((ec = _options.reader()->parseFile(std::unique_ptr<MemoryBuffer><br>+ (ci->getBuffer()), result)))<br>+ return nullptr;<br>+<br>+ assert(result.size() == 1);<br>+<br>+ // give up the pointer so that this object no longer manages it<br>+ for (std::unique_ptr<File> &f : result) {<br>+ return f.release();<br>+ }<br>+<br>+ return nullptr;<br>+ }<br>+<br>+ virtual void addAtom(const Atom&) {<br>+ llvm_unreachable("cannot add atoms to archive files");<br>+ }<br>+<br>+ virtual const atom_collection<DefinedAtom> &defined() const {<br>+ return _definedAtoms;<br>+ }<br>+<br>+ virtual const atom_collection<UndefinedAtom> &undefined() const {<br>+ return _undefinedAtoms;<br>+ }<br>+<br>+ virtual const atom_collection<SharedLibraryAtom> &sharedLibrary() const {<br>+ return _sharedLibraryAtoms;<br>+ }<br>+<br>+ virtual const atom_collection<AbsoluteAtom> &absolute() const {<br>+ return _absoluteAtoms;<br>+ }<br>+<br>+protected:<br>+ error_code isDataSymbol(MemoryBuffer *mb, StringRef symbol) const<br>+ {<br>+ llvm::object::ObjectFile *obj = <br>+ llvm::object::ObjectFile::createObjectFile(mb);<br>+ error_code ec;<br>+ llvm::object::SymbolRef::Type symtype;<br>+ uint32_t symflags;<br>+ llvm::object::symbol_iterator ibegin = obj->begin_symbols();<br>+ llvm::object::symbol_iterator iend = obj->end_symbols();<br>+ StringRef symbolname;<br>+<br>+ for (llvm::object::symbol_iterator i = ibegin; i != iend; i.increment(ec)) {<br>+ if (ec) return ec;<br>+ <br>+ // Get symbol name<br>+ if ((ec = (i->getName(symbolname)))) return ec;<br>+ <br>+ if (symbolname != symbol) <br>+ continue;<br>+ <br>+ // Get symbol flags<br>+ if ((ec = (i->getFlags(symflags)))) return ec;<br>+ <br>+ if (symflags <= llvm::object::SymbolRef::SF_Undefined)<br>+ continue;<br>+ <br>+ // Get Symbol Type<br>+ if ((ec = (i->getType(symtype)))) return ec;<br>+ <br>+ if (symtype == llvm::object::SymbolRef::ST_Data) {<br>+ return error_code::success();<br>+ }<br>+ }<br>+ return llvm::object::object_error::parse_failed;<br>+ }<br>+<br>+private:<br>+ llvm::MemoryBuffer *_mb;<br>+ std::unique_ptr<llvm::object::Archive> _archive;<br>+ const ReaderOptionsArchive _options;<br>+ atom_collection_vector<DefinedAtom> _definedAtoms;<br>+ atom_collection_vector<UndefinedAtom> _undefinedAtoms;<br>+ atom_collection_vector<SharedLibraryAtom> _sharedLibraryAtoms;<br>+ atom_collection_vector<AbsoluteAtom> _absoluteAtoms;<br>+<br>+public:<br>+ /// only subclasses of ArchiveLibraryFile can be instantiated <br>+ explicit FileArchive(llvm::MemoryBuffer *mb, <br>+ const ReaderOptionsArchive &options, <br>+ error_code &ec)<br>+ :ArchiveLibraryFile(mb->getBufferIdentifier()),<br>+ _mb(mb),<br>+ _archive(nullptr),<br>+ _options(options) { <br>+ auto *archive_obj = new llvm::object::Archive(mb, ec);<br>+ if (ec) <br>+ return;<br>+ _archive.reset(archive_obj);<br>+ }<br>+}; // class FileArchive<br>+<br>+// Returns a vector of Files that are contained in the archive file <br>+// pointed to by the MemoryBuffer<br>+error_code ReaderArchive::parseFile(std::unique_ptr<llvm::MemoryBuffer> mb,<br>+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>std::vector<std::unique_ptr<File>> &result) {<br>+ error_code ec;<br>+ <br>+ if (_options.isForceLoad())<br>+ {<br>+ _archive.reset(new llvm::object::Archive(mb.release(), ec));<br>+ if (ec)<br>+ return ec;<br>+ <br>+ for (auto mf = _archive->begin_children(), <br>+ me = _archive->end_children(); mf != me; ++mf)<br>+ {<br>+ <span class="Apple-tab-span" style="white-space:pre"> </span>if ((ec = _options.reader()->parseFile(std::unique_ptr<MemoryBuffer><br>+ (mf->getBuffer()), result)))<br>+ return ec;<br>+ }<br>+ } else {<br>+ std::unique_ptr<File> f;<br>+ f.reset(new FileArchive(mb.release(), _options, ec));<br>+ if (ec)<br>+ return ec;<br>+<br>+ result.push_back(std::move(f));<br>+ }<br>+ return llvm::error_code::success();<br>+}<br>+<br>+} // namespace lld<br><br>Added: lld/trunk/test/elf/Inputs/libfnarchive.x86_64<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/libfnarchive.x86_64?rev=167854&view=auto">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/libfnarchive.x86_64?rev=167854&view=auto</a><br>==============================================================================<br>Binary file - no diff available.<br><br>Propchange: lld/trunk/test/elf/Inputs/libfnarchive.x86_64<br>------------------------------------------------------------------------------<br> svn:mime-type = application/octet-stream<br><br>Added: lld/trunk/test/elf/Inputs/mainobj.x86_64<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/mainobj.x86_64?rev=167854&view=auto">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/mainobj.x86_64?rev=167854&view=auto</a><br>==============================================================================<br>Binary file - no diff available.<br><br>Propchange: lld/trunk/test/elf/Inputs/mainobj.x86_64<br>------------------------------------------------------------------------------<br> svn:mime-type = application/octet-stream<br><br>Added: lld/trunk/test/elf/archive-elf-forceload.objtxt<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/archive-elf-forceload.objtxt?rev=167854&view=auto">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/archive-elf-forceload.objtxt?rev=167854&view=auto</a><br>==============================================================================<br>--- lld/trunk/test/elf/archive-elf-forceload.objtxt (added)<br>+++ lld/trunk/test/elf/archive-elf-forceload.objtxt Tue Nov 13 12:39:10 2012<br>@@ -0,0 +1,48 @@<br>+# Tests the functionality of archive libraries reading <br>+# and resolution <br>+# Note: The binary files would not be required once we have support to generate<br>+# binary archives from textual(yaml) input<br>+#<br>+# Tests generated using the source files below<br>+# main file<br>+# int main()<br>+# {<br>+# fn();<br>+# return 0;<br>+# }<br>+# <br>+# archive file<br>+# int fn()<br>+# {<br>+# return 0;<br>+# }<br>+# <br>+# int fn1()<br>+# {<br>+# return 0;<br>+# }<br>+# gcc -c main.c fn.c fn1.c<br>+<br>+RUN: lld-core -reader ELF %p/Inputs/mainobj.x86_64 %p/Inputs/libfnarchive.x86_64 -force-load | FileCheck -check-prefix FORCELOAD %s<br>+<br>+FORCELOAD: - name: fn1<br>+FORCELOAD: scope: global<br>+FORCELOAD: type: code<br>+FORCELOAD: section-choice: custom-required<br>+FORCELOAD: section-name: .text<br>+FORCELOAD: content: [ 55, 48, 89, E5, B8, 00, 00, 00, 00, 5D, C3 ]<br>+FORCELOAD: - name: fn<br>+FORCELOAD: scope: global<br>+FORCELOAD: type: code<br>+FORCELOAD: section-choice: custom-required<br>+FORCELOAD: section-name: .text<br>+FORCELOAD: content: [ 55, 48, 89, E5, B8, 00, 00, 00, 00, 5D, C3 ]<br>+FORCELOAD: - name: main.c<br>+FORCELOAD: definition: absolute<br>+FORCELOAD: value: 0x0<br>+FORCELOAD: - name: fn1.c<br>+FORCELOAD: definition: absolute<br>+FORCELOAD: value: 0x0<br>+FORCELOAD: - name: fn.c<br>+FORCELOAD: definition: absolute<br>+FORCELOAD: value: 0x0<br><br>Added: lld/trunk/test/elf/archive-elf.objtxt<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/archive-elf.objtxt?rev=167854&view=auto">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/archive-elf.objtxt?rev=167854&view=auto</a><br>==============================================================================<br>--- lld/trunk/test/elf/archive-elf.objtxt (added)<br>+++ lld/trunk/test/elf/archive-elf.objtxt Tue Nov 13 12:39:10 2012<br>@@ -0,0 +1,39 @@<br>+# Tests the functionality of archive libraries reading <br>+# and resolution <br>+# Note: The binary files would not be required once we have support to generate<br>+# binary archives from textual(yaml) input<br>+#<br>+# Tests generated using the source files below<br>+# main file<br>+# int main()<br>+# {<br>+# fn();<br>+# return 0;<br>+# }<br>+# <br>+# archive file<br>+# int fn()<br>+# {<br>+# return 0;<br>+# }<br>+# <br>+# int fn1()<br>+# {<br>+# return 0;<br>+# }<br>+# gcc -c main.c fn.c fn1.c<br>+<br>+RUN: lld-core -reader ELF %p/Inputs/mainobj.x86_64 %p/Inputs/libfnarchive.x86_64 | FileCheck -check-prefix NOFORCELOAD %s<br>+<br>+NOFORCELOAD: - name: fn<br>+NOFORCELOAD: scope: global<br>+NOFORCELOAD: type: code<br>+NOFORCELOAD: section-choice: custom-required<br>+NOFORCELOAD: section-name: .text<br>+NOFORCELOAD: content: [ 55, 48, 89, E5, B8, 00, 00, 00, 00, 5D, C3 ]<br>+NOFORCELOAD: - name: main.c<br>+NOFORCELOAD: definition: absolute<br>+NOFORCELOAD: value: 0x0<br>+NOFORCELOAD: - name: fn.c<br>+NOFORCELOAD: definition: absolute<br>+NOFORCELOAD: value: 0x0<br><br>Modified: lld/trunk/tools/lld-core/lld-core.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld-core/lld-core.cpp?rev=167854&r1=167853&r2=167854&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld-core/lld-core.cpp?rev=167854&r1=167853&r2=167854&view=diff</a><br>==============================================================================<br>--- lld/trunk/tools/lld-core/lld-core.cpp (original)<br>+++ lld/trunk/tools/lld-core/lld-core.cpp Tue Nov 13 12:39:10 2012<br>@@ -12,6 +12,7 @@<br> #include "lld/Core/Pass.h"<br> #include "lld/Core/Resolver.h"<br> #include "lld/ReaderWriter/Reader.h"<br>+#include "lld/ReaderWriter/ReaderArchive.h"<br> #include "lld/ReaderWriter/ReaderNative.h"<br> #include "lld/ReaderWriter/ReaderYAML.h"<br> #include "lld/ReaderWriter/ReaderELF.h"<br>@@ -76,6 +77,10 @@<br> llvm::cl::desc("Any undefined symbols at end is an error"));<br><br> llvm::cl::opt<bool> <br>+cmdLineForceLoad("force-load", <br>+ llvm::cl::desc("force load all members of the archive"));<br>+<br>+llvm::cl::opt<bool> <br> cmdLineCommonsSearchArchives("commons-search-archives", <br> llvm::cl::desc("Tentative definitions trigger archive search"));<br><br>@@ -214,6 +219,8 @@<br> // create object to mange input files<br> InputFiles inputFiles;<br><br>+ ReaderOptionsArchive readerOptionsArchive(cmdLineForceLoad);<br>+<br> // read input files into in-memory File objects<br><br> TestingReaderOptionsYAML readerOptionsYAML;<br>@@ -231,7 +238,9 @@<br> reader = createReaderPECOFF(lld::ReaderOptionsPECOFF());<br> break;<br> case readerELF:<br>- reader = createReaderELF(lld::ReaderOptionsELF());<br>+ reader = createReaderELF(lld::ReaderOptionsELF(),<br>+ readerOptionsArchive);<br>+<br> break;<br> default:<br> reader = createReaderYAML(readerOptionsYAML);<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote></div><br></div></body></html>