[llvm-bugs] [Bug 41133] New: Improve error message for relocation against discarded section

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 18 22:56:56 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41133

            Bug ID: 41133
           Summary: Improve error message for relocation against discarded
                    section
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: smeenai at fb.com
                CC: grimar at accesssoftek.com, i at maskray.me,
                    llvm-bugs at lists.llvm.org, peter.smith at linaro.org,
                    peter at pcc.me.uk, ruiu at google.com

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", at progbits,foo,comdat
.globl foo
foo:
        retq

$ cat group2.s
.section .text.foo,"axG", at 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", at 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?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190319/1aebe98e/attachment.html>


More information about the llvm-bugs mailing list