mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 10:01:42 +00:00
Fix checks for R_386_8 and R_386_16.
Results created by these relocations are expected to be zero extended at runtime. llvm-svn: 294988
This commit is contained in:
parent
752f73b680
commit
195fba2967
@ -517,11 +517,17 @@ void X86TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
|
||||
// we want to support them.
|
||||
switch (Type) {
|
||||
case R_386_8:
|
||||
checkUInt<8>(Loc, Val, Type);
|
||||
*Loc = Val;
|
||||
break;
|
||||
case R_386_PC8:
|
||||
checkInt<8>(Loc, Val, Type);
|
||||
*Loc = Val;
|
||||
break;
|
||||
case R_386_16:
|
||||
checkUInt<16>(Loc, Val, Type);
|
||||
write16le(Loc, Val);
|
||||
break;
|
||||
case R_386_PC16:
|
||||
checkInt<16>(Loc, Val, Type);
|
||||
write16le(Loc, Val);
|
||||
|
3
lld/test/ELF/Inputs/i386-reloc-16-error.s
Normal file
3
lld/test/ELF/Inputs/i386-reloc-16-error.s
Normal file
@ -0,0 +1,3 @@
|
||||
.globl foo
|
||||
.hidden foo
|
||||
foo = 65536
|
3
lld/test/ELF/Inputs/i386-reloc-16.s
Normal file
3
lld/test/ELF/Inputs/i386-reloc-16.s
Normal file
@ -0,0 +1,3 @@
|
||||
.globl foo
|
||||
.hidden foo
|
||||
foo = 0xffff
|
3
lld/test/ELF/Inputs/i386-reloc-8-error.s
Normal file
3
lld/test/ELF/Inputs/i386-reloc-8-error.s
Normal file
@ -0,0 +1,3 @@
|
||||
.globl foo
|
||||
.hidden foo
|
||||
foo = 256
|
3
lld/test/ELF/Inputs/i386-reloc-8.s
Normal file
3
lld/test/ELF/Inputs/i386-reloc-8.s
Normal file
@ -0,0 +1,3 @@
|
||||
.globl foo
|
||||
.hidden foo
|
||||
foo = 0xff
|
14
lld/test/ELF/i386-reloc-16.s
Normal file
14
lld/test/ELF/i386-reloc-16.s
Normal file
@ -0,0 +1,14 @@
|
||||
// REQUIRES: x86
|
||||
|
||||
// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %S/Inputs/x86-64-reloc-16.s -o %t1
|
||||
// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %S/Inputs/x86-64-reloc-16-error.s -o %t2
|
||||
// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t
|
||||
// RUN: ld.lld -shared %t %t1 -o %t3
|
||||
|
||||
// CHECK: Contents of section .text:
|
||||
// CHECK-NEXT: 200000 42
|
||||
|
||||
// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
|
||||
// ERROR: relocation R_386_16 out of range
|
||||
|
||||
.short foo
|
14
lld/test/ELF/i386-reloc-8.s
Normal file
14
lld/test/ELF/i386-reloc-8.s
Normal file
@ -0,0 +1,14 @@
|
||||
// REQUIRES: x86
|
||||
|
||||
// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %S/Inputs/i386-reloc-8.s -o %t1
|
||||
// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %S/Inputs/i386-reloc-8-error.s -o %t2
|
||||
// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t
|
||||
// RUN: ld.lld -shared %t %t1 -o %t3
|
||||
|
||||
// CHECK: Contents of section .text:
|
||||
// CHECK-NEXT: 200000 42
|
||||
|
||||
// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
|
||||
// ERROR: relocation R_386_8 out of range
|
||||
|
||||
.byte foo
|
Loading…
Reference in New Issue
Block a user