[lld] r174150 - [ELF][x86-64] Add the _GLOBAL_OFFSET_TABLE_ Atom in the correct location.
Michael J. Spencer
bigcheesegs at gmail.com
Thu Jan 31 21:36:14 PST 2013
Author: mspencer
Date: Thu Jan 31 23:36:14 2013
New Revision: 174150
URL: http://llvm.org/viewvc/llvm-project?rev=174150&view=rev
Log:
[ELF][x86-64] Add the _GLOBAL_OFFSET_TABLE_ Atom in the correct location.
Now we link against glibc without --noinhibit-exec.
Modified:
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp?rev=174150&r1=174149&r2=174150&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp Thu Jan 31 23:36:14 2013
@@ -16,6 +16,10 @@ using namespace elf;
using namespace llvm::ELF;
+X86_64TargetHandler::X86_64TargetHandler(X86_64TargetInfo &targetInfo)
+ : DefaultTargetHandler(targetInfo), _gotFile(targetInfo),
+ _relocationHandler(targetInfo), _targetLayout(targetInfo) {}
+
namespace {
/// \brief R_X86_64_64 - word64: S + A
void reloc64(uint8_t *location, uint64_t P, uint64_t S, int64_t A) {
@@ -87,7 +91,32 @@ ErrorOr<void> X86_64TargetRelocationHand
return error_code::success();
}
-X86_64TargetHandler::X86_64TargetHandler(X86_64TargetInfo &targetInfo)
- : DefaultTargetHandler(targetInfo), _relocationHandler(targetInfo),
- _targetLayout(targetInfo) {
+namespace {
+class GLOBAL_OFFSET_TABLEAtom : public SimpleDefinedAtom {
+public:
+ GLOBAL_OFFSET_TABLEAtom(const File &f) : SimpleDefinedAtom(f) {}
+
+ virtual StringRef name() const { return "_GLOBAL_OFFSET_TABLE_"; }
+
+ virtual Scope scope() const { return scopeGlobal; }
+
+ virtual SectionChoice sectionChoice() const { return sectionCustomRequired; }
+
+ virtual StringRef customSectionName() const { return ".got"; }
+
+ virtual ContentType contentType() const { return typeGOT; }
+
+ virtual uint64_t size() const { return 0; }
+
+ virtual ContentPermissions permissions() const { return permRW_; }
+
+ virtual ArrayRef<uint8_t> rawContent() const {
+ return ArrayRef<uint8_t>();
+ }
+};
+} // end anon namespace
+
+void X86_64TargetHandler::addFiles(InputFiles &f) {
+ _gotFile.addAtom(*new (_gotFile._alloc) GLOBAL_OFFSET_TABLEAtom(_gotFile));
+ f.appendFile(_gotFile);
}
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h?rev=174150&r1=174149&r2=174150&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h Thu Jan 31 23:36:14 2013
@@ -13,6 +13,8 @@
#include "DefaultTargetHandler.h"
#include "TargetLayout.h"
+#include "lld/ReaderWriter/Simple.h"
+
namespace lld {
namespace elf {
typedef llvm::object::ELFType<llvm::support::little, 8, true> X86_64ELFType;
@@ -44,7 +46,15 @@ public:
return _relocationHandler;
}
+ virtual void addFiles(InputFiles &f);
+
private:
+ class GOTFile : public SimpleFile {
+ public:
+ GOTFile(const ELFTargetInfo &eti) : SimpleFile(eti, "GOTFile") {}
+ llvm::BumpPtrAllocator _alloc;
+ } _gotFile;
+
X86_64TargetRelocationHandler _relocationHandler;
TargetLayout<X86_64ELFType> _targetLayout;
};
More information about the llvm-commits
mailing list