diff options
| author | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-02-01 05:36:14 +0000 |
|---|---|---|
| committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-02-01 05:36:14 +0000 |
| commit | 3c75665fdd860f84f609523afb4d72868cf5e636 (patch) | |
| tree | b59a4839cbe07a5563803012870b79a6d1cf8a28 | |
| parent | c8803d27aadd0be4fd6acc24721bf382bb27de78 (diff) | |
| download | bcm5719-llvm-3c75665fdd860f84f609523afb4d72868cf5e636.tar.gz bcm5719-llvm-3c75665fdd860f84f609523afb4d72868cf5e636.zip | |
[ELF][x86-64] Add the _GLOBAL_OFFSET_TABLE_ Atom in the correct location.
Now we link against glibc without --noinhibit-exec.
llvm-svn: 174150
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp | 35 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h | 10 |
2 files changed, 42 insertions, 3 deletions
diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp index 3369f8dce57..398ff5fa281 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp @@ -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_64TargetRelocationHandler::applyRelocation( 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); } diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h index 179a8426d0b..9428478a152 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h @@ -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; }; |

