[lld] r276808 - [ELF][MIPS] Do not emit .got section in case of relocatable output
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 14:11:30 PDT 2016
Author: atanasyan
Date: Tue Jul 26 16:11:30 2016
New Revision: 276808
URL: http://llvm.org/viewvc/llvm-project?rev=276808&view=rev
Log:
[ELF][MIPS] Do not emit .got section in case of relocatable output
Added:
lld/trunk/test/ELF/mips-relocatable.s
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=276808&r1=276807&r2=276808&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jul 26 16:11:30 2016
@@ -555,7 +555,7 @@ template <class ELFT> void Writer<ELFT>:
// 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 @@ template <class ELFT> bool Writer<ELFT>:
// 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),
Added: lld/trunk/test/ELF/mips-relocatable.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-relocatable.s?rev=276808&view=auto
==============================================================================
--- lld/trunk/test/ELF/mips-relocatable.s (added)
+++ lld/trunk/test/ELF/mips-relocatable.s Tue Jul 26 16:11:30 2016
@@ -0,0 +1,21 @@
+# Check linking MIPS code in case of -r linker's option.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
+# RUN: ld.lld -r -o %t-r.o %t.o
+# RUN: llvm-objdump -s -t %t-r.o | FileCheck %s
+
+# REQUIRES: mips
+
+ .text
+ .global __start
+__start:
+ lw $t0,%call16(__start)($gp)
+foo:
+ nop
+
+ .section .rodata, "a"
+v:
+ .gpword foo
+
+# CHECK-NOT: Contents of section .got:
+# CHECK-NOT: {{.*}} _gp
More information about the llvm-commits
mailing list