<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 --- - Profile Instrumentation and linker (gnu) garbage collection"
   href="https://llvm.org/bugs/show_bug.cgi?id=25286">25286</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Profile Instrumentation and linker (gnu) garbage collection
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If you use the latest clang to build an instrumented executable or shared
library with garbage collection turned on, you will get a linker error if the
linker is gnu ld:

clang -fprofile-instr-generate -fdata-sections -ffunction-sections
-Wl,--gc-sections t.c


The affected platform is Linux and FreeBSD. This is basically a gnu linker bug:

<a href="https://sourceware.org/bugzilla/show_bug.cgi?id=19161">https://sourceware.org/bugzilla/show_bug.cgi?id=19161</a>


It is possible to workaround this by changing clang driver, but the solution is
hacky and temporary, so not desirable.

If you hit the problem, here are three solutions:

1) update the gnu linker (when the fix is released)
2) use gold linker: -fuse-ld=gold
3) use the following linker script -- name it prf_data.x


SECTIONS {
__llvm_prf_data : { KEEP(*(__llvm_prf_data)) }
}

and add the following link option: -Wl,-T,prf_data.x


Keep this bug open as a place holder to document the issue.</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>