[clang] Propagate -ftime-report to offload lto (#122143)
[llvm-project.git] / lld / test / ELF / linkerscript / discard-section.s
blob0bbebac59bb345b2c725a6cb0bd7022b29c7895a
1 # REQUIRES: x86
2 ## Test relocations referencing symbols defined relative to sections discarded by /DISCARD/.
4 # RUN: rm -rf %t && split-file %s %t && cd %t
5 # RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
7 # RUN: not ld.lld --threads=1 -T a.lds a.o b.o -z undefs -o /dev/null 2>&1 | FileCheck %s --check-prefix=LOCAL --implicit-check-not=error:
8 # RUN: not ld.lld --threads=1 -T a.lds a.o b.o -o /dev/null 2>&1 | FileCheck %s --check-prefixes=LOCAL,NONLOCAL --implicit-check-not=error:
9 # RUN: ld.lld -r -T a.lds a.o b.o -o a.ro 2>&1 | FileCheck %s --check-prefix=WARNING --implicit-check-not=warning:
10 # RUN: llvm-readelf -r -s a.ro | FileCheck %s --check-prefix=RELOC
12 # RUN: ld.lld -r --gc-sections -T a.lds a.o b.o -o a.gc.ro --no-fatal-warnings
13 # RUN: llvm-readelf -r -s a.gc.ro | FileCheck %s --check-prefix=RELOC-GC
15 # LOCAL: error: relocation refers to a discarded section: .aaa
16 # LOCAL-NEXT: >>> defined in a.o
17 # LOCAL-NEXT: >>> referenced by a.o:(.bbb+0x0)
19 # NONLOCAL: error: relocation refers to a symbol in a discarded section: global
20 # NONLOCAL-NEXT: >>> defined in a.o
21 # NONLOCAL-NEXT: >>> referenced by b.o:(.data+0x0)
23 # NONLOCAL: error: relocation refers to a symbol in a discarded section: weak
24 # NONLOCAL-NEXT: >>> defined in a.o
25 # NONLOCAL-NEXT: >>> referenced by b.o:(.data+0x8)
27 # NONLOCAL: error: relocation refers to a symbol in a discarded section: weakref1
28 # NONLOCAL-NEXT: >>> defined in a.o
29 # NONLOCAL-NEXT: >>> referenced by b.o:(.data+0x10)
31 # NONLOCAL: error: relocation refers to a symbol in a discarded section: weakref2
32 # NONLOCAL-NEXT: >>> defined in a.o
33 # NONLOCAL-NEXT: >>> referenced by b.o:(.data+0x18)
35 # WARNING: warning: relocation refers to a discarded section: .aaa
36 # WARNING-NEXT: >>> referenced by a.o:(.rela.bbb+0x0)
38 ## GNU ld reports "defined in discarded secion" errors even in -r mode.
39 ## We set the symbol index to 0.
40 # RELOC: Relocation section '.rela.bbb' at offset {{.*}} contains 1 entries:
41 # RELOC-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
42 # RELOC-NEXT: 0000000000000000 0000000000000000 R_X86_64_NONE 0
43 # RELOC-EMPTY:
44 # RELOC-NEXT: Relocation section '.rela.data' at offset {{.*}} contains 4 entries:
45 # RELOC-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
46 # RELOC-NEXT: 0000000000000000 0000000000000001 R_X86_64_64 0
47 # RELOC-NEXT: 0000000000000008 0000000000000001 R_X86_64_64 0
48 # RELOC-NEXT: 0000000000000010 0000000000000001 R_X86_64_64 0
49 # RELOC-NEXT: 0000000000000018 0000000000000001 R_X86_64_64 0
51 # RELOC: Num: Value Size Type Bind Vis Ndx Name
52 # RELOC-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
53 # RELOC-NEXT: 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text
54 # RELOC-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 .bbb
55 # RELOC-NEXT: 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .data
56 # RELOC-NEXT: 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 _start
57 # RELOC-EMPTY:
59 # RELOC-GC: There are no relocations in this file.
61 #--- a.s
62 .globl _start
63 _start:
65 .section .aaa,"a"
66 .globl global, weakref1, unused
67 .weak weak, weakref2
68 global:
69 weak:
70 weakref1:
71 weakref2:
72 ## Eliminate `unused` just like GC discarded definitions.
73 ## Linux kernel's CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y configuration expects
74 ## that the unreferenced `unused` is not emitted to .symtab.
75 unused:
76 .quad 0
78 .section .bbb,"aw"
79 .quad .aaa
81 #--- b.s
82 .weak weakref1, weakref2
83 .section .data,"aw"
84 .quad global
85 .quad weak
86 .quad weakref1
87 .quad weakref2
89 #--- a.lds
90 SECTIONS { /DISCARD/ : { *(.aaa) } }