[lld] r209063 - [Mips] Fix calculation of initial GOT entry value when this entry is

Simon Atanasyan simon at atanasyan.com
Fri May 16 21:58:26 PDT 2014


Author: atanasyan
Date: Fri May 16 23:58:26 2014
New Revision: 209063

URL: http://llvm.org/viewvc/llvm-project?rev=209063&view=rev
Log:
[Mips] Fix calculation of initial GOT entry value when this entry is
referenced by a local symbol.

Added:
    lld/trunk/test/elf/Mips/got16-2.test
Modified:
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp?rev=209063&r1=209062&r2=209063&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp Fri May 16 23:58:26 2014
@@ -111,7 +111,7 @@ static void relocGPRel32(uint8_t *locati
 
 /// \brief LLD_R_MIPS_32_HI16
 static void reloc32hi16(uint8_t *location, uint64_t S, int64_t A) {
-  applyReloc(location, (S + A) & 0xffff0000, 0xffffffff);
+  applyReloc(location, (S + A + 0x8000) & 0xffff0000, 0xffffffff);
 }
 
 /// \brief LLD_R_MIPS_HI16

Added: lld/trunk/test/elf/Mips/got16-2.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/got16-2.test?rev=209063&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/got16-2.test (added)
+++ lld/trunk/test/elf/Mips/got16-2.test Fri May 16 23:58:26 2014
@@ -0,0 +1,73 @@
+# Check handling of R_MIPS_GOT16 relocation against local
+# symbols when addresses of local data cross 64 KBytes border.
+
+# RUN: yaml2obj -format=elf %s > %t-obj
+# RUN: lld -flavor gnu -target mipsel -e T0 -o %t-exe %t-obj
+# RUN: llvm-objdump -s %t-exe | FileCheck %s
+
+# CHECK:      Contents of section .got:
+# CHECK-NEXT:  40a000 00000000 00000080 00004000 00004100  .......... at ...A.
+#                     lazy     module   0x400000 0x410000
+#                     resolver pointer  for L1   for L2
+
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_MIPS
+  Flags:           [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC,
+                     EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x04
+    Content:         '00000000000000000000000000000000'
+
+  - Name:            .rel.text
+    Type:            SHT_REL
+    Link:            .symtab
+    Info:            .text
+    AddressAlign:    0x04
+    Address:         0x1000
+    Relocations:
+      - Offset:      0
+        Symbol:      L1
+        Type:        R_MIPS_GOT16
+      - Offset:      4
+        Symbol:      L1
+        Type:        R_MIPS_LO16
+      - Offset:      8
+        Symbol:      L2
+        Type:        R_MIPS_GOT16
+      - Offset:      12
+        Symbol:      L2
+        Type:        R_MIPS_LO16
+
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    AddressAlign:    0x04
+    Size:            0x9000
+
+Symbols:
+  Local:
+    - Name:            .text
+      Type:            STT_SECTION
+      Section:         .text
+    - Name:            L1
+      Type:            STT_OBJECT
+      Section:         .data
+      Value:           0x00
+      Size:            0x8000
+    - Name:            L2
+      Type:            STT_OBJECT
+      Section:         .data
+      Value:           0x8000
+      Size:            0x04
+
+  Global:
+    - Name:            T0
+      Type:            STT_FUNC
+      Section:         .text
+      Size:            0x04





More information about the llvm-commits mailing list