1*55c81d42SFangrui Song# RUN: yaml2obj %s -o %t 26e4dc6f2SAlexander Shaposhnikov 36e4dc6f2SAlexander Shaposhnikov# Single flags on a section with no flags: 4017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,alloc \ 5017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,alloc %t %t.alloc 6017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.alloc | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,WRITE 7017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,load \ 8017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,load %t %t.load 9017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.load | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE 10017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,noload \ 11017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,noload %t %t.noload 12017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.noload | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE 13017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,readonly \ 14017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,readonly %t %t.readonly 15aa1f2c50SFangrui Song# RUN: llvm-readobj --sections %t.readonly | FileCheck %s --check-prefixes=CHECK,PROGBITS 16e446322fSSergey Dmitriev# RUN: llvm-objcopy --rename-section=.foo=.bar,exclude \ 17e446322fSSergey Dmitriev# RUN: --rename-section=.baz=.blah,exclude %t %t.exclude 18e446322fSSergey Dmitriev# RUN: llvm-readobj --sections %t.exclude | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXCLUDE,WRITE 19017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,debug \ 20017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,debug %t %t.debug 21017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.debug | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE 22017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,code \ 23017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,code %t %t.code 24017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.code | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXEC,WRITE 25017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,data \ 26017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,data %t %t.data 27017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.data | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE 28017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,rom \ 29017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,rom %t %t.rom 30017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.rom | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE 31017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,contents \ 32017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,contents %t %t.contents 33017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.contents | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE 34017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,merge \ 35017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,merge %t %t.merge 36aa1f2c50SFangrui Song# RUN: llvm-readobj --sections %t.merge | FileCheck %s --check-prefixes=CHECK,PROGBITS,MERGE,WRITE 37017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,strings \ 38017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,strings %t %t.strings 39aa1f2c50SFangrui Song# RUN: llvm-readobj --sections %t.strings | FileCheck %s --check-prefixes=CHECK,PROGBITS,STRINGS,WRITE 40017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,share \ 41017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,share %t %t.share 42aa1f2c50SFangrui Song# RUN: llvm-readobj --sections %t.share | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE 436e4dc6f2SAlexander Shaposhnikov 446e4dc6f2SAlexander Shaposhnikov# Multiple flags: 45017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,alloc,readonly,strings \ 46017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,alloc,readonly,strings %t %t.alloc_ro_strings 47017deaf1SJordan Rupprecht# RUN: llvm-readobj --sections %t.alloc_ro_strings | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,STRINGS 48017deaf1SJordan Rupprecht# RUN: llvm-objcopy --rename-section=.foo=.bar,alloc,code \ 49017deaf1SJordan Rupprecht# RUN: --rename-section=.baz=.blah,alloc,code %t %t.alloc_code 50aa1f2c50SFangrui Song# RUN: llvm-readobj --sections %t.alloc_code | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,EXEC,WRITE 516e4dc6f2SAlexander Shaposhnikov 526e4dc6f2SAlexander Shaposhnikov# Invalid flags: 536e4dc6f2SAlexander Shaposhnikov# RUN: not llvm-objcopy --rename-section=.foo=.bar,xyzzy %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG 546e4dc6f2SAlexander Shaposhnikov 55d931cf3eSJames Henderson# Upper-case flags: 56d931cf3eSJames Henderson# RUN: llvm-objcopy --rename-section=.foo=.bar,ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE \ 57d931cf3eSJames Henderson# RUN: --rename-section=.baz=.blah,ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE %t %t.upper 58d931cf3eSJames Henderson# RUN: llvm-readobj --sections %t.upper | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS 59f5b181e1SJames Henderson 60f5b181e1SJames Henderson# Mixed-case flags: 61d931cf3eSJames Henderson# RUN: llvm-objcopy --rename-section=.foo=.bar,aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE \ 62d931cf3eSJames Henderson# RUN: --rename-section=.baz=.blah,aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE %t %t.mixed 63d931cf3eSJames Henderson# RUN: llvm-readobj --sections %t.mixed | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS 64d931cf3eSJames Henderson 656e4dc6f2SAlexander Shaposhnikov!ELF 666e4dc6f2SAlexander ShaposhnikovFileHeader: 676e4dc6f2SAlexander Shaposhnikov Class: ELFCLASS64 686e4dc6f2SAlexander Shaposhnikov Data: ELFDATA2LSB 696e4dc6f2SAlexander Shaposhnikov Type: ET_REL 706e4dc6f2SAlexander Shaposhnikov Machine: EM_X86_64 716e4dc6f2SAlexander ShaposhnikovSections: 726e4dc6f2SAlexander Shaposhnikov - Name: .foo 736e4dc6f2SAlexander Shaposhnikov Type: SHT_PROGBITS 746e4dc6f2SAlexander Shaposhnikov Flags: [ ] 756e4dc6f2SAlexander Shaposhnikov Content: "c3c3c3c3" 76017deaf1SJordan Rupprecht - Name: .baz 77017deaf1SJordan Rupprecht Type: SHT_NOBITS 78017deaf1SJordan Rupprecht Flags: [ ] 796e4dc6f2SAlexander Shaposhnikov 806e4dc6f2SAlexander Shaposhnikov# CHECK: Name: .bar 816e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT: Type: SHT_PROGBITS 826e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT: Flags [ 836e4dc6f2SAlexander Shaposhnikov# ALLOC-NEXT: SHF_ALLOC (0x2) 846e4dc6f2SAlexander Shaposhnikov# EXEC-NEXT: SHF_EXECINSTR (0x4) 856e4dc6f2SAlexander Shaposhnikov# MERGE-NEXT: SHF_MERGE (0x10) 866e4dc6f2SAlexander Shaposhnikov# STRINGS-NEXT: SHF_STRINGS (0x20) 87e446322fSSergey Dmitriev# EXCLUDE-NEXT: SHF_EXCLUDE (0x80000000) 886e4dc6f2SAlexander Shaposhnikov# WRITE-NEXT: SHF_WRITE (0x1) 896e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT: ] 906e4dc6f2SAlexander Shaposhnikov 91017deaf1SJordan Rupprecht# CHECK: Name: .blah 92017deaf1SJordan Rupprecht# NOBITS-NEXT: Type: SHT_NOBITS 93017deaf1SJordan Rupprecht# PROGBITS-NEXT: Type: SHT_PROGBITS 94017deaf1SJordan Rupprecht# CHECK-NEXT: Flags [ 95017deaf1SJordan Rupprecht# ALLOC-NEXT: SHF_ALLOC (0x2) 96017deaf1SJordan Rupprecht# EXEC-NEXT: SHF_EXECINSTR (0x4) 97017deaf1SJordan Rupprecht# MERGE-NEXT: SHF_MERGE (0x10) 98017deaf1SJordan Rupprecht# STRINGS-NEXT: SHF_STRINGS (0x20) 99e446322fSSergey Dmitriev# EXCLUDE-NEXT: SHF_EXCLUDE (0x80000000) 100017deaf1SJordan Rupprecht# WRITE-NEXT: SHF_WRITE (0x1) 101017deaf1SJordan Rupprecht# CHECK-NEXT: ] 102017deaf1SJordan Rupprecht 103e446322fSSergey Dmitriev# BAD-FLAG: unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, exclude, debug, code, data, rom, share, contents, merge, strings 104