<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 - [LLD/ELF] LLD change inflates elf binary size when linked with no-rosegment"
   href="https://bugs.llvm.org/show_bug.cgi?id=43997">43997</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[LLD/ELF] LLD change inflates elf binary size when linked with no-rosegment
          </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>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>ELF
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22811" name="attach_22811" title="qemu reproducible tarball">attachment 22811</a> <a href="attachment.cgi?id=22811&action=edit" title="qemu reproducible tarball">[details]</a></span>
qemu reproducible tarball

The problem was discovered when the elf binary size of some packages after llvm
toolchain update has drastically increased.
The binaries were built with ld.lld --no-rosegment.

For example qemu_x86_64 elf binary size changed from 4MB to 1.6GB.


After bisection I located the commit which introduced the problem:

06bb7dfbd445fe928b0ae0263ba9df1acd861c41
[ELF] Map the ELF header at imageBase

Here is the difference of readelf before and after the commit:

BEFORE:
-------------------------
$ readelf --sections  --wide qemu-x86_64

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg
Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00     
0   0  0
  [ 1] .text             PROGBITS        0000000060000000 001000 245dc6 00  AX 
0   0 32

AFTER:
-------------------------
$ readelf --sections qemu-x86_64

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg
Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00     
0   0  0
  [ 1] .text             PROGBITS        0000000060000000 5fe00000 245dc6 00 
AX  0   0 32


Steps to reproduce:

tar -axf qemu.tar && cd qemu
ld.lld @response.txt
ls -lh qemu-x86_64
readelf --sections --wide qemu-x86_64</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>