<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - arm asm label calculation error in sub" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24346&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=Quqh_Vizt85Mym_R-IObbH0cPWwOb298liKiLiv-ri0&s=s9KIM1IojVGJL3j2P6mx2uekPVFshOOja8xNBvoU074&e=">24346</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>arm asm label calculation error in sub
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>shenhan@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The label calculation is not correct in the following simple ARM asm

.text
.syntax unified
.code 32
.type DATA,%object
.align 5
DATA:
.word 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5
.word 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5
.word 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3
.word 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174
.word 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc
.word 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da
.word 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7
.word 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967
.word 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13
.word 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85
.word 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3
.word 0xd192e819,0xd6990624,0xf40e3585,0x106aa070
.word 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5
.word 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3
.word 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208
.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
.word 0x90befffa,0xa4506ceb,0x90befffa,0xa4506ceb
.size DATA,.-DATA
.word 0 @ terminator

.global FOO
.type FOO,%function
.align 5
FOO:
.L1:
 adr r3,.L1
 sub r3, r3, #(.L1-DATA) 
 @ Now r3 should point to start of DATA (0)

.size FOO,.-FOO

This is what I get from gnu-as- 
00000160 <FOO>:
 160:   e24f3008        sub     r3, pc, #8      ; Now r3 is 0x160
 164:   e2433e16        sub     r3, r3, #352    ; 0x160

The 2 subs results 0 (which is the correct starting address) in r3

Now this is what I get from clang - 
00000160 <FOO>:
 160:   e24f3008        sub     r3, pc, #8      ; Now r3 is 0x160
 164:   e2433160        sub     r3, r3, #96, 2  ; After this r3 is not zero

The 2 subs results in a different value than the start address of DATA. (The
relocation section of the object file is empty)</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>