<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 - --discard-all is not supported with -r output"
   href="https://bugs.llvm.org/show_bug.cgi?id=37782">37782</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>--discard-all is not supported with -r output
          </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
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In normal links, the --discard* family of options throws away certain symbols,
depending on the nature of the output and which exact switch is specified. We
do not support this switch at all for relocatable output. At least for some
situations, there is no reason not to, that I'm aware of.

This seems to have been implemented as the fix to <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - relocations to local symbols not handled with -r"
   href="show_bug.cgi?id=31252">bug 31252</a>, which prevents any
discarding for relocatable output, to prevent discarding of certain temporary
symbols. Whilst this behaviour should be the default, it shouldn't, in my
opinion, be the behaviour when --discard* switches are explicitly specified.
Note that ld.bfd follows a different approach:

// test.s
.local local
local:
        ret

.global global
global:
        ret

<span class="quote">> clang -c test.s
> ld.lld -r --discard-all test.o -o test.ro
> llvm-objdump -t test.ro</span >
test.ro:        file format ELF64-x86-64

SYMBOL TABLE:
0000000000000000         *UND*           00000000 
0000000000000000         .text           00000000 local
0000000000000000 l    d  .text           00000000 .text
0000000000000000 l    d  .data           00000000 .data
0000000000000000 l    d  .bss            00000000 .bss
0000000000000001         .text           00000000 global

<span class="quote">> ld.bfd -r --discard-all test.o -o test.ro
> llvm-objdump -t test.ro</span >
test.ro:        file format ELF64-x86-64

SYMBOL TABLE:
0000000000000000         *UND*           00000000 
0000000000000000 l    d  .text           00000000 .text
0000000000000000 l    d  .data           00000000 .data
0000000000000000 l    d  .bss            00000000 .bss
0000000000000001         .text           00000000 global

Note that "local" has not been discarded.</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>