<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 - Improve error message for relocation against discarded section"
   href="https://bugs.llvm.org/show_bug.cgi?id=41133">41133</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improve error message for relocation against discarded section
          </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>All
          </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>smeenai@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>grimar@accesssoftek.com, i@maskray.me, llvm-bugs@lists.llvm.org, peter.smith@linaro.org, peter@pcc.me.uk, ruiu@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>gold gained some nice enhancements to its error messages for relocations
against discarded sections recently (I believe with version 2.31). For example,

$ cat group1.s
.section .text.foo,"axG",@progbits,foo,comdat
.globl foo
foo:
        retq

$ cat group2.s
.section .text.foo,"axG",@progbits,foo,comdat
.globl foo
foo:
        retq
.globl bar
bar:
        retq

$ cat main.s
.text
.globl main
main:
        jmp     bar

$ llvm-mc -filetype=obj -o group1.o group1.s
$ llvm-mc -filetype=obj -o group2.o group2.s
$ llvm-mc -filetype=obj -o main.o main.s
$ ld.gold -e main group1.o group2.o main.o
main.o(.text+0x1): error: relocation refers to global symbol "bar", which is
defined in a discarded section

It displays more information if the discarded section is in the same object
file as the relocation to it:

$ cat group3.s
.section .text.foo,"axG",@progbits,foo,comdat
.globl foo
foo:
        retq
.globl bar
bar:
        retq
.text
.globl main
main:
        jmp     bar

$ llvm-mc -filetype=obj -o group3.o group3.s
$ ld.gold -e main group1.o group3.o
group3.o(.text+0x1): error: relocation refers to global symbol "bar", which is
defined in a discarded section
  section group signature: "foo"
  prevailing definition is from group1.o

LLD just displays an undefined symbol error for both cases. That's technically
accurate, but it can be confusing, since you do have a definition in your
object files, just not one that was part of a prevailing COMDAT group. Would it
be possible to keep track of discarded COMDAT groups in LLD to display more
informative error messages?</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>