[ELF][MIPS] Do not emit .got section in case of relocatable output
llvm-svn: 276808
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 88f243d..540be8c 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -555,7 +555,7 @@
// The linker is expected to define some symbols depending on
// the linking result. This function defines such symbols.
template <class ELFT> void Writer<ELFT>::addReservedSymbols() {
- if (Config->EMachine == EM_MIPS) {
+ if (Config->EMachine == EM_MIPS && !Config->Relocatable) {
// Define _gp for MIPS. st_value of _gp symbol will be updated by Writer
// so that it points to an absolute address which is relative to GOT.
// See "Global Data Symbols" in Chapter 6 in the following document:
@@ -816,7 +816,7 @@
// We add the .got section to the result for dynamic MIPS target because
// its address and properties are mentioned in the .dynamic section.
- if (Config->EMachine == EM_MIPS)
+ if (Config->EMachine == EM_MIPS && !Config->Relocatable)
return true;
// If we have a relocation that is relative to GOT (such as GOTOFFREL),