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

referenced by a local symbol.

llvm-svn: 209063
This commit is contained in:
Simon Atanasyan 2014-05-17 04:58:26 +00:00
parent 124084e238
commit 9ab2cd0301
2 changed files with 74 additions and 1 deletions

View File

@ -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

View File

@ -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