From 05018c2f2872a05b1a2fff1a9934621ba1f38084 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Thu, 9 Dec 2010 20:27:52 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121408 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCAssembler.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/MC/MCAssembler.cpp') diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 323352ff8b..319f04cfe7 100644 --- a/lib/MC/MCAssembler.cpp +++ b/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; } -- cgit v1.2.3