diff options
author | Owen Anderson <resistor@mac.com> | 2010-12-09 20:27:52 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2010-12-09 20:27:52 +0000 |
commit | 3ef19d9d48ea21def23eb4c012ae9f8c17c00432 (patch) | |
tree | 12d06d4fd4f8b0e20e23375e610f5546c73fd491 /llvm/lib/MC/MCAssembler.cpp | |
parent | 68b27eb9d11061b2ca3ef757b4952c26f0ca072b (diff) | |
download | llvm-3ef19d9d48ea21def23eb4c012ae9f8c17c00432.zip llvm-3ef19d9d48ea21def23eb4c012ae9f8c17c00432.tar.gz llvm-3ef19d9d48ea21def23eb4c012ae9f8c17c00432.tar.bz2 |
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/MC/MCAssembler.cpp')
-rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 323352f..319f04c 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; } |