summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2016-01-12 17:31:45 +0000
committerSimon Atanasyan <simon@atanasyan.com>2016-01-12 17:31:45 +0000
commit3a5b6e275013276b253246f2b4de4146fcafd881 (patch)
tree15d748a3b599653bee83184ad87e4988f432663d
parent6002e78a066fc93d50a8c3bebfdd335ff94f7536 (diff)
downloadbcm5719-llvm-3a5b6e275013276b253246f2b4de4146fcafd881.tar.gz
bcm5719-llvm-3a5b6e275013276b253246f2b4de4146fcafd881.zip
[ELF][MIPS] Do not create dynamic relocations against _gp_disp symbol
MIPS _gp_disp designates offset between start of function and gp pointer into GOT therefore any relocations against it do not require dynamic relocation. llvm-svn: 257492
-rw-r--r--lld/ELF/Writer.cpp23
-rw-r--r--lld/test/ELF/mips-gp-disp.s4
2 files changed, 19 insertions, 8 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 0b0ff805c9a..9143024c615 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -287,14 +287,21 @@ void Writer<ELFT>::scanRelocs(
continue;
}
- if (Config->EMachine == EM_MIPS && NeedsGot) {
- // MIPS ABI has special rules to process GOT entries
- // and doesn't require relocation entries for them.
- // See "Global Offset Table" in Chapter 5 in the following document
- // for detailed description:
- // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
- Body->setUsedInDynamicReloc();
- continue;
+ if (Config->EMachine == EM_MIPS) {
+ if (NeedsGot) {
+ // MIPS ABI has special rules to process GOT entries
+ // and doesn't require relocation entries for them.
+ // See "Global Offset Table" in Chapter 5 in the following document
+ // for detailed description:
+ // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
+ Body->setUsedInDynamicReloc();
+ continue;
+ }
+ if (Body == Config->MipsGpDisp)
+ // MIPS _gp_disp designates offset between start of function and gp
+ // pointer into GOT therefore any relocations against it do not require
+ // dynamic relocation.
+ continue;
}
// Here we are creating a relocation for the dynamic linker based on
diff --git a/lld/test/ELF/mips-gp-disp.s b/lld/test/ELF/mips-gp-disp.s
index b7f0517a134..a08829c18bd 100644
--- a/lld/test/ELF/mips-gp-disp.s
+++ b/lld/test/ELF/mips-gp-disp.s
@@ -7,6 +7,7 @@
# RUN: llvm-readobj -symbols %S/Inputs/mips-gp-disp.so \
# RUN: | FileCheck -check-prefix=EXT-SO %s
# RUN: llvm-objdump -d -t %t.so | FileCheck -check-prefix=DIS %s
+# RUN: llvm-readobj -relocations %t.so | FileCheck -check-prefix=REL %s
# REQUIRES: mips
@@ -22,6 +23,9 @@
# ^-- 0x37ff0 & 0xffff
# DIS: 00027ff0 *ABS* 00000000 _gp
+# REL: Relocations [
+# REL-NEXT: ]
+
.text
.globl __start
__start:
OpenPOWER on IntegriCloud