Index: lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp =================================================================== --- lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp +++ lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp @@ -29,8 +29,7 @@ class ARMELFObjectWriter : public MCELFObjectTargetWriter { enum { DefaultEABIVersion = 0x05000000U }; - unsigned GetRelocTypeInner(const MCReloc &Reloc, bool IsPCRel, - MCContext &Ctx) const; + unsigned getRelocTypeInner(const MCReloc &Reloc, MCContext &Ctx) const; public: ARMELFObjectWriter(uint8_t OSABI); @@ -72,84 +71,70 @@ unsigned ARMELFObjectWriter::getRelocType(MCAssembler &Asm, const MCReloc &Reloc) const { MCContext &Ctx = Asm.getContext(); - bool IsPCRel = Asm.getBackend().getFixupKindInfo(Reloc.getKind()).Flags & - MCFixupKindInfo::FKF_IsPCRel; - return GetRelocTypeInner(Reloc, IsPCRel, Ctx); + return getRelocTypeInner(Reloc, Ctx); } -unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCReloc &Fixup, - bool IsPCRel, +unsigned ARMELFObjectWriter::getRelocTypeInner(const MCReloc &Fixup, MCContext &Ctx) const { const MCReloc &Target = Fixup; MCSymbolRefExpr::VariantKind Modifier = Target.getAccessVariant(); - if (IsPCRel) { - switch ((unsigned)Fixup.getKind()) { - default: - Ctx.reportFatalError(Fixup.getLoc(), "unsupported relocation on symbol"); - return ELF::R_ARM_NONE; - case FK_PCRel_4: - case FK_Data_4: - switch (Modifier) { - default: - llvm_unreachable("Unsupported Modifier"); - case MCSymbolRefExpr::VK_None: - return ELF::R_ARM_REL32; - case MCSymbolRefExpr::VK_GOTTPOFF: - return ELF::R_ARM_TLS_IE32; - case MCSymbolRefExpr::VK_ARM_GOT_PREL: - return ELF::R_ARM_GOT_PREL; - case MCSymbolRefExpr::VK_ARM_PREL31: - return ELF::R_ARM_PREL31; - } - case ARM::fixup_arm_blx: - case ARM::fixup_arm_uncondbl: - switch (Modifier) { - case MCSymbolRefExpr::VK_PLT: - return ELF::R_ARM_CALL; - case MCSymbolRefExpr::VK_TLSCALL: - return ELF::R_ARM_TLS_CALL; - default: - return ELF::R_ARM_CALL; - } - case ARM::fixup_arm_condbl: - case ARM::fixup_arm_condbranch: - case ARM::fixup_arm_uncondbranch: - return ELF::R_ARM_JUMP24; - case ARM::fixup_t2_condbranch: - return ELF::R_ARM_THM_JUMP19; - case ARM::fixup_t2_uncondbranch: - return ELF::R_ARM_THM_JUMP24; - case ARM::fixup_arm_movt_hi16: - case ARM::fixup_arm_movt_hi16_pc: - return ELF::R_ARM_MOVT_PREL; - case ARM::fixup_arm_movw_lo16: - case ARM::fixup_arm_movw_lo16_pc: - return ELF::R_ARM_MOVW_PREL_NC; - case ARM::fixup_t2_movt_hi16: - case ARM::fixup_t2_movt_hi16_pc: - return ELF::R_ARM_THM_MOVT_PREL; - case ARM::fixup_t2_movw_lo16: - case ARM::fixup_t2_movw_lo16_pc: - return ELF::R_ARM_THM_MOVW_PREL_NC; - case ARM::fixup_arm_thumb_br: - return ELF::R_ARM_THM_JUMP11; - case ARM::fixup_arm_thumb_bcc: - return ELF::R_ARM_THM_JUMP8; - case ARM::fixup_arm_thumb_bl: - case ARM::fixup_arm_thumb_blx: - switch (Modifier) { - case MCSymbolRefExpr::VK_TLSCALL: - return ELF::R_ARM_THM_TLS_CALL; - default: - return ELF::R_ARM_THM_CALL; - } - } - } switch ((unsigned)Fixup.getKind()) { default: Ctx.reportFatalError(Fixup.getLoc(), "unsupported relocation on symbol"); return ELF::R_ARM_NONE; + case FK_PCRel_4: + switch (Modifier) { + default: + llvm_unreachable("Unsupported Modifier"); + case MCSymbolRefExpr::VK_None: + return ELF::R_ARM_REL32; + case MCSymbolRefExpr::VK_GOTTPOFF: + return ELF::R_ARM_TLS_IE32; + case MCSymbolRefExpr::VK_ARM_GOT_PREL: + return ELF::R_ARM_GOT_PREL; + case MCSymbolRefExpr::VK_ARM_PREL31: + return ELF::R_ARM_PREL31; + } + case ARM::fixup_arm_blx: + case ARM::fixup_arm_uncondbl: + switch (Modifier) { + case MCSymbolRefExpr::VK_PLT: + return ELF::R_ARM_CALL; + case MCSymbolRefExpr::VK_TLSCALL: + return ELF::R_ARM_TLS_CALL; + default: + return ELF::R_ARM_CALL; + } + case ARM::fixup_arm_condbl: + case ARM::fixup_arm_condbranch: + case ARM::fixup_arm_uncondbranch: + return ELF::R_ARM_JUMP24; + case ARM::fixup_t2_condbranch: + return ELF::R_ARM_THM_JUMP19; + case ARM::fixup_t2_uncondbranch: + return ELF::R_ARM_THM_JUMP24; + case ARM::fixup_arm_movt_hi16_pc: + return ELF::R_ARM_MOVT_PREL; + case ARM::fixup_arm_movw_lo16_pc: + return ELF::R_ARM_MOVW_PREL_NC; + case ARM::fixup_t2_movt_hi16_pc: + return ELF::R_ARM_THM_MOVT_PREL; + case ARM::fixup_t2_movw_lo16_pc: + return ELF::R_ARM_THM_MOVW_PREL_NC; + case ARM::fixup_arm_thumb_br: + return ELF::R_ARM_THM_JUMP11; + case ARM::fixup_arm_thumb_bcc: + return ELF::R_ARM_THM_JUMP8; + case ARM::fixup_arm_thumb_bl: + case ARM::fixup_arm_thumb_blx: + switch (Modifier) { + case MCSymbolRefExpr::VK_TLSCALL: + return ELF::R_ARM_THM_TLS_CALL; + default: + return ELF::R_ARM_THM_CALL; + } + case FK_Data_1: switch (Modifier) { default: @@ -203,9 +188,6 @@ case MCSymbolRefExpr::VK_ARM_TLSDESCSEQ: return ELF::R_ARM_TLS_DESCSEQ; } - case ARM::fixup_arm_condbranch: - case ARM::fixup_arm_uncondbranch: - return ELF::R_ARM_JUMP24; case ARM::fixup_arm_movt_hi16: switch (Modifier) { default: @@ -216,7 +198,6 @@ return ELF::R_ARM_MOVT_BREL; } case ARM::fixup_arm_movw_lo16: - case ARM::fixup_arm_movw_lo16_pc: switch (Modifier) { default: llvm_unreachable("Unsupported Modifier"); @@ -235,7 +216,6 @@ return ELF::R_ARM_THM_MOVT_BREL; } case ARM::fixup_t2_movw_lo16: - case ARM::fixup_t2_movw_lo16_pc: switch (Modifier) { default: llvm_unreachable("Unsupported Modifier");