<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - store happening to wrongly loaded address with thumb2"
   href="https://bugs.llvm.org/show_bug.cgi?id=39919">39919</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>store happening to wrongly loaded address with thumb2
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>raj.khem@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21205" name="attach_21205" title="testcase">attachment 21205</a> <a href="attachment.cgi?id=21205&action=edit" title="testcase">[details]</a></span>
testcase

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
        .thumb_func
getty_main:
        .fnstart
@ %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
.LPC0_0:
        add     r2, pc
        ldr     r5, .LCPI0_2
        ldr     r1, .LCPI0_3
.LPC0_1:
        add     r3, pc
        ldr     r4, [r2] <--------------------------- loads the address of
ptr_to_globals struct
.LPC0_2:
        add     r5, pc
        str     r0, [r2] <-------------------------- Stores the address
returned from xzalloc()
.LPC0_3:
        add     r1, pc
        @APP
        @NO_APP
        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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>