160 lines · plain
1# RUN: yaml2obj %s -o %t2 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.alloc6# RUN: llvm-readobj --sections %t.alloc | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,WRITE7# RUN: llvm-objcopy --set-section-flags=.foo=load \8# RUN: --set-section-flags=.baz=load --set-section-flags=.rela.baz=load %t %t.load9# RUN: llvm-readobj --sections %t.load | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE10# RUN: llvm-objcopy --set-section-flags=.foo=noload \11# RUN: --set-section-flags=.baz=noload --set-section-flags=.rela.baz=noload %t %t.noload12# RUN: llvm-readobj --sections %t.noload | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE13# RUN: llvm-objcopy --set-section-flags=.foo=readonly \14# RUN: --set-section-flags=.baz=readonly --set-section-flags=.rela.baz=readonly %t %t.readonly15# RUN: llvm-readobj --sections %t.readonly | FileCheck %s --check-prefixes=CHECK,PROGBITS16# RUN: llvm-objcopy --set-section-flags=.foo=exclude \17# RUN: --set-section-flags=.baz=exclude --set-section-flags=.rela.baz=exclude %t %t.exclude18# RUN: llvm-readobj --sections %t.exclude | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXCLUDE,WRITE19# RUN: llvm-objcopy --set-section-flags=.foo=debug \20# RUN: --set-section-flags=.baz=debug --set-section-flags=.rela.baz=debug %t %t.debug21# RUN: llvm-readobj --sections %t.debug | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE22# RUN: llvm-objcopy --set-section-flags=.foo=code \23# RUN: --set-section-flags=.baz=code --set-section-flags=.rela.baz=code %t %t.code24# RUN: llvm-readobj --sections %t.code | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXEC,WRITE25# RUN: llvm-objcopy --set-section-flags=.foo=data \26# RUN: --set-section-flags=.baz=data --set-section-flags=.rela.baz=data %t %t.data27# RUN: llvm-readobj --sections %t.data | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE28# RUN: llvm-objcopy --set-section-flags=.foo=rom \29# RUN: --set-section-flags=.baz=rom --set-section-flags=.rela.baz=rom %t %t.rom30# RUN: llvm-readobj --sections %t.rom | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE31# RUN: llvm-objcopy --set-section-flags=.foo=contents \32# RUN: --set-section-flags=.baz=contents --set-section-flags=.rela.baz=contents %t %t.contents33# RUN: llvm-readobj --sections %t.contents | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE34# RUN: llvm-objcopy --set-section-flags=.foo=merge \35# RUN: --set-section-flags=.baz=merge --set-section-flags=.rela.baz=merge %t %t.merge36# RUN: llvm-readobj --sections %t.merge | FileCheck %s --check-prefixes=CHECK,MERGE,PROGBITS,WRITE37# RUN: llvm-objcopy --set-section-flags=.foo=strings \38# RUN: --set-section-flags=.baz=strings --set-section-flags=.rela.baz=strings %t %t.strings39# RUN: llvm-readobj --sections %t.strings | FileCheck %s --check-prefixes=CHECK,STRINGS,PROGBITS,WRITE40# RUN: llvm-objcopy --set-section-flags=.foo=share \41# RUN: --set-section-flags=.baz=share --set-section-flags=.rela.baz=share %t %t.share42# RUN: llvm-readobj --sections %t.share | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE43# RUN: llvm-objcopy --set-section-flags=.foo=large \44# RUN: --set-section-flags=.baz=large --set-section-flags=.rela.baz=large %t %t.large45# RUN: llvm-readobj --sections %t.large | FileCheck %s --check-prefixes=CHECK,LARGE,PROGBITS,WRITE46# RUN: llvm-objcopy --set-section-flags=.foo=data \47# RUN: --set-section-flags=.baz=data --set-section-flags=.rela.baz=data %t %t.no-large48# RUN: llvm-readobj --sections %t.no-large | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE49 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_strings54# RUN: llvm-readobj --sections %t.alloc_ro_strings | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,STRINGS55# 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_code58# RUN: llvm-readobj --sections %t.alloc_code | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,EXEC,WRITE59 60# Invalid flags:61# RUN: not llvm-objcopy --set-section-flags=.foo=xyzzy %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG62 63# Bad flag format:64# RUN: not llvm-objcopy --set-section-flags=.foo %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT65 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-SETS68 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.upper73# RUN: llvm-readobj --sections %t.upper | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS74 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.mixed79# RUN: llvm-readobj --sections %t.mixed | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS80 81## Unspecified sections are not affected:82# RUN: llvm-objcopy --set-section-flags=.foo=alloc %t %t.unspecified83# RUN: llvm-readobj --sections %t.unspecified | FileCheck %s --check-prefixes=UNSPECIFIED84 85!ELF86FileHeader:87 Class: ELFCLASS6488 Data: ELFDATA2LSB89 Type: ET_REL90 Machine: EM_X86_6491Sections:92 - Name: .foo93 Type: SHT_PROGBITS94 Flags: [ ]95 - Name: .baz96 Type: SHT_NOBITS97 Flags: [ ]98 - Name: .rela.baz99 Type: SHT_RELA100 Info: .baz101 102# CHECK: Name: .foo103# CHECK-NEXT: Type: SHT_PROGBITS104# 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: .baz115# NOBITS-NEXT: Type: SHT_NOBITS116# PROGBITS-NEXT: Type: SHT_PROGBITS117# 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.baz128# CHECK-NEXT: Type: SHT_RELA129# 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, strings143 144# UNSPECIFIED: Name: .foo145# UNSPECIFIED-NEXT: Type: SHT_PROGBITS146# UNSPECIFIED-NEXT: Flags [147# UNSPECIFIED-NEXT: SHF_ALLOC (0x2)148# UNSPECIFIED-NEXT: SHF_WRITE (0x1)149# UNSPECIFIED-NEXT: ]150 151# UNSPECIFIED: Name: .baz152# UNSPECIFIED-NEXT: Type: SHT_NOBITS153# UNSPECIFIED-NEXT: Flags [ (0x0)154# UNSPECIFIED-NEXT: ]155 156# UNSPECIFIED: Name: .rela.baz157# UNSPECIFIED-NEXT: Type: SHT_RELA158# UNSPECIFIED-NEXT: Flags [ (0x0)159# UNSPECIFIED-NEXT: ]160