group.test
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy --remove-section=.text.bar %t %t1
# RUN: llvm-readobj --elf-section-groups %t1 | FileCheck %s
# In this test the section .text.bar is getting removed, as a result,
# the indices of the sections which go after .text.bar will change,
# thus the fields Link, Info and the content of .group should be updated.
# CHECK: Name: .group
# CHECK-NEXT: Index: 1
# CHECK-NEXT: Link: 3
# CHECK-NEXT: Info: 2
# CHECK-NEXT: Type: COMDAT (0x1)
# CHECK-NEXT: Signature: foo
# CHECK: .text.foo (2)
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .group
Type: SHT_GROUP
Link: .symtab
AddressAlign: 0x0000000000000004
Info: foo
Members:
- SectionOrType: GRP_COMDAT
- SectionOrType: .text.foo
- Name: .text.bar
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000000010
- Name: .text.foo
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
AddressAlign: 0x0000000000000010
Symbols:
- Name: .text.bar
Type: STT_SECTION
Section: .text.bar
- Name: .text.foo
Type: STT_SECTION
Section: .text.foo
- Name: bar
Type: STT_FUNC
Section: .text.bar
Size: 0x0000000000000000
Binding: STB_WEAK
- Name: foo
Type: STT_FUNC
Section: .text.foo
Size: 0x0000000000000000
Binding: STB_WEAK
## This checks that tool will emit an error when trying to remove the symbol
## table when we have a group section linked with symtab.
# RUN: not llvm-objcopy -R .symtab %t %t2 2>&1 | FileCheck %s --check-prefix=ERR -DINPUT=%t
# ERR: error: '[[INPUT]]': section '.symtab' cannot be removed because it is referenced by the group section '.group'
## The '.symtab' section could be removed using --allow-broken-links option.
# RUN: llvm-objcopy --allow-broken-links -R .symtab %t %t3
# RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=SECTIONS
# SECTIONS: There are 6 section headers
# SECTIONS: Name Type Address Off Size ES Flg Lk Inf
# SECTIONS-NEXT: NULL
# SECTIONS-NEXT: .group {{.+}} {{.+}} {{.+}} {{.+}} {{.+}} 0 0
# SECTIONS-NEXT: .text.bar
# SECTIONS-NEXT: .text.foo
# SECTIONS-NEXT: .strtab
# SECTIONS-NEXT: .shstrtab
## Show that llvm-objcopy can handle a group section with a zero sh_link and
## sh_info fields.
# RUN: llvm-objcopy --allow-broken-links -R .symtab %t3 %t4
# RUN: cmp %t3 %t4