summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2016-07-26 21:11:30 +0000
committerSimon Atanasyan <simon@atanasyan.com>2016-07-26 21:11:30 +0000
commit240bc16532b92fff14ab037868fac2f70fa5af2d (patch)
tree388a518d8950e3a2dcad7d34ca421e15c4c25510
parent72170d27534c54b003d5cf589dc8445b846fa146 (diff)
downloadbcm5719-llvm-240bc16532b92fff14ab037868fac2f70fa5af2d.tar.gz
bcm5719-llvm-240bc16532b92fff14ab037868fac2f70fa5af2d.zip
[ELF][MIPS] Do not emit .got section in case of relocatable output
llvm-svn: 276808
-rw-r--r--lld/ELF/Writer.cpp4
-rw-r--r--lld/test/ELF/mips-relocatable.s21
2 files changed, 23 insertions, 2 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 88f243d9125..540be8c54a4 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -555,7 +555,7 @@ template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
// 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>::needsGot() {
// 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),
diff --git a/lld/test/ELF/mips-relocatable.s b/lld/test/ELF/mips-relocatable.s
new file mode 100644
index 00000000000..168ddf736e1
--- /dev/null
+++ b/lld/test/ELF/mips-relocatable.s
@@ -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
OpenPOWER on IntegriCloud