1 # RUN: yaml2obj %s > %t
3 # Single flags on a section with no flags:
4 # RUN: llvm-objcopy --set-section-flags=.foo=alloc \
5 # RUN: --set-section-flags=.baz=alloc --set-section-flags=.rela.baz=alloc %t %t.alloc
6 # RUN: llvm-readobj --sections %t.alloc | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,WRITE
7 # RUN: llvm-objcopy --set-section-flags=.foo=load \
8 # RUN: --set-section-flags=.baz=load --set-section-flags=.rela.baz=load %t %t.load
9 # RUN: llvm-readobj --sections %t.load | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE
10 # RUN: llvm-objcopy --set-section-flags=.foo=noload \
11 # RUN: --set-section-flags=.baz=noload --set-section-flags=.rela.baz=noload %t %t.noload
12 # RUN: llvm-readobj --sections %t.noload | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE
13 # RUN: llvm-objcopy --set-section-flags=.foo=readonly \
14 # RUN: --set-section-flags=.baz=readonly --set-section-flags=.rela.baz=readonly %t %t.readonly
15 # RUN: llvm-readobj --sections %t.readonly | FileCheck %s --check-prefixes=CHECK,PROGBITS
16 # RUN: llvm-objcopy --set-section-flags=.foo=debug \
17 # RUN: --set-section-flags=.baz=debug --set-section-flags=.rela.baz=debug %t %t.debug
18 # RUN: llvm-readobj --sections %t.debug | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE
19 # RUN: llvm-objcopy --set-section-flags=.foo=code \
20 # RUN: --set-section-flags=.baz=code --set-section-flags=.rela.baz=code %t %t.code
21 # RUN: llvm-readobj --sections %t.code | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXEC,WRITE
22 # RUN: llvm-objcopy --set-section-flags=.foo=data \
23 # RUN: --set-section-flags=.baz=data --set-section-flags=.rela.baz=data %t %t.data
24 # RUN: llvm-readobj --sections %t.data | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE
25 # RUN: llvm-objcopy --set-section-flags=.foo=rom \
26 # RUN: --set-section-flags=.baz=rom --set-section-flags=.rela.baz=rom %t %t.rom
27 # RUN: llvm-readobj --sections %t.rom | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE
28 # RUN: llvm-objcopy --set-section-flags=.foo=contents \
29 # RUN: --set-section-flags=.baz=contents --set-section-flags=.rela.baz=contents %t %t.contents
30 # RUN: llvm-readobj --sections %t.contents | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE
31 # RUN: llvm-objcopy --set-section-flags=.foo=merge \
32 # RUN: --set-section-flags=.baz=merge --set-section-flags=.rela.baz=merge %t %t.merge
33 # RUN: llvm-readobj --sections %t.merge | FileCheck %s --check-prefixes=CHECK,MERGE,PROGBITS,WRITE
34 # RUN: llvm-objcopy --set-section-flags=.foo=strings \
35 # RUN: --set-section-flags=.baz=strings --set-section-flags=.rela.baz=strings %t %t.strings
36 # RUN: llvm-readobj --sections %t.strings | FileCheck %s --check-prefixes=CHECK,STRINGS,PROGBITS,WRITE
37 # RUN: llvm-objcopy --set-section-flags=.foo=share \
38 # RUN: --set-section-flags=.baz=share --set-section-flags=.rela.baz=share %t %t.share
39 # RUN: llvm-readobj --sections %t.share | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE
42 # RUN: llvm-objcopy --set-section-flags=.foo=alloc,readonly,strings \
43 # RUN: --set-section-flags=.baz=alloc,readonly,strings \
44 # RUN: --set-section-flags=.rela.baz=alloc,readonly,strings %t %t.alloc_ro_strings
45 # RUN: llvm-readobj --sections %t.alloc_ro_strings | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,STRINGS
46 # RUN: llvm-objcopy --set-section-flags=.foo=alloc,code \
47 # RUN: --set-section-flags=.baz=alloc,code \
48 # RUN: --set-section-flags=.rela.baz=alloc,code %t %t.alloc_code
49 # RUN: llvm-readobj --sections %t.alloc_code | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,EXEC,WRITE
52 # RUN: not llvm-objcopy --set-section-flags=.foo=xyzzy %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG
55 # RUN: not llvm-objcopy --set-section-flags=.foo %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT
57 # Setting flags for the same section multiple times:
58 # RUN: not llvm-objcopy --set-section-flags=.foo=alloc --set-section-flags=.foo=load %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-SETS
61 # RUN: llvm-objcopy --set-section-flags=.foo=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE \
62 # RUN: --set-section-flags=.baz=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE \
63 # RUN: --set-section-flags=.rela.baz=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE %t %t.upper
64 # RUN: llvm-readobj --sections %t.upper | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS
67 # RUN: llvm-objcopy --set-section-flags=.foo=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE \
68 # RUN: --set-section-flags=.baz=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE \
69 # RUN: --set-section-flags=.rela.baz=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE %t %t.mixed
70 # RUN: llvm-readobj --sections %t.mixed | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS
90 # CHECK-NEXT: Type: SHT_PROGBITS
92 # ALLOC-NEXT: SHF_ALLOC (0x2)
93 # EXEC-NEXT: SHF_EXECINSTR (0x4)
94 # MERGE-NEXT: SHF_MERGE (0x10)
95 # STRINGS-NEXT: SHF_STRINGS (0x20)
96 # WRITE-NEXT: SHF_WRITE (0x1)
100 # NOBITS-NEXT: Type: SHT_NOBITS
101 # PROGBITS-NEXT: Type: SHT_PROGBITS
102 # CHECK-NEXT: Flags [
103 # ALLOC-NEXT: SHF_ALLOC (0x2)
104 # EXEC-NEXT: SHF_EXECINSTR (0x4)
105 # MERGE-NEXT: SHF_MERGE (0x10)
106 # STRINGS-NEXT: SHF_STRINGS (0x20)
107 # WRITE-NEXT: SHF_WRITE (0x1)
110 # CHECK: Name: .rela.baz
111 # CHECK-NEXT: Type: SHT_RELA
112 # CHECK-NEXT: Flags [
113 # ALLOC-NEXT: SHF_ALLOC (0x2)
114 # EXEC-NEXT: SHF_EXECINSTR (0x4)
115 # MERGE-NEXT: SHF_MERGE (0x10)
116 # STRINGS-NEXT: SHF_STRINGS (0x20)
117 # WRITE-NEXT: SHF_WRITE (0x1)
120 # BAD-FORMAT: bad format for --set-section-flags: missing '='
121 # MULTIPLE-SETS: --set-section-flags set multiple times for section '.foo'
123 # BAD-FLAG: unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, debug, code, data, rom, share, contents, merge, strings