[PATCH] [TargetInfo] Move LinkerInputFile to TargetInfo and rename more specific name
Rui Ueyama
ruiu at google.com
Thu Jun 20 20:18:41 PDT 2013
- Keep LinkerInternalFile class
- Make TargetInfo the ownership of a LinkerInternalFile
Hi shankarke,
http://llvm-reviews.chandlerc.com/D1016
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1016?vs=2515&id=2517#toc
Files:
include/lld/Core/TargetInfo.h
lib/Core/TargetInfo.cpp
lib/ReaderWriter/ELF/OutputELFWriter.h
Index: include/lld/Core/TargetInfo.h
===================================================================
--- include/lld/Core/TargetInfo.h
+++ include/lld/Core/TargetInfo.h
@@ -364,6 +364,10 @@
private:
/// Validate the subclass bits. Only called by validate.
virtual bool validateImpl(raw_ostream &diagnostics) = 0;
+
+ File &createLinkerInternalFile() const;
+
+ mutable llvm::BumpPtrAllocator _allocator;
};
} // end namespace lld
Index: lib/Core/TargetInfo.cpp
===================================================================
--- lib/Core/TargetInfo.cpp
+++ lib/Core/TargetInfo.cpp
@@ -7,7 +7,10 @@
//
//===----------------------------------------------------------------------===//
+#include "lld/Core/InputFiles.h"
#include "lld/Core/TargetInfo.h"
+#include "lld/Core/UndefinedAtom.h"
+#include "lld/ReaderWriter/Simple.h"
#include "lld/ReaderWriter/Writer.h"
#include "llvm/ADT/Triple.h"
@@ -46,11 +49,30 @@
}
void TargetInfo::addImplicitFiles(InputFiles& inputs) const {
- this->writer().addFiles(inputs);
+ // Make the linker internal file to be the first file.
+ inputs.prependFile(createLinkerInternalFile());
+
+ this->writer().addFiles(inputs);
}
void TargetInfo::addPasses(PassManager &pm) const {
}
+/// Create a file that acts as an internal file that the linker uses to add
+/// undefined symbols. Undefiend symbols can be defined by using the linker
+/// options such as -u, or --defsym option.
+File &TargetInfo::createLinkerInternalFile() const {
+ auto *file = new (_allocator.Allocate<SimpleFile>())
+ SimpleFile(*this, "Linker Internal File");
+
+ // Add all symbols that are specified by the -u option as part of the
+ // command line argument to lld.
+ for (const StringRef symbolName : _targetInfo.undefinedSymbols()) {
+ auto *atom = new (_allocator.Allocate<SimpleUndefinedAtom>())
+ SimpleUndefinedAtom(*file, symbolName);
+ file->addAtom(*atom);
+ }
+ return *file;
+}
} // end namespace lld
Index: lib/ReaderWriter/ELF/OutputELFWriter.h
===================================================================
--- lib/ReaderWriter/ELF/OutputELFWriter.h
+++ lib/ReaderWriter/ELF/OutputELFWriter.h
@@ -28,15 +28,6 @@
template<class ELFT>
class OutputELFWriter;
-/// \brief This acts as a internal file that the linker uses to add
-/// undefined symbols that are defined by using the linker options such
-/// as -u, or --defsym option.
-template <class ELFT> class LinkerInternalFile : public CRuntimeFile<ELFT> {
-public:
- LinkerInternalFile(const ELFTargetInfo &ti)
- : CRuntimeFile<ELFT>(ti, "Linker Internal File") {};
-};
-
//===----------------------------------------------------------------------===//
// OutputELFWriter Class
//===----------------------------------------------------------------------===//
@@ -123,16 +114,14 @@
LLD_UNIQUE_BUMP_PTR(HashSection<ELFT>) _hashTable;
llvm::StringSet<> _soNeeded;
/// @}
- LinkerInternalFile<ELFT> _linkerInternalFile;
};
//===----------------------------------------------------------------------===//
// OutputELFWriter
//===----------------------------------------------------------------------===//
template <class ELFT>
OutputELFWriter<ELFT>::OutputELFWriter(const ELFTargetInfo &ti)
- : _targetInfo(ti), _targetHandler(ti.getTargetHandler<ELFT>()),
- _linkerInternalFile(ti) {
+ : _targetInfo(ti), _targetHandler(ti.getTargetHandler<ELFT>()) {
_layout = &_targetHandler.targetLayout();
}
@@ -238,12 +227,6 @@
void OutputELFWriter<ELFT>::addFiles(InputFiles &inputFiles) {
// Add all input Files that are defined by the target
_targetHandler.addFiles(inputFiles);
- // Add all symbols that are specified by the -u option
- // as part of the command line argument to lld
- for (auto ai : _targetInfo.undefinedSymbols())
- _linkerInternalFile.addUndefinedAtom(ai);
- // Make the linker internal file to be the first file
- inputFiles.prependFile(_linkerInternalFile);
}
template <class ELFT> void OutputELFWriter<ELFT>::createDefaultSections() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1016.2.patch
Type: text/x-patch
Size: 4065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130620/9e321c16/attachment.bin>
More information about the llvm-commits
mailing list