<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 - Incorrect alignment of common symbol for mixed LTO + native object"
   href="https://bugs.llvm.org/show_bug.cgi?id=47819">47819</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect alignment of common symbol for mixed LTO + native object
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>ELF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jh7370.2008@my.bristol.ac.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If a bitcode file defines a common symbol with a larger size, but smaller
alignment, and a native object file defines a common symbol with a smaller
size, but larger alignment, the alignment from smaller symbol is ignored,
unlike the other possible resolution cases of bitcode + bitcode, object +
object, or bitcode + object where the object had the larger alignment.

The problem is because the compiled LTO output symbol unconditionally replaces
the symbol LLD already has internally in this case. Since the LTO output will
only have the alignment of the symbol from the bitcode, it has a smaller
alignment than the one in memory, and so the correct alignment is lost.

Example inputs:

; common.ll
target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@b = common global i64 0, align 4

# common2.s
.comm b,8,16

Result: b has size 8, and the .bss section has 4-byte alignment (it should be
size 8 and 16-byte alignment).</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>