xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test (revision 68616584c3a5ce9352b37d24e408b171928f6840)
1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objcopy --strip-dwo %t
3# RUN: llvm-readobj --symbols -S --section-groups %t | \
4# RUN:   FileCheck %s --implicit-check-not=.debug_
5
6## `llvm-objcopy --strip-dwo` strips out dwo sections, as a result, the index of
7## the symbol table, the indices of the symbols and the indices of the sections
8## which go after the removed ones will change. Consequently, the fields Link,
9## Info and the content of .group need to be updated.
10
11## Note. 'Signature' is generated using 'Link' and 'Info', so checking it
12## validates updating these fields.
13
14# CHECK:      Groups {
15# CHECK-NEXT:  Group {
16# CHECK-NEXT:   Name: .group
17# CHECK-NEXT:   Index:
18# CHECK-NEXT:   Link:
19# CHECK-NEXT:   Info:
20# CHECK-NEXT:   Type:
21# CHECK-NEXT:   Signature: group1
22# CHECK-NEXT:   Section(s) in group [
23# CHECK-NEXT:     .text.group1
24# CHECK-NEXT:   ]
25
26# CHECK:        Name: .group
27# CHECK-NEXT:   Index:
28# CHECK-NEXT:   Link:
29# CHECK-NEXT:   Info:
30# CHECK-NEXT:   Type:
31# CHECK-NEXT:   Signature: group2
32# CHECK-NEXT:   Section(s) in group [
33# CHECK-NEXT:     .text.group2
34# CHECK-NEXT:     .rela.text.group2
35# CHECK-NEXT:   ]
36
37--- !ELF
38FileHeader:
39  Class:   ELFCLASS64
40  Data:    ELFDATA2LSB
41  Type:    ET_REL
42  Machine: EM_X86_64
43Sections:
44  - Name: .debug_before.dwo
45    Type: SHT_PROGBITS
46  - Name: .group
47    Type: SHT_GROUP
48    Link: .symtab
49    Info: group1
50    Members:
51      - SectionOrType: GRP_COMDAT
52      - SectionOrType: .text.group1
53  - Name:  .text.group1
54    Type:  SHT_PROGBITS
55    Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
56  - Name: '.group (1)'
57    Type: SHT_GROUP
58    Link: .symtab
59    Info: group2
60    Members:
61      - SectionOrType: GRP_COMDAT
62      - SectionOrType: .text.group2
63      - SectionOrType: .rela.text.group2
64  - Name:  .text.group2
65    Type:  SHT_PROGBITS
66    Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
67  - Name:  .rela.text.group2
68    Type:  SHT_RELA
69    Flags: [ SHF_GROUP ]
70    Info:  .text.group2
71  - Name: .debug_after.dwo
72    Type: SHT_PROGBITS
73Symbols:
74  - Name:    debug_before
75    Section: .debug_before.dwo
76  - Name:    debug_after
77    Section: .debug_after.dwo
78  - Name:    group2
79    Section: .text.group2
80    Binding: STB_WEAK
81  - Name:    group1
82    Section: .text.group1
83    Binding: STB_WEAK
84