Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] Improve error message for relocations to symbols defined in dis…
…carded sections Rather than report "undefined symbol: ", give more informative message about the object file that defines the discarded section. In particular, PR41133, if the section is a discarded COMDAT, print the section group signature and the object file with the prevailing definition. This is useful to track down some ODR issues. We need to * add `uint32_t DiscardedSecIdx` to Undefined for this feature. * make ComdatGroups public and change its type to DenseMap<CachedHashStringRef, const InputFile *> Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D59649 llvm-svn: 361359
- Loading branch information
Showing
9 changed files
with
144 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t1.o | ||
# RUN: echo '.section .text.foo,"axG",@progbits,foo,comdat; .globl foo; foo:' | \ | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t2.o | ||
# RUN: echo '.section .text.foo,"axG",@progbits,foo,comdat; .globl bar; bar:' | \ | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t3.o | ||
|
||
# RUN: not ld.lld %t1.o %t2.o %t3.o -o /dev/null 2>&1 | FileCheck %s | ||
|
||
# CHECK: error: relocation refers to a symbol in a discarded section: bar | ||
# CHECK-NEXT: >>> defined in {{.*}}3.o | ||
# CHECK-NEXT: >>> section group signature: foo | ||
# CHECK-NEXT: >>> prevailing definition is in {{.*}}2.o | ||
# CHECK-NEXT: >>> referenced by {{.*}}1.o:(.text+0x1) | ||
|
||
.globl _start | ||
_start: | ||
jmp bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o | ||
# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s | ||
|
||
# CHECK: error: relocation refers to a symbol in a discarded section: foo | ||
# CHECK-NEXT: >>> defined in {{.*}}.o | ||
# CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x1) | ||
|
||
.globl _start | ||
_start: | ||
jmp foo | ||
|
||
.section .foo,"ae" | ||
.globl foo | ||
foo: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o | ||
# RUN: echo '.section .foo,"ae"; .weak foo; foo:' | \ | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o | ||
# RUN: not ld.lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck %s | ||
|
||
# Because foo defined in %t1.o is weak, it does not override global undefined | ||
# in %t.o | ||
# CHECK-NOT: discarded section | ||
# CHECK: undefined symbol: foo | ||
|
||
.globl _start | ||
_start: | ||
jmp foo |