[llvm-bugs] [Bug 48512] New: [arm assembler]: Incorrect ARM alignment NOPs in mixed ARM and Thumb assembly

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 14 19:23:09 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48512

            Bug ID: 48512
           Summary: [arm assembler]: Incorrect ARM alignment NOPs in mixed
                    ARM and Thumb assembly
           Product: libraries
           Version: 10.0
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
          Assignee: unassignedbugs at nondot.org
          Reporter: husseydevin at gmail.com
                CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com,
                    Ties.Stuij at arm.com

Seems to be related to bug 18019.

In a mixed ARM and Thumb file, two Thumb NOPs will be emitted in a manual
alignment, even in ARM mode.

This rarely causes an issue in practice, as most uses of 8-byte alignment are
for constant pools which will be branched over anyways, but it is an issue
nonetheless.

    .syntax unified
    .text
    .globl arm
    .type arm, %function
    .p2align 3, 0 @ 8-byte align
arm:
    nop     @ normal nop, now we are not 8-byte aligned
    .p2align 3, 0 @ align again
    bx      lr

    .thumb @ we just need this directive in the file to trigger the bug, no
Thumb code is required


$ clang --target=arm-none-eabi -march=armv4t -c test.s -o test.o
$ arm-none-eabi-objdump -d test.o

test.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <arm>:
   0:   e1a00000        nop                     ; (mov r0, r0)
   4:   46c046c0        strbmi  r4, [r0], r0, asr #13
   8:   e12fff1e        bx      lr

While the manual nop is correct, the implicit alignment nop is two Thumb nops.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201215/7cb61f54/attachment.html>


More information about the llvm-bugs mailing list