aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-09-30 03:11:42 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-09-30 03:11:42 +0000
commita8c02c3bdd68e65d14fb6b0d56989663754059b0 (patch)
treec373bb5e12b01decbe52b0cb6c7d4fdbf22c3a1c /lib/MC/ELFObjectWriter.cpp
parentafd1cc25786f68ca56a63d29ea2bd297990e9f81 (diff)
Correctly produce R_X86_64_32 or R_X86_64_32S.
With this patch in movq $foo, foo(%rip) foo: .long foo We produce a R_X86_64_32S for the first relocation and R_X86_64_32 for the second one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115134 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/ELFObjectWriter.cpp')
-rw-r--r--lib/MC/ELFObjectWriter.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index 94251d76b2..a80e7b6b08 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -577,16 +577,13 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
switch ((unsigned)Fixup.getKind()) {
default: llvm_unreachable("invalid fixup kind!");
case FK_Data_8: Type = ELF::R_X86_64_64; break;
+ case X86::reloc_signed_4byte:
case X86::reloc_pcrel_4byte:
+ assert(isInt<32>(Target.getConstant()));
+ Type = ELF::R_X86_64_32S;
+ break;
case FK_Data_4:
- // check that the offset fits within a signed long
- if (Target.getConstant() < 0) {
- assert(isInt<32>(Target.getConstant()));
- Type = ELF::R_X86_64_32S;
- } else {
- assert(isUInt<32>(Target.getConstant()));
- Type = ELF::R_X86_64_32;
- }
+ Type = ELF::R_X86_64_32;
break;
case FK_Data_2: Type = ELF::R_X86_64_16; break;
case X86::reloc_pcrel_1byte:
@@ -599,6 +596,10 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
} else {
switch ((unsigned)Fixup.getKind()) {
default: llvm_unreachable("invalid fixup kind!");
+
+ // FIXME: Should we avoid selecting reloc_signed_4byte in 32 bit mode
+ // instead?
+ case X86::reloc_signed_4byte:
case X86::reloc_pcrel_4byte:
case FK_Data_4: Type = ELF::R_386_32; break;
case FK_Data_2: Type = ELF::R_386_16; break;