<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 - Add a new option to ignore undefined symbols in DSO"
   href="https://bugs.llvm.org/show_bug.cgi?id=43554">43554</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Add a new option to ignore undefined symbols in DSO
          </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>enhancement
          </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>ruiu@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>lld used to ignore undefined symbols in DSOs, but I changed that behavior in
<a href="https://reviews.llvm.org/rL325849">https://reviews.llvm.org/rL325849</a> to improve compatibility with GNU linkers.
That resulted in an unintended consequence on Android.

First, let me explain why I made lld to try to resolve undefined symbols in
DSO. The current lld's behavior is as follows.

  1. When you are creating a DSO, Unix linkers traditionally allow undefined
symbols to remain. Remaining undefined symbols from input object files are left
as undefined symbols in a DSO.

  2. When you are creating an executable, Unix linkers traditionally try to
resolve all undefined symbols for all input files including DSOs. Undefined
symbols in DSOs that cannot be resolved by any other DSOs or by a main
executable are usually detected at this stage. If the linker doesn't do this,
such undefined symbols would be detected at dynamic-link time (i.e. you can't
find them until you try to run a program), which is much more inconvenient.

I think the above (1) and (2) are coherent and make sense. Being said that,
that doesn't seems like the only approach that make sense. Think about the
following feature combination.

  3. Do not allow undefined symbols in DSOs. This can be achieved by passing
`--no-undefined` option to the linker along with `--shared`.

  4. Do not try to resolve undefined symbols in DSOs when creating an
executable, assuming all DSO undefined symbols will be resolved successfully at
runtime.

It seems (3) and (4) are also coherent and make sense.

On Android, `--no-undefined` is actually always passed to the linker. So, on
Android, we don't have to try to resolve DSO undefined symbols at link-time.

The problem is that it seems like we don't have an option to achieve (4)'s
behavior. Maybe we should add a new option for that. What do you think?</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>