| 1 |
# RUN: yaml2obj %s -o %t |
| 2 |
|
| 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=exclude \ |
| 17 |
# RUN: --set-section-flags=.baz=exclude --set-section-flags=.rela.baz=exclude %t %t.exclude |
| 18 |
# RUN: llvm-readobj --sections %t.exclude | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXCLUDE,WRITE |
| 19 |
# RUN: llvm-objcopy --set-section-flags=.foo=debug \ |
| 20 |
# RUN: --set-section-flags=.baz=debug --set-section-flags=.rela.baz=debug %t %t.debug |
| 21 |
# RUN: llvm-readobj --sections %t.debug | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE |
| 22 |
# RUN: llvm-objcopy --set-section-flags=.foo=code \ |
| 23 |
# RUN: --set-section-flags=.baz=code --set-section-flags=.rela.baz=code %t %t.code |
| 24 |
# RUN: llvm-readobj --sections %t.code | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXEC,WRITE |
| 25 |
# RUN: llvm-objcopy --set-section-flags=.foo=data \ |
| 26 |
# RUN: --set-section-flags=.baz=data --set-section-flags=.rela.baz=data %t %t.data |
| 27 |
# RUN: llvm-readobj --sections %t.data | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE |
| 28 |
# RUN: llvm-objcopy --set-section-flags=.foo=rom \ |
| 29 |
# RUN: --set-section-flags=.baz=rom --set-section-flags=.rela.baz=rom %t %t.rom |
| 30 |
# RUN: llvm-readobj --sections %t.rom | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE |
| 31 |
# RUN: llvm-objcopy --set-section-flags=.foo=contents \ |
| 32 |
# RUN: --set-section-flags=.baz=contents --set-section-flags=.rela.baz=contents %t %t.contents |
| 33 |
# RUN: llvm-readobj --sections %t.contents | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE |
| 34 |
# RUN: llvm-objcopy --set-section-flags=.foo=merge \ |
| 35 |
# RUN: --set-section-flags=.baz=merge --set-section-flags=.rela.baz=merge %t %t.merge |
| 36 |
# RUN: llvm-readobj --sections %t.merge | FileCheck %s --check-prefixes=CHECK,MERGE,PROGBITS,WRITE |
| 37 |
# RUN: llvm-objcopy --set-section-flags=.foo=strings \ |
| 38 |
# RUN: --set-section-flags=.baz=strings --set-section-flags=.rela.baz=strings %t %t.strings |
| 39 |
# RUN: llvm-readobj --sections %t.strings | FileCheck %s --check-prefixes=CHECK,STRINGS,PROGBITS,WRITE |
| 40 |
# RUN: llvm-objcopy --set-section-flags=.foo=share \ |
| 41 |
# RUN: --set-section-flags=.baz=share --set-section-flags=.rela.baz=share %t %t.share |
| 42 |
# RUN: llvm-readobj --sections %t.share | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE |
| 43 |
# RUN: llvm-objcopy --set-section-flags=.foo=large \ |
| 44 |
# RUN: --set-section-flags=.baz=large --set-section-flags=.rela.baz=large %t %t.large |
| 45 |
# RUN: llvm-readobj --sections %t.large | FileCheck %s --check-prefixes=CHECK,LARGE,PROGBITS,WRITE |
| 46 |
# RUN: llvm-objcopy --set-section-flags=.foo=data \ |
| 47 |
# RUN: --set-section-flags=.baz=data --set-section-flags=.rela.baz=data %t %t.no-large |
| 48 |
# RUN: llvm-readobj --sections %t.no-large | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE |
| 49 |
|
| 50 |
# Multiple flags: |
| 51 |
# RUN: llvm-objcopy --set-section-flags=.foo=alloc,readonly,strings \ |
| 52 |
# RUN: --set-section-flags=.baz=alloc,readonly,strings \ |
| 53 |
# RUN: --set-section-flags=.rela.baz=alloc,readonly,strings %t %t.alloc_ro_strings |
| 54 |
# RUN: llvm-readobj --sections %t.alloc_ro_strings | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,STRINGS |
| 55 |
# RUN: llvm-objcopy --set-section-flags=.foo=alloc,code \ |
| 56 |
# RUN: --set-section-flags=.baz=alloc,code \ |
| 57 |
# RUN: --set-section-flags=.rela.baz=alloc,code %t %t.alloc_code |
| 58 |
# RUN: llvm-readobj --sections %t.alloc_code | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,EXEC,WRITE |
| 59 |
|
| 60 |
# Invalid flags: |
| 61 |
# RUN: not llvm-objcopy --set-section-flags=.foo=xyzzy %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG |
| 62 |
|
| 63 |
# Bad flag format: |
| 64 |
# RUN: not llvm-objcopy --set-section-flags=.foo %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT |
| 65 |
|
| 66 |
# Setting flags for the same section multiple times: |
| 67 |
# RUN: not llvm-objcopy --set-section-flags=.foo=alloc --set-section-flags=.foo=load %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-SETS |
| 68 |
|
| 69 |
# Upper-case flags: |
| 70 |
# RUN: llvm-objcopy --set-section-flags=.foo=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE \ |
| 71 |
# RUN: --set-section-flags=.baz=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE \ |
| 72 |
# RUN: --set-section-flags=.rela.baz=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE %t %t.upper |
| 73 |
# RUN: llvm-readobj --sections %t.upper | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS |
| 74 |
|
| 75 |
# Mixed-case flags: |
| 76 |
# RUN: llvm-objcopy --set-section-flags=.foo=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE \ |
| 77 |
# RUN: --set-section-flags=.baz=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE \ |
| 78 |
# RUN: --set-section-flags=.rela.baz=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE %t %t.mixed |
| 79 |
# RUN: llvm-readobj --sections %t.mixed | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS |
| 80 |
|
| 81 |
## Unspecified sections are not affected: |
| 82 |
# RUN: llvm-objcopy --set-section-flags=.foo=alloc %t %t.unspecified |
| 83 |
# RUN: llvm-readobj --sections %t.unspecified | FileCheck %s --check-prefixes=UNSPECIFIED |
| 84 |
|
| 85 |
!ELF |
| 86 |
FileHeader: |
| 87 |
Class: ELFCLASS64 |
| 88 |
Data: ELFDATA2LSB |
| 89 |
Type: ET_REL |
| 90 |
Machine: EM_X86_64 |
| 91 |
Sections: |
| 92 |
- Name: .foo |
| 93 |
Type: SHT_PROGBITS |
| 94 |
Flags: [ ] |
| 95 |
- Name: .baz |
| 96 |
Type: SHT_NOBITS |
| 97 |
Flags: [ ] |
| 98 |
- Name: .rela.baz |
| 99 |
Type: SHT_RELA |
| 100 |
Info: .baz |
| 101 |
|
| 102 |
# CHECK: Name: .foo |
| 103 |
# CHECK-NEXT: Type: SHT_PROGBITS |
| 104 |
# CHECK-NEXT: Flags [ |
| 105 |
# ALLOC-NEXT: SHF_ALLOC (0x2) |
| 106 |
# EXEC-NEXT: SHF_EXECINSTR (0x4) |
| 107 |
# MERGE-NEXT: SHF_MERGE (0x10) |
| 108 |
# STRINGS-NEXT: SHF_STRINGS (0x20) |
| 109 |
# EXCLUDE-NEXT: SHF_EXCLUDE (0x80000000) |
| 110 |
# WRITE-NEXT: SHF_WRITE (0x1) |
| 111 |
# LARGE-NEXT: SHF_X86_64_LARGE (0x10000000) |
| 112 |
# CHECK-NEXT: ] |
| 113 |
|
| 114 |
# CHECK: Name: .baz |
| 115 |
# NOBITS-NEXT: Type: SHT_NOBITS |
| 116 |
# PROGBITS-NEXT: Type: SHT_PROGBITS |
| 117 |
# CHECK-NEXT: Flags [ |
| 118 |
# ALLOC-NEXT: SHF_ALLOC (0x2) |
| 119 |
# EXEC-NEXT: SHF_EXECINSTR (0x4) |
| 120 |
# MERGE-NEXT: SHF_MERGE (0x10) |
| 121 |
# STRINGS-NEXT: SHF_STRINGS (0x20) |
| 122 |
# EXCLUDE-NEXT: SHF_EXCLUDE (0x80000000) |
| 123 |
# WRITE-NEXT: SHF_WRITE (0x1) |
| 124 |
# LARGE-NEXT: SHF_X86_64_LARGE (0x10000000) |
| 125 |
# CHECK-NEXT: ] |
| 126 |
|
| 127 |
# CHECK: Name: .rela.baz |
| 128 |
# CHECK-NEXT: Type: SHT_RELA |
| 129 |
# CHECK-NEXT: Flags [ |
| 130 |
# ALLOC-NEXT: SHF_ALLOC (0x2) |
| 131 |
# EXEC-NEXT: SHF_EXECINSTR (0x4) |
| 132 |
# MERGE-NEXT: SHF_MERGE (0x10) |
| 133 |
# STRINGS-NEXT: SHF_STRINGS (0x20) |
| 134 |
# EXCLUDE-NEXT: SHF_EXCLUDE (0x80000000) |
| 135 |
# WRITE-NEXT: SHF_WRITE (0x1) |
| 136 |
# LARGE-NEXT: SHF_X86_64_LARGE (0x10000000) |
| 137 |
# CHECK-NEXT: ] |
| 138 |
|
| 139 |
# BAD-FORMAT: bad format for --set-section-flags: missing '=' |
| 140 |
# MULTIPLE-SETS: --set-section-flags set multiple times for section '.foo' |
| 141 |
|
| 142 |
# BAD-FLAG: unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, exclude, debug, code, data, rom, share, contents, merge, strings |
| 143 |
|
| 144 |
# UNSPECIFIED: Name: .foo |
| 145 |
# UNSPECIFIED-NEXT: Type: SHT_PROGBITS |
| 146 |
# UNSPECIFIED-NEXT: Flags [ |
| 147 |
# UNSPECIFIED-NEXT: SHF_ALLOC (0x2) |
| 148 |
# UNSPECIFIED-NEXT: SHF_WRITE (0x1) |
| 149 |
# UNSPECIFIED-NEXT: ] |
| 150 |
|
| 151 |
# UNSPECIFIED: Name: .baz |
| 152 |
# UNSPECIFIED-NEXT: Type: SHT_NOBITS |
| 153 |
# UNSPECIFIED-NEXT: Flags [ (0x0) |
| 154 |
# UNSPECIFIED-NEXT: ] |
| 155 |
|
| 156 |
# UNSPECIFIED: Name: .rela.baz |
| 157 |
# UNSPECIFIED-NEXT: Type: SHT_RELA |
| 158 |
# UNSPECIFIED-NEXT: Flags [ (0x0) |
| 159 |
# UNSPECIFIED-NEXT: ] |