diff options
author | Kevin Enderby <enderby@apple.com> | 2012-07-30 18:46:15 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2012-07-30 18:46:15 +0000 |
commit | 5af4de18ef244d2ce52b2f2ac0a703409b6fdfe6 (patch) | |
tree | 961d72e11d90fafd0ad8afc9c9e120e8438e822a | |
parent | 3f63a589788995a724bc4587d022fe15ea8576ba (diff) | |
download | external_llvm-5af4de18ef244d2ce52b2f2ac0a703409b6fdfe6.zip external_llvm-5af4de18ef244d2ce52b2f2ac0a703409b6fdfe6.tar.gz external_llvm-5af4de18ef244d2ce52b2f2ac0a703409b6fdfe6.tar.bz2 |
Fix a bug in ARMMachObjectWriter::RecordRelocation() in ARMMachObjectWriter.cpp
where the other_half of the movt and movw relocation entries needs to get set
and only with the 16 bits of the other half.
rdar://10038370
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160978 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp | 11 | ||||
-rw-r--r-- | test/MC/MachO/ARM/thumb2-movw-fixup.s | 44 |
2 files changed, 53 insertions, 2 deletions
diff --git a/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp b/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp index 78faf59..a51e0fa 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp @@ -408,15 +408,22 @@ void ARMMachObjectWriter::RecordRelocation(MachObjectWriter *Writer, // Even when it's not a scattered relocation, movw/movt always uses // a PAIR relocation. if (Type == macho::RIT_ARM_Half) { - // The other-half value only gets populated for the movt relocation. + // The other-half value only gets populated for the movt and movw + // relocation entries. uint32_t Value = 0;; switch ((unsigned)Fixup.getKind()) { default: break; + case ARM::fixup_arm_movw_lo16: + case ARM::fixup_arm_movw_lo16_pcrel: + case ARM::fixup_t2_movw_lo16: + case ARM::fixup_t2_movw_lo16_pcrel: + Value = (FixedValue >> 16) & 0xffff; + break; case ARM::fixup_arm_movt_hi16: case ARM::fixup_arm_movt_hi16_pcrel: case ARM::fixup_t2_movt_hi16: case ARM::fixup_t2_movt_hi16_pcrel: - Value = FixedValue; + Value = FixedValue & 0xffff; break; } macho::RelocationEntry MREPair; diff --git a/test/MC/MachO/ARM/thumb2-movw-fixup.s b/test/MC/MachO/ARM/thumb2-movw-fixup.s new file mode 100644 index 0000000..57973a8 --- /dev/null +++ b/test/MC/MachO/ARM/thumb2-movw-fixup.s @@ -0,0 +1,44 @@ +@ RUN: llvm-mc -mcpu=cortex-a8 -triple thumbv7-apple-darwin10 -filetype=obj -o - < %s | macho-dump | FileCheck %s + +@ rdar://10038370 + + .syntax unified + .text + .align 2 + .code 16 + .thumb_func _foo + movw r2, :lower16:L1 + movt r2, :upper16:L1 + movw r12, :lower16:L2 + movt r12, :upper16:L2 + .space 70000 + + .data +L1: .long 0 +L2: .long 0 + +@ CHECK: ('_relocations', [ +@ CHECK: # Relocation 0 +@ CHECK: (('word-0', 0xc), +@ CHECK: ('word-1', 0x86000002)), +@ CHECK: # Relocation 1 +@ CHECK: (('word-0', 0x1184), +@ CHECK: ('word-1', 0x16ffffff)), +@ CHECK: # Relocation 2 +@ CHECK: (('word-0', 0x8), +@ CHECK: ('word-1', 0x84000002)), +@ CHECK: # Relocation 3 +@ CHECK: (('word-0', 0x1), +@ CHECK: ('word-1', 0x14ffffff)), +@ CHECK: # Relocation 4 +@ CHECK: (('word-0', 0x4), +@ CHECK: ('word-1', 0x86000002)), +@ CHECK: # Relocation 5 +@ CHECK: (('word-0', 0x1180), +@ CHECK: ('word-1', 0x16ffffff)), +@ CHECK: # Relocation 6 +@ CHECK: (('word-0', 0x0), +@ CHECK: ('word-1', 0x84000002)), +@ CHECK: # Relocation 7 +@ CHECK: (('word-0', 0x1), +@ CHECK: ('word-1', 0x14ffffff)), |