aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/ARM/ARMAsmBackend.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2010-12-17 19:03:02 +0000
committerJim Grosbach <grosbach@apple.com>2010-12-17 19:03:02 +0000
commita3dbd3a2444f2531763ba05b64a30932542a631f (patch)
treeefb1e1b47cd677a5088fcaa71fa0b88d525991b3 /lib/Target/ARM/ARMAsmBackend.cpp
parent7fb866643e76dc598473b666439a42a11d97a58c (diff)
downloadexternal_llvm-a3dbd3a2444f2531763ba05b64a30932542a631f.zip
external_llvm-a3dbd3a2444f2531763ba05b64a30932542a631f.tar.gz
external_llvm-a3dbd3a2444f2531763ba05b64a30932542a631f.tar.bz2
If The ARM WriteNopData() gets an unaligned byte count to pad out, fill in with
a partial value. rdar://8782954 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMAsmBackend.cpp')
-rw-r--r--lib/Target/ARM/ARMAsmBackend.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Target/ARM/ARMAsmBackend.cpp b/lib/Target/ARM/ARMAsmBackend.cpp
index 0a11129..e9fed97 100644
--- a/lib/Target/ARM/ARMAsmBackend.cpp
+++ b/lib/Target/ARM/ARMAsmBackend.cpp
@@ -123,18 +123,26 @@ void ARMAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
bool ARMAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
if (isThumb()) {
- assert (((Count & 1) == 0) && "Unaligned Nop data fragment!");
// FIXME: 0xbf00 is the ARMv7 value. For v6 and before, we'll need to
// use 0x46c0 (which is a 'mov r8, r8' insn).
- Count /= 2;
- for (uint64_t i = 0; i != Count; ++i)
+ uint64_t NumNops = Count / 2;
+ for (uint64_t i = 0; i != NumNops; ++i)
OW->Write16(0xbf00);
+ if (Count & 1)
+ OW->Write8(0);
return true;
}
// ARM mode
- Count /= 4;
- for (uint64_t i = 0; i != Count; ++i)
+ uint64_t NumNops = Count / 4;
+ for (uint64_t i = 0; i != NumNops; ++i)
OW->Write32(0xe1a00000);
+ switch (Count % 4) {
+ default: break; // No leftover bytes to write
+ case 1: OW->Write8(0); break;
+ case 2: OW->Write16(0); break;
+ case 3: OW->Write16(0); OW->Write8(0xa0); break;
+ }
+
return true;
}