llvm-6502/lib
David Peixotto 1edc33b924 ARM integrated assembler generates incorrect nop opcode
This patch fixes a bug in the assembler that was causing bad code to
be emitted.  When switching modes in an assembly file (e.g. arm to
thumb mode) we would always emit the opcode from the original mode.

Consider this small example:

$ cat align.s
.code 16
foo:
  add r0, r0
.align 3
  add r0, r0

$ llvm-mc -triple armv7-none-linux align.s -filetype=obj -o t.o
$ llvm-objdump -triple thumbv7 -d t.o
Disassembly of section .text:
foo:
       0:       00 44         add     r0, r0
       2:       00 f0 20 e3   blx #4195904
       6:       00 00         movs    r0, r0
       8:       00 44         add     r0, r0

This shows that we have actually emitted an arm nop (e320f000)
instead of a thumb nop. Unfortunately, this encodes to a thumb
branch which causes bad things to happen when compiling assembly
code with align directives.

The fix is to notify the ARMAsmBackend when we switch mode. The
MCMachOStreamer was already doing this correctly. This patch makes
the same change for the MCElfStreamer.

There is still a bug in the way nops are emitted for alignment
because the MCAlignment fragment does not store the correct mode.
The ARMAsmBackend will emit nops for the last mode it knew about. In
the example above, we still generate an arm nop if we add a `.code
32` to the end of the file.

PR18019


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195677 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-25 19:11:13 +00:00
..
Analysis Don't speculate loads under ThreadSanitizer 2013-11-21 07:29:28 +00:00
AsmParser Make it explicit that nulls are not allowed in names. 2013-11-19 21:12:39 +00:00
Bitcode Fix spacing, forward declare order. 2013-11-18 02:51:33 +00:00
CodeGen Unrevert r195599 with testcase fix. 2013-11-25 18:05:22 +00:00
DebugInfo DebugInfo: Make pubnames header printing similar to unit header printing 2013-11-01 17:53:30 +00:00
ExecutionEngine [mips] Resolve relocation for the stubs in MCJIT when load address is known 2013-11-19 21:56:00 +00:00
IR [PM] Complete the cross-layer interfaces with a Module-to-Function 2013-11-23 01:25:07 +00:00
IRReader [llvm-c] Expose IRReader interface 2013-11-06 09:21:15 +00:00
Linker Revert "Move copying of global initializers below the cloning of functions." 2013-11-09 00:43:18 +00:00
LTO Use array_pod_sort instead of std::sort 2013-11-16 16:15:56 +00:00
MC ARM integrated assembler generates incorrect nop opcode 2013-11-25 19:11:13 +00:00
Object Path: Recognize COFF import library file magic. 2013-11-15 21:22:02 +00:00
Option Use startswith_lower() where possible. 2013-11-04 19:22:50 +00:00
Support Make helper function static. 2013-11-25 15:40:24 +00:00
TableGen Fix most memory leaks in tablegen. 2013-10-31 04:07:41 +00:00
Target Fix indentation typo 2013-11-25 17:04:35 +00:00
Transforms Migrate metadata information from scalar to vector instructions during 2013-11-23 00:48:34 +00:00
CMakeLists.txt Move LTO support library to a component, allowing it to be tested 2013-09-24 23:52:22 +00:00
LLVMBuild.txt Move LTO support library to a component, allowing it to be tested 2013-09-24 23:52:22 +00:00
Makefile Reformat Makefile. No other changes. 2013-10-30 04:03:03 +00:00