forked from OSchip/llvm-project
[Mips] Support R_MIPS_16 relocation handling
llvm-svn: 239959
This commit is contained in:
parent
9bc2ad5e6c
commit
17478c5804
|
@ -101,6 +101,7 @@ static MipsRelocationParams getRelocationParams(uint32_t rType) {
|
|||
return {4, 0xffff, 0, false, gpDispCheck<16>};
|
||||
case R_MIPS_LO16:
|
||||
return {4, 0xffff, 0, false, dummyCheck};
|
||||
case R_MIPS_16:
|
||||
case R_MIPS_PCHI16:
|
||||
case R_MIPS_PCLO16:
|
||||
case R_MIPS_GOT16:
|
||||
|
@ -438,6 +439,8 @@ static ErrorOr<int64_t> calculateRelocation(Reference::KindValue kind,
|
|||
switch (kind) {
|
||||
case R_MIPS_NONE:
|
||||
return 0;
|
||||
case R_MIPS_16:
|
||||
return tgtAddr + llvm::SignExtend32<16>(addend);
|
||||
case R_MIPS_32:
|
||||
case R_MIPS_64:
|
||||
return tgtAddr + addend;
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
# Check R_MIPS_16 relocation overflow handling.
|
||||
|
||||
# RUN: yaml2obj -format=elf %s > %t.o
|
||||
# RUN: not lld -flavor gnu -target mipsel -e T0 -o %t.exe %t.o 2>&1 \
|
||||
# RUN: | FileCheck %s
|
||||
|
||||
# CHECK: Relocation out of range in file {{.*}} reference from T0+0 to T1+32767 of type 1 (R_MIPS_16)
|
||||
|
||||
FileHeader:
|
||||
Class: ELFCLASS32
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_MIPS
|
||||
Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
|
||||
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
Content: "ff7f00000000000000000000"
|
||||
# ^ T1
|
||||
# ^ T0 A := 0x7fff
|
||||
AddressAlign: 16
|
||||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||
|
||||
- Name: .rel.text
|
||||
Type: SHT_REL
|
||||
Info: .text
|
||||
AddressAlign: 4
|
||||
Relocations:
|
||||
- Offset: 0
|
||||
Symbol: T1
|
||||
Type: R_MIPS_16
|
||||
|
||||
Symbols:
|
||||
Global:
|
||||
- Name: T0
|
||||
Section: .text
|
||||
Type: STT_FUNC
|
||||
Value: 0
|
||||
Size: 8
|
||||
- Name: T1
|
||||
Section: .text
|
||||
Type: STT_FUNC
|
||||
Value: 8
|
||||
Size: 4
|
|
@ -0,0 +1,51 @@
|
|||
# Check handling of R_MIPS_16 relocation.
|
||||
|
||||
# RUN: yaml2obj -format=elf %s > %t.o
|
||||
# RUN: lld -flavor gnu -target mipsel -shared -o %t.exe %t.o
|
||||
# RUN: llvm-objdump -s -t %t.exe | FileCheck %s
|
||||
|
||||
# CHECK: Contents of section .text:
|
||||
# CHECK-NEXT: 00f0 f0000000 00000000 00000000
|
||||
# ^ V = (T1 - 8) = T0
|
||||
|
||||
# CHECK: SYMBOL TABLE:
|
||||
# CHECK: 000000f0 g F .text 00000008 T0
|
||||
# CHECK: 000000f8 g F .text 00000004 T1
|
||||
|
||||
FileHeader:
|
||||
Class: ELFCLASS32
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_MIPS
|
||||
Flags: [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
|
||||
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
Content: "f8ff00000000000000000000"
|
||||
# ^ T1
|
||||
# ^ T0 A := 0xfff8 = -8
|
||||
AddressAlign: 16
|
||||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||
|
||||
- Name: .rel.text
|
||||
Type: SHT_REL
|
||||
Info: .text
|
||||
AddressAlign: 4
|
||||
Relocations:
|
||||
- Offset: 0
|
||||
Symbol: T1
|
||||
Type: R_MIPS_16
|
||||
|
||||
Symbols:
|
||||
Global:
|
||||
- Name: T0
|
||||
Section: .text
|
||||
Type: STT_FUNC
|
||||
Value: 0
|
||||
Size: 8
|
||||
- Name: T1
|
||||
Section: .text
|
||||
Type: STT_FUNC
|
||||
Value: 8
|
||||
Size: 4
|
Loading…
Reference in New Issue