aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
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;