[lld] r235031 - [Mips] Create _GLOBAL_OFFSET_TABLE_ only if the .got section exists
Simon Atanasyan
simon at atanasyan.com
Wed Apr 15 11:31:53 PDT 2015
Author: atanasyan
Date: Wed Apr 15 13:31:53 2015
New Revision: 235031
URL: http://llvm.org/viewvc/llvm-project?rev=235031&view=rev
Log:
[Mips] Create _GLOBAL_OFFSET_TABLE_ only if the .got section exists
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
lld/trunk/test/elf/Mips/gotsym.test
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h?rev=235031&r1=235030&r2=235031&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h Wed Apr 15 13:31:53 2015
@@ -48,7 +48,6 @@ public:
auto got = gotSection ? gotSection->virtualAddr() : 0;
auto gp = gotSection ? got + _targetLayout.getGPOffset() : 0;
- setAtomValue("_GLOBAL_OFFSET_TABLE_", got);
setAtomValue("_gp", gp);
setAtomValue("_gp_disp", gp);
setAtomValue("__gnu_local_gp", gp);
@@ -57,7 +56,6 @@ public:
std::unique_ptr<RuntimeFile<ELFT>> createRuntimeFile() {
auto file = llvm::make_unique<RuntimeFile<ELFT>>(_ctx, "Mips runtime file");
if (_ctx.isDynamic()) {
- file->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
file->addAbsoluteAtom("_gp");
file->addAbsoluteAtom("_gp_disp");
file->addAbsoluteAtom("__gnu_local_gp");
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=235031&r1=235030&r2=235031&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Wed Apr 15 13:31:53 2015
@@ -280,6 +280,13 @@ public:
}
};
+class MipsGlobalOffsetTableAtom : public GlobalOffsetTableAtom {
+public:
+ MipsGlobalOffsetTableAtom(const File &f) : GlobalOffsetTableAtom(f) {}
+
+ StringRef customSectionName() const override { return ".got"; }
+};
+
class RelocationPassFile : public SimpleFile {
public:
RelocationPassFile(const ELFLinkingContext &ctx)
@@ -442,6 +449,13 @@ void RelocationPass<ELFT>::perform(std::
uint64_t ordinal = 0;
+ if (!_localGotVector.empty() || !_globalGotVector.empty() ||
+ !_tlsGotVector.empty()) {
+ SimpleDefinedAtom *ga = new (_file._alloc) MipsGlobalOffsetTableAtom(_file);
+ ga->setOrdinal(ordinal++);
+ mf->addAtom(*ga);
+ }
+
for (auto &got : _localGotVector) {
got->setOrdinal(ordinal++);
mf->addAtom(*got);
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h?rev=235031&r1=235030&r2=235031&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h Wed Apr 15 13:31:53 2015
@@ -155,6 +155,9 @@ public:
const AtomLayout *appendAtom(const Atom *atom) override {
const DefinedAtom *da = dyn_cast<DefinedAtom>(atom);
+ if (atom->name() == "_GLOBAL_OFFSET_TABLE_")
+ return AtomSection<ELFT>::appendAtom(atom);
+
for (const auto &r : *da) {
if (r->kindNamespace() != Reference::KindNamespace::ELF)
continue;
Modified: lld/trunk/test/elf/Mips/gotsym.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/gotsym.test?rev=235031&r1=235030&r2=235031&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/gotsym.test (original)
+++ lld/trunk/test/elf/Mips/gotsym.test Wed Apr 15 13:31:53 2015
@@ -8,7 +8,7 @@
# SHARED: Idx Name Size Address Type
# SHARED: 6 .got 00000008 0000000000001000 DATA
# SHARED: SYMBOL TABLE:
-# SHARED: 00001000 g *ABS* 00000000 _GLOBAL_OFFSET_TABLE_
+# SHARED: 00001000 .got 00000000 _GLOBAL_OFFSET_TABLE_
# SHARED: 00008ff0 g *ABS* 00000000 _gp
# SHARED: 00008ff0 g *ABS* 00000000 _gp_disp
@@ -19,7 +19,7 @@
# EXE: Idx Name Size Address Type
# EXE: 7 .got 00000008 0000000000401000 DATA
# EXE: SYMBOL TABLE:
-# EXE: 00401000 g *ABS* 00000000 _GLOBAL_OFFSET_TABLE_
+# EXE: 00401000 .got 00000000 _GLOBAL_OFFSET_TABLE_
# EXE: 00408ff0 g *ABS* 00000000 _gp
# EXE: 00408ff0 g *ABS* 00000000 _gp_disp
More information about the llvm-commits
mailing list