Debian Codegraph @

llvm/test/tools/llvm-objcopy/ELF/rename-section-flag-osproc-mask.test

raw
1 # Test that cpu/processor-specific SHF_* flags are preserved,
2 # except SHF_X86_64_LARGE on x86_64 (which is controlled with the
3 # "large" flag).
4
5 # ===== x86_64 =====
6
7 # RUN: yaml2obj --docnum=1 %s -o %t-x86_64.o
8 # RUN: llvm-objcopy --rename-section=.foo=.bar,alloc %t-x86_64.o
9 # RUN: llvm-readobj --sections %t-x86_64.o | FileCheck %s --check-prefix=X86_64
10 # RUN: llvm-objcopy --rename-section=.bar=.quz,alloc,large %t-x86_64.o
11 # RUN: llvm-readobj --sections %t-x86_64.o | FileCheck %s --check-prefix=X86_64-LARGE
12
13 --- !ELF
14 FileHeader:
15 Class: ELFCLASS64
16 Data: ELFDATA2LSB
17 Type: ET_REL
18 Machine: EM_X86_64
19 Sections:
20 - Name: .foo
21 Type: SHT_PROGBITS
22 Flags: [ SHF_X86_64_LARGE ]
23
24 # X86_64: Name: .bar
25 # X86_64-NEXT: Type: SHT_PROGBITS
26 # X86_64-NEXT: Flags [
27 # X86_64-NEXT: SHF_ALLOC (0x2)
28 # X86_64-NEXT: SHF_WRITE (0x1)
29 # X86_64-NEXT: ]
30
31 # X86_64-LARGE: Name: .quz
32 # X86_64-LARGE-NEXT: Type: SHT_PROGBITS
33 # X86_64-LARGE-NEXT: Flags [
34 # X86_64-LARGE-NEXT: SHF_ALLOC (0x2)
35 # X86_64-LARGE-NEXT: SHF_WRITE (0x1)
36 # X86_64-LARGE-NEXT: SHF_X86_64_LARGE (0x10000000)
37 # X86_64-LARGE-NEXT: ]
38
39 # ===== hex =====
40
41 # RUN: yaml2obj --docnum=2 %s -o %t-hex.o
42 # RUN: llvm-objcopy --rename-section=.foo=.bar,alloc %t-hex.o
43 # RUN: llvm-readobj --sections %t-hex.o | FileCheck %s --check-prefix=HEX
44
45 --- !ELF
46 FileHeader:
47 Class: ELFCLASS64
48 Data: ELFDATA2LSB
49 Type: ET_REL
50 Machine: EM_HEXAGON
51 Sections:
52 - Name: .foo
53 Type: SHT_PROGBITS
54 Flags: [ SHF_HEX_GPREL ]
55
56 # HEX: Name: .bar
57 # HEX-NEXT: Type: SHT_PROGBITS
58 # HEX-NEXT: Flags [
59 # HEX-NEXT: SHF_ALLOC (0x2)
60 # HEX-NEXT: SHF_HEX_GPREL (0x10000000)
61 # HEX-NEXT: SHF_WRITE (0x1)
62 # HEX-NEXT: ]
63
64 # ===== mips =====
65
66 # RUN: yaml2obj --docnum=3 %s -o %t-mips.o
67 # RUN: llvm-objcopy --rename-section=.foo=.bar,alloc %t-mips.o
68 # RUN: llvm-readobj --sections %t-mips.o | FileCheck %s --check-prefix=MIPS
69
70 --- !ELF
71 FileHeader:
72 Class: ELFCLASS64
73 Data: ELFDATA2LSB
74 Type: ET_REL
75 Machine: EM_MIPS
76 Sections:
77 - Name: .foo
78 Type: SHT_PROGBITS
79 Flags: [ SHF_MIPS_NODUPES, SHF_MIPS_NAMES, SHF_MIPS_LOCAL,
80 SHF_MIPS_NOSTRIP, SHF_MIPS_GPREL, SHF_MIPS_MERGE,
81 SHF_MIPS_ADDR, SHF_MIPS_STRING ]
82
83 # Note: llvm-readobj prints SHF_EXCLUDE/SHF_MASKPROC since specifying all
84 # SHF_MIPS_* flags covers the same bitset.
85
86 # MIPS: Name: .bar
87 # MIPS-NEXT: Type: SHT_PROGBITS
88 # MIPS-NEXT: Flags [
89 # MIPS-NEXT: SHF_ALLOC (0x2)
90 # MIPS-NEXT: SHF_MIPS_ADDR (0x40000000)
91 # MIPS-NEXT: SHF_MIPS_GPREL (0x10000000)
92 # MIPS-NEXT: SHF_MIPS_LOCAL (0x4000000)
93 # MIPS-NEXT: SHF_MIPS_MERGE (0x20000000)
94 # MIPS-NEXT: SHF_MIPS_NAMES (0x2000000)
95 # MIPS-NEXT: SHF_MIPS_NODUPES (0x1000000)
96 # MIPS-NEXT: SHF_MIPS_NOSTRIP (0x8000000)
97 # MIPS-NEXT: SHF_WRITE (0x1)
98 # MIPS-NEXT: ]
99
100 # ===== arm =====
101
102 # RUN: yaml2obj --docnum=4 %s -o %t-arm.o
103 # RUN: llvm-objcopy --rename-section=.foo=.bar,alloc %t-arm.o
104 # RUN: llvm-readobj --sections %t-arm.o | FileCheck %s --check-prefix=ARM
105
106 --- !ELF
107 FileHeader:
108 Class: ELFCLASS64
109 Data: ELFDATA2LSB
110 Type: ET_REL
111 Machine: EM_ARM
112 Sections:
113 - Name: .foo
114 Type: SHT_PROGBITS
115 Flags: [ SHF_ARM_PURECODE ]
116
117 # ARM: Name: .bar
118 # ARM-NEXT: Type: SHT_PROGBITS
119 # ARM-NEXT: Flags [
120 # ARM-NEXT: SHF_ALLOC (0x2)
121 # ARM-NEXT: SHF_ARM_PURECODE (0x20000000)
122 # ARM-NEXT: SHF_WRITE (0x1)
123 # ARM-NEXT: ]
124
125 # ===== aarch64 =====
126
127 # RUN: yaml2obj --docnum=5 %s -o %t-aarch64.o
128 # RUN: llvm-objcopy --rename-section=.foo=.bar,alloc %t-aarch64.o
129 # RUN: llvm-readobj --sections %t-aarch64.o | FileCheck %s --check-prefix=AARCH64
130
131 --- !ELF
132 FileHeader:
133 Class: ELFCLASS64
134 Data: ELFDATA2LSB
135 Type: ET_REL
136 Machine: EM_AARCH64
137 Sections:
138 - Name: .foo
139 Type: SHT_PROGBITS
140 Flags: [ SHF_AARCH64_PURECODE ]
141
142 # AARCH64: Name: .bar
143 # AARCH64-NEXT: Type: SHT_PROGBITS
144 # AARCH64-NEXT: Flags [
145 # AARCH64-NEXT: SHF_AARCH64_PURECODE (0x20000000)
146 # AARCH64-NEXT: SHF_ALLOC (0x2)
147 # AARCH64-NEXT: SHF_WRITE (0x1)
148 # AARCH64-NEXT: ]