[llvm-bugs] [Bug 39919] New: store happening to wrongly loaded address with thumb2

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 7 12:10:58 PST 2018


            Bug ID: 39919
           Summary: store happening to wrongly loaded address with thumb2
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: raj.khem at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 21205
  --> https://bugs.llvm.org/attachment.cgi?id=21205&action=edit

This issue pops up when compiling busybox for arm using thumb2 ISA. Getty
applet segfaults. 

Program received signal SIGSEGV, Segmentation fault.
getty_main (argc=<optimized out>, argv=0x7efffd58) at loginutils/getty.c:561
warning: Source file is more recent than executable.
561             G.eol = '\r';

This is also present in the attached reproducer

clang  -target armv7l-linux-gnueabihf -S -Os -mthumb getty.c


        .code   16                      @ @getty_main
@ %bb.0:
        .save   {r4, r5, r6, r7, lr}
        push    {r4, r5, r6, r7, lr}
        .setfp  r7, sp, #12
        add     r7, sp, #12
        .save   {r11}
        str     r11, [sp, #-4]!
        .pad    #16
        sub     sp, #16
        mov.w   r0, #260
        mov     r6, r1
        bl      xzalloc  <--------------------------- allocate ptr_to_globals
struct (return address of mem in r0)
        ldr     r2, .LCPI0_0
        ldr     r3, .LCPI0_1
        add     r2, pc
        ldr     r5, .LCPI0_2
        ldr     r1, .LCPI0_3
        add     r3, pc
        ldr     r4, [r2] <--------------------------- loads the address of
ptr_to_globals struct
        add     r5, pc
        str     r0, [r2] <-------------------------- Stores the address
returned from xzalloc()
        add     r1, pc
        str     r3, [r0, #20]
        add.w   r2, r4, #20
        str     r5, [r0, #4]
        movs    r0, #13
        strb.w  r0, [r4, #68] <------------- Stores '\r' to globals+68 which is
location of ptr_to_globals.eol
        adds    r0, r4, #4
        add.w   r3, r4, #8
        strd    r2, r0, [sp]
        add.w   r2, r4, #16
        mov     r0, r6
        str     r4, [sp, #8]
        bl      getopt32
        add     sp, #16
        ldr     r11, [sp], #4
        pop     {r4, r5, r6, r7, pc}
        .p2align        2

As can be seen above, it has loaded address of ptr_to_globals into r4 before
return of xzalloc() in r0 is stored into it.

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/20181207/462acb69/attachment.html>

More information about the llvm-bugs mailing list