[lld] r257492 - [ELF][MIPS] Do not create dynamic relocations against _gp_disp symbol

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 09:31:45 PST 2016


Author: atanasyan
Date: Tue Jan 12 11:31:45 2016
New Revision: 257492

URL: http://llvm.org/viewvc/llvm-project?rev=257492&view=rev
Log:
[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.

Modified:
    lld/trunk/ELF/Writer.cpp
    lld/trunk/test/ELF/mips-gp-disp.s

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=257492&r1=257491&r2=257492&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jan 12 11:31:45 2016
@@ -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

Modified: lld/trunk/test/ELF/mips-gp-disp.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-gp-disp.s?rev=257492&r1=257491&r2=257492&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-gp-disp.s (original)
+++ lld/trunk/test/ELF/mips-gp-disp.s Tue Jan 12 11:31:45 2016
@@ -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:




More information about the llvm-commits mailing list