summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-05-17 04:58:26 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-05-17 04:58:26 +0000
commit9ab2cd03018ce5777b553e6587ef081221ccfac2 (patch)
tree969e51cbed4fa86ac498611719475b9854e92998
parent124084e23823202ed3f286f28fae2457b82fe913 (diff)
downloadbcm5719-llvm-9ab2cd03018ce5777b553e6587ef081221ccfac2.tar.gz
bcm5719-llvm-9ab2cd03018ce5777b553e6587ef081221ccfac2.zip
[Mips] Fix calculation of initial GOT entry value when this entry is
referenced by a local symbol. llvm-svn: 209063
-rw-r--r--lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp2
-rw-r--r--lld/test/elf/Mips/got16-2.test73
2 files changed, 74 insertions, 1 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
index 36913dfa4cc..2287d0cf573 100644
--- a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
+++ b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
@@ -111,7 +111,7 @@ static void relocGPRel32(uint8_t *location, uint64_t P, uint64_t S, int64_t A,
/// \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
diff --git a/lld/test/elf/Mips/got16-2.test b/lld/test/elf/Mips/got16-2.test
new file mode 100644
index 00000000000..6f576536c54
--- /dev/null
+++ b/lld/test/elf/Mips/got16-2.test
@@ -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 ..........@...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
OpenPOWER on IntegriCloud