From: Joerg Sonnenberger Date: Thu, 2 Oct 2014 13:41:42 +0000 (+0000) Subject: Support padding unaligned data in .text. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=92583e0712b53e669ea26b47025522a47cc8fe3b Support padding unaligned data in .text. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218870 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp b/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp index d8e6128cd54..efeb54d91b8 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp @@ -367,7 +367,12 @@ bool MipsAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const { // Check for a less than instruction size number of bytes // FIXME: 16 bit instructions are not handled yet here. // We shouldn't be using a hard coded number for instruction size. - if (Count % 4) return false; + + // If the count is not 4-byte aligned, we must be writing data into the text + // section (otherwise we have unaligned instructions, and thus have far + // bigger problems), so just write zeros instead. + for (uint64_t i = 0, e = Count % 4; i != e; ++i) + OW->Write8(0); uint64_t NumNops = Count / 4; for (uint64_t i = 0; i != NumNops; ++i) diff --git a/test/MC/Mips/unaligned-nops.s b/test/MC/Mips/unaligned-nops.s new file mode 100644 index 00000000000..ebbbb40f4dc --- /dev/null +++ b/test/MC/Mips/unaligned-nops.s @@ -0,0 +1,4 @@ +# RUN: llvm-mc -filetype=obj -triple=mipsel %s -o %t +.byte 1 +.p2align 2 +foo: