mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-30 17:33:24 +00:00
Correctly handle GOTPCREL relocations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115793 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0dadb15927
commit
8cecf253e4
@ -544,12 +544,12 @@ static bool ShouldRelocOnSymbol(const MCSymbolData &SD,
|
|||||||
if (SD.isExternal())
|
if (SD.isExternal())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const llvm::MCSymbolRefExpr& Ref = *Target.getSymA();
|
MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind();
|
||||||
const MCSectionELF &Sec2 =
|
const MCSectionELF &Sec2 =
|
||||||
static_cast<const MCSectionELF&>(F.getParent()->getSection());
|
static_cast<const MCSectionELF&>(F.getParent()->getSection());
|
||||||
|
|
||||||
if (Ref.getKind() == MCSymbolRefExpr::VK_PLT &&
|
if (&Sec2 != &Section &&
|
||||||
&Sec2 != &Section)
|
(Kind == MCSymbolRefExpr::VK_PLT || Kind == MCSymbolRefExpr::VK_GOTPCREL))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -648,6 +648,9 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
|||||||
case MCSymbolRefExpr::VK_GOT:
|
case MCSymbolRefExpr::VK_GOT:
|
||||||
Type = ELF::R_X86_64_GOT32;
|
Type = ELF::R_X86_64_GOT32;
|
||||||
break;
|
break;
|
||||||
|
case llvm::MCSymbolRefExpr::VK_GOTPCREL:
|
||||||
|
Type = ELF::R_X86_64_GOTPCREL;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Unimplemented");
|
llvm_unreachable("Unimplemented");
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
movl $.Lfoo, %edi
|
movl $.Lfoo, %edi
|
||||||
movl $.Lfoo+2, %edi
|
movl $.Lfoo+2, %edi
|
||||||
jmp foo@PLT
|
jmp foo@PLT
|
||||||
|
movq foo@GOTPCREL, %rax
|
||||||
|
|
||||||
.section .sec1,"aM",@progbits,16
|
.section .sec1,"aM",@progbits,16
|
||||||
.Lfoo:
|
.Lfoo:
|
||||||
@ -70,4 +71,12 @@ foo:
|
|||||||
// CHECK-NEXT: ('r_type', 4
|
// CHECK-NEXT: ('r_type', 4
|
||||||
// CHECK-NEXT: ('r_addend',
|
// CHECK-NEXT: ('r_addend',
|
||||||
// CHECK-NEXT: ),
|
// CHECK-NEXT: ),
|
||||||
|
|
||||||
|
// Relocation 4 refers to symbol 2
|
||||||
|
// CHECK-NEXT: # Relocation 4
|
||||||
|
// CHECK-NEXT: (('r_offset',
|
||||||
|
// CHECK-NEXT: ('r_sym', 2)
|
||||||
|
// CHECK-NEXT: ('r_type', 9
|
||||||
|
// CHECK-NEXT: ('r_addend',
|
||||||
|
// CHECK-NEXT: ),
|
||||||
// CHECK-NEXT: ])
|
// CHECK-NEXT: ])
|
||||||
|
Loading…
Reference in New Issue
Block a user