forked from OSchip/llvm-project
parent
92063b3bf2
commit
75e5fda3de
|
@ -501,12 +501,18 @@ template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) {
|
|||
support::endian::write64le(Location, SymVA + RI.r_addend);
|
||||
break;
|
||||
case llvm::ELF::R_X86_64_32: {
|
||||
case llvm::ELF::R_X86_64_32S:
|
||||
APInt VA(64, SymVA);
|
||||
APInt Addend(64, RI.r_addend, true);
|
||||
APInt Result64 = VA + Addend;
|
||||
APInt Result = Result64.trunc(32);
|
||||
if (Result.zext(64) != Result64)
|
||||
error("Relocation out of range");
|
||||
if (Type == llvm::ELF::R_X86_64_32) {
|
||||
if (Result.zext(64) != Result64)
|
||||
error("Relocation out of range");
|
||||
} else
|
||||
if (Result.sext(64) != Result64)
|
||||
error("R_X86_64_32S out of range");
|
||||
|
||||
support::endian::write32le(Location, Result.getZExtValue());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
|
||||
// RUN: not lld -flavor gnu2 %t -o %t2 2>&1 | FileCheck %s
|
||||
// REQUIRES: x86
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
movq _start - 0x1000000000000, %rdx
|
||||
|
||||
#CHECK: R_X86_64_32S out of range
|
|
@ -35,10 +35,19 @@ R_X86_64_32:
|
|||
// CHECK-NEXT: R_X86_64_32:
|
||||
// CHECK-NEXT: 12000: {{.*}} movl $73728, %edx
|
||||
|
||||
.section .R_X86_64_32S,"ax",@progbits
|
||||
.global R_X86_64_32S
|
||||
R_X86_64_32S:
|
||||
movq lulz - 0x100000, %rdx
|
||||
|
||||
// CHECK: Disassembly of section .R_X86_64_32S:
|
||||
// CHECK-NEXT: R_X86_64_32S:
|
||||
// CHECK-NEXT: {{.*}}: {{.*}} movq -978935, %rdx
|
||||
|
||||
.section .R_X86_64_64,"a",@progbits
|
||||
.global R_X86_64_64
|
||||
R_X86_64_64:
|
||||
.quad R_X86_64_64
|
||||
|
||||
// CHECK: Contents of section .R_X86_64_64:
|
||||
// CHECK-NEXT: 13000 00300100 00000000
|
||||
// CHECK-NEXT: 14000 00400100 00000000
|
||||
|
|
Loading…
Reference in New Issue