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