forked from OSchip/llvm-project
parent
b3f04f468e
commit
622ad5170b
|
@ -27,8 +27,8 @@ struct MCFixupKindInfo {
|
||||||
/// evaluate fixup values in a target independent manner when possible.
|
/// evaluate fixup values in a target independent manner when possible.
|
||||||
FKF_IsPCRel = (1 << 0),
|
FKF_IsPCRel = (1 << 0),
|
||||||
|
|
||||||
// Should this fixup kind force a 4-byte aligned effective PC value?
|
/// Should this fixup kind force a 4-byte aligned effective PC value?
|
||||||
FKF_IsAligned = (1 << 1)
|
FKF_IsAlignedDownTo32Bits = (1 << 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A target specific name for the fixup kind. The names will be unique for
|
/// A target specific name for the fixup kind. The names will be unique for
|
||||||
|
|
|
@ -248,14 +248,18 @@ bool MCAssembler::EvaluateFixup(const MCObjectWriter &Writer,
|
||||||
if (IsResolved)
|
if (IsResolved)
|
||||||
IsResolved = Writer.IsFixupFullyResolved(*this, Target, IsPCRel, DF);
|
IsResolved = Writer.IsFixupFullyResolved(*this, Target, IsPCRel, DF);
|
||||||
|
|
||||||
|
bool ShouldAlignPC = Emitter.getFixupKindInfo(Fixup.getKind()).Flags &
|
||||||
|
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits;
|
||||||
|
assert((ShouldAlignPC ? IsPCRel : true) &&
|
||||||
|
"FKF_IsAlignedDownTo32Bits is only allowed on PC-relative fixups!");
|
||||||
|
|
||||||
if (IsPCRel) {
|
if (IsPCRel) {
|
||||||
bool ShouldAlignPC = Emitter.getFixupKindInfo(
|
uint32_t Offset = Fixup.getOffset();
|
||||||
Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsAligned;
|
|
||||||
// PC should be aligned to a 4-byte value.
|
// A number of ARM fixups in Thumb mode require that the effective PC
|
||||||
if (ShouldAlignPC)
|
// address be determined as the 32-bit aligned version of the actual offset.
|
||||||
Value -= Layout.getFragmentOffset(DF) + (Fixup.getOffset() & ~0x3);
|
if (ShouldAlignPC) Offset &= 0x3;
|
||||||
else
|
Value -= Layout.getFragmentOffset(DF) + Offset;
|
||||||
Value -= Layout.getFragmentOffset(DF) + Fixup.getOffset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ARM fixups based from a thumb function address need to have the low
|
// ARM fixups based from a thumb function address need to have the low
|
||||||
|
|
|
@ -51,15 +51,15 @@ public:
|
||||||
// Name Offset (bits) Size (bits) Flags
|
// Name Offset (bits) Size (bits) Flags
|
||||||
{ "fixup_arm_ldst_pcrel_12", 1, 24, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_arm_ldst_pcrel_12", 1, 24, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "fixup_t2_ldst_pcrel_12", 0, 32, MCFixupKindInfo::FKF_IsPCRel |
|
{ "fixup_t2_ldst_pcrel_12", 0, 32, MCFixupKindInfo::FKF_IsPCRel |
|
||||||
MCFixupKindInfo::FKF_IsAligned},
|
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
|
||||||
{ "fixup_arm_pcrel_10", 1, 24, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_arm_pcrel_10", 1, 24, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "fixup_t2_pcrel_10", 0, 32, MCFixupKindInfo::FKF_IsPCRel |
|
{ "fixup_t2_pcrel_10", 0, 32, MCFixupKindInfo::FKF_IsPCRel |
|
||||||
MCFixupKindInfo::FKF_IsAligned},
|
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
|
||||||
{ "fixup_thumb_adr_pcrel_10",0, 8, MCFixupKindInfo::FKF_IsPCRel |
|
{ "fixup_thumb_adr_pcrel_10",0, 8, MCFixupKindInfo::FKF_IsPCRel |
|
||||||
MCFixupKindInfo::FKF_IsAligned},
|
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
|
||||||
{ "fixup_arm_adr_pcrel_12", 1, 24, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_arm_adr_pcrel_12", 1, 24, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "fixup_t2_adr_pcrel_12", 0, 32, MCFixupKindInfo::FKF_IsPCRel |
|
{ "fixup_t2_adr_pcrel_12", 0, 32, MCFixupKindInfo::FKF_IsPCRel |
|
||||||
MCFixupKindInfo::FKF_IsAligned},
|
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
|
||||||
{ "fixup_arm_branch", 0, 24, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_arm_branch", 0, 24, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "fixup_t2_condbranch", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_t2_condbranch", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "fixup_t2_uncondbranch", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_t2_uncondbranch", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
|
|
Loading…
Reference in New Issue