mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[X86] Produce R_X86_64_GOTPCRELX for test/binop instructions (MOV32rm/TEST32rm/...) when -Wa,-mrelax-relocations=yes is enabled
We have been producing R_X86_64_REX_GOTPCRELX (MOV64rm/TEST64rm/...) and R_X86_64_GOTPCRELX for CALL64m/JMP64m without the REX prefix since 2016 (to be consistent with GNU as), but not for MOV32rm/TEST32rm/...
This commit is contained in:
parent
bf4d4552bd
commit
123fab6226
@ -229,6 +229,7 @@ private:
|
||||
case ELF::R_X86_64_64:
|
||||
return ELF_x86_64_Edges::ELFX86RelocationKind::Pointer64;
|
||||
case ELF::R_X86_64_GOTPCREL:
|
||||
case ELF::R_X86_64_GOTPCRELX:
|
||||
case ELF::R_X86_64_REX_GOTPCRELX:
|
||||
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32GOTLoad;
|
||||
}
|
||||
|
@ -404,6 +404,17 @@ void X86MCCodeEmitter::emitMemModRMByte(const MCInst &MI, unsigned Op,
|
||||
switch (Opcode) {
|
||||
default:
|
||||
return X86::reloc_riprel_4byte;
|
||||
case X86::ADC32rm:
|
||||
case X86::ADD32rm:
|
||||
case X86::AND32rm:
|
||||
case X86::CMP32rm:
|
||||
case X86::MOV32rm:
|
||||
case X86::OR32rm:
|
||||
case X86::SBB32rm:
|
||||
case X86::SUB32rm:
|
||||
case X86::TEST32mr:
|
||||
case X86::XOR32rm:
|
||||
return X86::reloc_riprel_4byte_relax;
|
||||
case X86::MOV64rm:
|
||||
assert(HasREX);
|
||||
return X86::reloc_riprel_4byte_movq_load;
|
||||
|
@ -1,21 +0,0 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o - | llvm-readobj -r - | FileCheck %s
|
||||
// RUN: llvm-mc -filetype=obj -relax-relocations=false -triple x86_64-pc-linux %s -o - | llvm-readobj -r - | FileCheck --check-prefix=OLD %s
|
||||
|
||||
// these should produce R_X86_64_GOTPCRELX
|
||||
|
||||
call *call@GOTPCREL(%rip)
|
||||
jmp *jmp@GOTPCREL(%rip)
|
||||
|
||||
// CHECK: Relocations [
|
||||
// CHECK-NEXT: Section ({{.*}}) .rela.text {
|
||||
// CHECK-NEXT: R_X86_64_GOTPCRELX call
|
||||
// CHECK-NEXT: R_X86_64_GOTPCRELX jmp
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
|
||||
// OLD: Relocations [
|
||||
// OLD-NEXT: Section ({{.*}}) .rela.text {
|
||||
// OLD-NEXT: R_X86_64_GOTPCREL call
|
||||
// OLD-NEXT: R_X86_64_GOTPCREL jmp
|
||||
// OLD-NEXT: }
|
||||
// OLD-NEXT: ]
|
@ -9,7 +9,7 @@
|
||||
// CHECK: Relocations [
|
||||
// CHECK: Section ({{[^ ]+}}) .rela.text {
|
||||
// CHECK-NEXT: 0x{{[^ ]+}} R_X86_64_GOT32 foo 0x{{[^ ]+}}
|
||||
// CHECK-NEXT: 0x{{[^ ]+}} R_X86_64_GOTPCREL foo 0x{{[^ ]+}}
|
||||
// CHECK-NEXT: 0x{{[^ ]+}} R_X86_64_GOTPCRELX foo 0x{{[^ ]+}}
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
|
||||
|
49
test/MC/X86/gotpcrelx.s
Normal file
49
test/MC/X86/gotpcrelx.s
Normal file
@ -0,0 +1,49 @@
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s | llvm-readobj -r - | FileCheck %s
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 -relax-relocations=false %s | llvm-readobj -r - | FileCheck --check-prefix=NORELAX %s
|
||||
|
||||
# CHECK: Relocations [
|
||||
# CHECK-NEXT: Section ({{.*}}) .rela.text {
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX mov
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX test
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX adc
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX add
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX and
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX cmp
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX or
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX sbb
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX sub
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX xor
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX call
|
||||
# CHECK-NEXT: R_X86_64_GOTPCRELX jmp
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: ]
|
||||
|
||||
# NORELAX: Relocations [
|
||||
# NORELAX-NEXT: Section ({{.*}}) .rela.text {
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL mov
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL test
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL adc
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL add
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL and
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL cmp
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL or
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL sbb
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL sub
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL xor
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL call
|
||||
# NORELAX-NEXT: R_X86_64_GOTPCREL jmp
|
||||
# NORELAX-NEXT: }
|
||||
# NORELAX-NEXT: ]
|
||||
|
||||
movl mov@GOTPCREL(%rip), %eax
|
||||
test %eax, test@GOTPCREL(%rip)
|
||||
adc adc@GOTPCREL(%rip), %eax
|
||||
add add@GOTPCREL(%rip), %eax
|
||||
and and@GOTPCREL(%rip), %eax
|
||||
cmp cmp@GOTPCREL(%rip), %eax
|
||||
or or@GOTPCREL(%rip), %eax
|
||||
sbb sbb@GOTPCREL(%rip), %eax
|
||||
sub sub@GOTPCREL(%rip), %eax
|
||||
xor xor@GOTPCREL(%rip), %eax
|
||||
call *call@GOTPCREL(%rip)
|
||||
jmp *jmp@GOTPCREL(%rip)
|
Loading…
Reference in New Issue
Block a user