• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: yaml2obj %s -o %t
2
3## Single flag on a section with no flags:
4# RUN: llvm-objcopy --set-section-flags=.foo=alloc %t %t.alloc
5# RUN: llvm-readobj --sections %t.alloc | FileCheck %s --check-prefixes=CHECK,UNINITDATA,READ,WRITE
6# RUN: llvm-objcopy --set-section-flags=.foo=load %t %t.load
7# RUN: llvm-readobj --sections %t.load | FileCheck %s --check-prefixes=CHECK,READ,WRITE
8# RUN: llvm-objcopy --set-section-flags=.foo=noload %t %t.noload
9# RUN: llvm-readobj --sections %t.noload | FileCheck %s --check-prefixes=CHECK,READ,WRITE,REMOVE
10# RUN: llvm-objcopy --set-section-flags=.foo=readonly %t %t.readonly
11# RUN: llvm-readobj --sections %t.readonly | FileCheck %s --check-prefixes=CHECK,READ
12# RUN: llvm-objcopy --set-section-flags=.foo=exclude %t %t.exclude
13# RUN: llvm-readobj --sections %t.exclude | FileCheck %s --check-prefixes=CHECK,READ,WRITE,REMOVE
14# RUN: llvm-objcopy --set-section-flags=.foo=debug %t %t.debug
15# RUN: llvm-readobj --sections %t.debug | FileCheck %s --check-prefixes=CHECK,INITDATA,DISCARDABLE,READ,WRITE
16# RUN: llvm-objcopy --set-section-flags=.foo=code %t %t.code
17# RUN: llvm-readobj --sections %t.code | FileCheck %s --check-prefixes=CHECK,CODE,EXECUTE,READ,WRITE
18# RUN: llvm-objcopy --set-section-flags=.foo=data %t %t.data
19# RUN: llvm-readobj --sections %t.data | FileCheck %s --check-prefixes=CHECK,INITDATA,READ,WRITE
20# RUN: llvm-objcopy --set-section-flags=.foo=rom %t %t.rom
21# RUN: llvm-readobj --sections %t.rom | FileCheck %s --check-prefixes=CHECK,READ,WRITE
22# RUN: llvm-objcopy --set-section-flags=.foo=contents %t %t.contents
23# RUN: llvm-readobj --sections %t.contents | FileCheck %s --check-prefixes=CHECK,READ,WRITE
24# RUN: llvm-objcopy --set-section-flags=.foo=merge %t %t.merge
25# RUN: llvm-readobj --sections %t.merge | FileCheck %s --check-prefixes=CHECK,READ,WRITE
26# RUN: llvm-objcopy --set-section-flags=.foo=strings %t %t.strings
27# RUN: llvm-readobj --sections %t.strings | FileCheck %s --check-prefixes=CHECK,READ,WRITE
28# RUN: llvm-objcopy --set-section-flags=.foo=share %t %t.share
29# RUN: llvm-readobj --sections %t.share | FileCheck %s --check-prefixes=CHECK,READ,SHARED,WRITE
30
31## Multiple flags:
32# RUN: llvm-objcopy --set-section-flags=.foo=alloc,readonly,share %t %t.alloc_ro_share
33# RUN: llvm-readobj --sections %t.alloc_ro_share | FileCheck %s --check-prefixes=CHECK,UNINITDATA,READ,SHARED
34# RUN: llvm-objcopy --set-section-flags=.foo=alloc,code %t %t.alloc_code
35# RUN: llvm-readobj --sections %t.alloc_code | FileCheck %s --check-prefixes=CHECK,CODE,UNINITDATA,EXECUTE,READ,WRITE
36
37## Invalid flags:
38# RUN: not llvm-objcopy --set-section-flags=.foo=xyzzy %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG
39
40## Bad flag format:
41# RUN: not llvm-objcopy --set-section-flags=.foo %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT
42
43## Setting flags for the same section multiple times:
44# RUN: not llvm-objcopy --set-section-flags=.foo=alloc --set-section-flags=.foo=load %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-SETS
45
46## Upper-case flags:
47# RUN: llvm-objcopy --set-section-flags=.foo=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE %t %t.upper
48# RUN: llvm-readobj --sections %t.upper | FileCheck %s --check-prefixes=CHECK,CODE,INITDATA,REMOVE,DISCARDABLE,EXECUTE,READ,SHARED
49
50## Mixed-case flags:
51# RUN: llvm-objcopy --set-section-flags=.foo=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE %t %t.mixed
52# RUN: llvm-readobj --sections %t.mixed | FileCheck %s --check-prefixes=CHECK,CODE,INITDATA,REMOVE,DISCARDABLE,EXECUTE,READ,SHARED
53
54--- !COFF
55header:
56  Machine:         IMAGE_FILE_MACHINE_AMD64
57  Characteristics: [ ]
58sections:
59  - Name:            .foo
60    Characteristics: [ ]
61    Alignment:       4
62symbols:
63...
64
65# CHECK:            Name: .foo
66# CHECK:            Characteristics [
67# CHECK-NEXT:         IMAGE_SCN_ALIGN_4BYTES
68# CODE-NEXT:          IMAGE_SCN_CNT_CODE
69# INITDATA-NEXT:      IMAGE_SCN_CNT_INITIALIZED_DATA
70# UNINITDATA-NEXT:    IMAGE_SCN_CNT_UNINITIALIZED_DATA
71# REMOVE-NEXT:        IMAGE_SCN_LNK_REMOVE
72# DISCARDABLE-NEXT:   IMAGE_SCN_MEM_DISCARDABLE
73# EXECUTE-NEXT:       IMAGE_SCN_MEM_EXECUTE
74# READ-NEXT:          IMAGE_SCN_MEM_READ
75# SHARED-NEXT:        IMAGE_SCN_MEM_SHARED
76# WRITE-NEXT:         IMAGE_SCN_MEM_WRITE
77# CHECK-NEXT:       ]
78
79# BAD-FORMAT: bad format for --set-section-flags: missing '='
80# MULTIPLE-SETS: --set-section-flags set multiple times for section '.foo'
81
82# BAD-FLAG: unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, exclude, debug, code, data, rom, share, contents, merge, strings
83