<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 - Crash given weak symbol in C, normal symbol in inline assembly"
   href="https://bugs.llvm.org/show_bug.cgi?id=43187">43187</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash given weak symbol in C, normal symbol in inline assembly
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jonathanchesterfield@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For example,

__attribute__((weak)) int x = 4;
__asm__(".type x,@object\n"
        ".data\n"
        ".p2align 2\n"
        "x:\n"
        ".long 42\n");
=> fatal error: error in backend: symbol 'x' is already defined

or, equivalently:

module asm ".type x,@object"
module asm ".data"
module asm ".p2align 2"
module asm "x:"
module asm ".long 42"
@x = weak dso_local global i32 4, align 4
=> same error

Expected behaviour is for x to have the initial value 42, replacing the weak
symbol. Observed behaviour is the fatal error.

Using non-inline assembly works as expected. Symbol overridden, no error.

Weak on either (or both) symbol(s) shows the same behaviour.

Non-reduced case has inline assembly in one translation unit and the weak
symbol in another. Compiling each separately to an elf and linking works fine,
llvm-link then llc fails as above.</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>