summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-12-09 20:27:52 +0000
committerOwen Anderson <resistor@mac.com>2010-12-09 20:27:52 +0000
commit3ef19d9d48ea21def23eb4c012ae9f8c17c00432 (patch)
tree12d06d4fd4f8b0e20e23375e610f5546c73fd491 /llvm/lib
parent68b27eb9d11061b2ca3ef757b4952c26f0ca072b (diff)
downloadbcm5719-llvm-3ef19d9d48ea21def23eb4c012ae9f8c17c00432.tar.gz
bcm5719-llvm-3ef19d9d48ea21def23eb4c012ae9f8c17c00432.zip
Fix an issue in some Thumb fixups, where the effective PC address needs to be 4-byte aligned when calculating
the offset. Add a new fixup flag to represent this, and use it for the one fixups that I have a testcase for needing this. It's quite likely that the other Thumb fixups will need this too, and to have their fixup encoding logic adjusted accordingly. llvm-svn: 121408
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp11
-rw-r--r--llvm/lib/Target/ARM/ARMAsmBackend.cpp4
-rw-r--r--llvm/lib/Target/ARM/ARMMCCodeEmitter.cpp3
3 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 323352ff8b7..319f04cfe70 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -253,8 +253,15 @@ bool MCAssembler::EvaluateFixup(const MCObjectWriter &Writer,
if (IsResolved)
IsResolved = Writer.IsFixupFullyResolved(*this, Target, IsPCRel, DF);
- if (IsPCRel)
- Value -= Layout.getFragmentOffset(DF) + Fixup.getOffset();
+ if (IsPCRel) {
+ bool ShouldAlignPC = Emitter.getFixupKindInfo(
+ Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsAligned;
+ // PC should be aligned to a 4-byte value.
+ if (ShouldAlignPC)
+ Value -= Layout.getFragmentOffset(DF) + (Fixup.getOffset() & ~0x3);
+ else
+ Value -= Layout.getFragmentOffset(DF) + Fixup.getOffset();
+ }
return IsResolved;
}
diff --git a/llvm/lib/Target/ARM/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/ARMAsmBackend.cpp
index 6be9f9288e2..606437efbb4 100644
--- a/llvm/lib/Target/ARM/ARMAsmBackend.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmBackend.cpp
@@ -100,10 +100,10 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
}
case ARM::fixup_arm_ldst_pcrel_12:
// ARM PC-relative values are offset by 8.
- Value -= 6;
+ Value -= 4;
case ARM::fixup_t2_ldst_pcrel_12: {
// Offset by 4, adjusted by two due to the half-word ordering of thumb.
- Value -= 2;
+ Value -= 4;
bool isAdd = true;
if ((int64_t)Value < 0) {
Value = -Value;
diff --git a/llvm/lib/Target/ARM/ARMMCCodeEmitter.cpp b/llvm/lib/Target/ARM/ARMMCCodeEmitter.cpp
index c81833b28f8..4d8791c9989 100644
--- a/llvm/lib/Target/ARM/ARMMCCodeEmitter.cpp
+++ b/llvm/lib/Target/ARM/ARMMCCodeEmitter.cpp
@@ -47,7 +47,8 @@ public:
const static MCFixupKindInfo Infos[] = {
// name off bits flags
{ "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},
{ "fixup_arm_pcrel_10", 1, 24, MCFixupKindInfo::FKF_IsPCRel },
{ "fixup_t2_pcrel_10", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
{ "fixup_arm_adr_pcrel_12", 1, 24, MCFixupKindInfo::FKF_IsPCRel },
OpenPOWER on IntegriCloud