xref: /llvm-project/lld/test/ELF/undef-not-suggest.test (revision 0f298ec6ccc0877117e4ee8036a58d10e5ff1ac3)
1## Check we don't suggest alternative spelling for relocations to symbols
2## defined in discarded sections.
3
4# RUN: yaml2obj %s -o %t.o
5# RUN: not ld.lld %t.o %t.o -o /dev/null 2>&1 | FileCheck %s
6
7# CHECK-NOT: did you mean:
8
9--- !ELF
10FileHeader:
11  Class:   ELFCLASS64
12  Data:    ELFDATA2LSB
13  Type:    ET_REL
14  Machine: EM_X86_64
15Sections:
16  - Name: .group
17    Type: SHT_GROUP
18    Link: .symtab
19    Info: foo
20    Members:
21      - SectionOrType: GRP_COMDAT
22      - SectionOrType: .text.foo
23  - Name:  .text.foo
24    Type:  SHT_PROGBITS
25    Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
26  - Name:  .rodata
27    Type:  SHT_PROGBITS
28    Flags: [ SHF_ALLOC ]
29  - Name: .rela.rodata
30    Type: SHT_RELA
31    Link: .symtab
32    Info: .rodata
33    Relocations:
34      ## Relocation which references ".text.foo". Check we don't suggest the
35      ## section symbol for ".data", which has an empty name.
36      - Type:   R_X86_64_64
37        ## .text.foo
38        Symbol: 1
39      ## Relocation which references "foo". Check we don't suggest "for".
40      - Type:   R_X86_64_64
41        Symbol: foo
42  - Name: .data
43    Type: SHT_PROGBITS
44Symbols:
45  - Name:    ""
46    Type:    STT_SECTION
47    Section: .text.foo
48  - Name:    ""
49    Type:    STT_SECTION
50    Section: .data
51  - Name:    foo
52    Section: .text.foo
53    Binding: STB_GLOBAL
54  - Name:    for
55    Section: .data
56
57## Check we don't suggest an empty name symbol (e.g. STT_SECTION).
58
59# RUN: yaml2obj --docnum=2 %s -o %t2.o
60# RUN: not ld.lld %t2.o -o /dev/null 2>&1 | FileCheck %s
61
62--- !ELF
63FileHeader:
64  Class:   ELFCLASS64
65  Data:    ELFDATA2LSB
66  Type:    ET_REL
67  Machine: EM_X86_64
68Sections:
69  - Name:  .text
70    Type:  SHT_PROGBITS
71    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
72  - Name: .rela.text
73    Type:  SHT_RELA
74    Info: .text
75    Relocations:
76      - Type:   R_X86_64_64
77        Symbol: f
78Symbols:
79  - Name:    ""
80    Type:    STT_SECTION
81    Section: .text
82  - Name:    f
83    Binding: STB_GLOBAL
84