Debian Codegraph @

llvm/test/tools/llvm-objcopy/ELF/set-section-type.test

raw
1 # RUN: yaml2obj %s -o %t
2
3 # RUN: llvm-objcopy --set-section-type=.foo=14 --set-section-type .bar=0xf %t %t.1
4 # RUN: llvm-readobj --sections %t.1 | FileCheck %s
5
6 # RUN: llvm-objcopy --set-section-type=.foo=13 --set-section-type=.foo=14 --set-section-type .bar=0xf %t %t.1
7 # RUN: llvm-readobj --sections %t.1 | FileCheck %s
8
9 # CHECK: Name: .foo
10 # CHECK-NEXT: Type: SHT_INIT_ARRAY (0xE)
11 # CHECK-NEXT: Flags [
12 # CHECK-NEXT: SHF_ALLOC
13 # CHECK-NEXT: ]
14
15 # CHECK: Name: .bar
16 # CHECK-NEXT: Type: SHT_FINI_ARRAY (0xF)
17 # CHECK-NEXT: Flags [
18 # CHECK-NEXT: ]
19
20 ## --set-section-flags does not specify "readonly", so the output gets SHF_WRITE.
21 ## "contents" changes SHT_NOBITS to SHT_PROGBITS, but this is overridden by --set-section-type.
22 ## sh_type is a uint32_t. There is no diagnostic for an overflow value.
23 # RUN: llvm-objcopy --set-section-flags=.foo=alloc,contents --set-section-type=.foo=0x10000000a %t %t.2 2>&1 | count 0
24 # RUN: llvm-readobj --sections %t.2 | FileCheck %s --check-prefix=CHECK2
25
26 # CHECK2: Name: .foo
27 # CHECK2-NEXT: Type: SHT_SHLIB
28 # CHECK2-NEXT: Flags [
29 # CHECK2-NEXT: SHF_ALLOC
30 # CHECK2-NEXT: SHF_WRITE
31 # CHECK2-NEXT: ]
32
33 # RUN: not llvm-objcopy --set-section-type=.foo %t /dev/null 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT
34 # BAD-FORMAT: bad format for --set-section-type: missing '='
35
36 # RUN: not llvm-objcopy --set-section-type==4 %t /dev/null 2>&1 | FileCheck %s --check-prefix=MISSING-SECTION
37 # MISSING-SECTION: error: bad format for --set-section-type: missing section name
38
39 # RUN: not llvm-objcopy --set-section-type=.foo=aaa %t /dev/null 2>&1 | FileCheck %s --check-prefix=INVALID-TYPE
40 # INVALID-TYPE: error: invalid value for --set-section-type: 'aaa'
41
42 !ELF
43 FileHeader:
44 Class: ELFCLASS64
45 Data: ELFDATA2LSB
46 Type: ET_REL
47 Machine: EM_X86_64
48 Sections:
49 - Name: .foo
50 Type: SHT_NOBITS
51 Flags: [ SHF_ALLOC ]
52 - Name: .bar
53 Type: SHT_PROGBITS
54 Flags: [ ]