Index: llvm/test/tools/llvm-objcopy/COFF/add-section.test =================================================================== --- llvm/test/tools/llvm-objcopy/COFF/add-section.test +++ llvm/test/tools/llvm-objcopy/COFF/add-section.test @@ -3,7 +3,7 @@ ## Test that llvm-objcopy adds a section to the given object with expected ## contents. # RUN: echo DEADBEEF > %t.sec -# RUN: llvm-objcopy --add-section=.test.section=%t.sec %t %t1 +# RUN: llvm-objcopy --add-section=.test.section=%t.sec -- %t %t1 # RUN: llvm-readobj --file-headers --sections --section-data %t1 | FileCheck %s --check-prefixes=CHECK-ADD # CHECK-ADD: SectionCount: 2 @@ -18,7 +18,7 @@ # CHECK-ADD-NEXT: ) ## Test that llvm-objcopy can add a section with an empty name. -# RUN: llvm-objcopy --add-section==%t.sec %t %t1.empty.name +# RUN: llvm-objcopy --add-section==%t.sec -- %t %t1.empty.name # RUN: llvm-readobj --file-headers --sections --section-data %t1.empty.name | FileCheck %s --check-prefixes=CHECK-ADD-EMPTY-NAME # CHECK-ADD-EMPTY-NAME: SectionCount: 2 @@ -36,7 +36,7 @@ ## relocations. # RUN: %python %p/../Inputs/ungzip.py %p/Inputs/x86_64-obj-xrelocs.yaml.gz > %t.xrelocs.yaml # RUN: yaml2obj %t.xrelocs.yaml -o %t.xrelocs.obj -# RUN: llvm-objcopy --add-section=.test.section=%t.sec %t.xrelocs.obj %t1.xrelocs.obj +# RUN: llvm-objcopy --add-section=.test.section=%t.sec -- %t.xrelocs.obj %t1.xrelocs.obj # RUN: llvm-readobj --file-headers --sections --section-data %t1.xrelocs.obj | FileCheck %s --check-prefixes=CHECK-EXTENDED-RELOCS # CHECK-EXTENDED-RELOCS: SectionCount: 2 @@ -59,17 +59,17 @@ ## Test that llvm-objcopy produces an error if the file with section contents ## to be added does not exist. -# RUN: not llvm-objcopy --add-section=.another.section=%t2 %t %t3 2>&1 | FileCheck -DFILE1=%t -DFILE2=%t2 -DMSG=%errc_ENOENT %s --check-prefixes=ERR1 +# RUN: not llvm-objcopy --add-section=.another.section=%t2 -- %t %t3 2>&1 | FileCheck -DFILE1=%t -DFILE2=%t2 -DMSG=%errc_ENOENT %s --check-prefixes=ERR1 # ERR1: error: '[[FILE1]]': '[[FILE2]]': [[MSG]] ## Another negative test for invalid --add-sections command line argument. -# RUN: not llvm-objcopy --add-section=.another.section %t %t3 2>&1 | FileCheck %s --check-prefixes=ERR2 +# RUN: not llvm-objcopy --add-section=.another.section -- %t %t3 2>&1 | FileCheck %s --check-prefixes=ERR2 # ERR2: error: bad format for --add-section: missing '=' ## Negative test for invalid --add-sections argument - missing file name. -# RUN: not llvm-objcopy --add-section=.section.name= %t %t3 2>&1 | FileCheck %s --check-prefixes=ERR3 +# RUN: not llvm-objcopy --add-section=.section.name= -- %t %t3 2>&1 | FileCheck %s --check-prefixes=ERR3 # ERR3: error: bad format for --add-section: missing file name Index: llvm/test/tools/llvm-objcopy/COFF/set-section-flags.test =================================================================== --- llvm/test/tools/llvm-objcopy/COFF/set-section-flags.test +++ llvm/test/tools/llvm-objcopy/COFF/set-section-flags.test @@ -1,54 +1,54 @@ # RUN: yaml2obj %s -o %t ## Single flag on a section with no flags: -# RUN: llvm-objcopy --set-section-flags=.foo=alloc %t %t.alloc +# RUN: llvm-objcopy --set-section-flags=.foo=alloc -- %t %t.alloc # RUN: llvm-readobj --sections %t.alloc | FileCheck %s --check-prefixes=CHECK,UNINITDATA,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=load %t %t.load +# RUN: llvm-objcopy --set-section-flags=.foo=load -- %t %t.load # RUN: llvm-readobj --sections %t.load | FileCheck %s --check-prefixes=CHECK,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=noload %t %t.noload +# RUN: llvm-objcopy --set-section-flags=.foo=noload -- %t %t.noload # RUN: llvm-readobj --sections %t.noload | FileCheck %s --check-prefixes=CHECK,READ,WRITE,REMOVE -# RUN: llvm-objcopy --set-section-flags=.foo=readonly %t %t.readonly +# RUN: llvm-objcopy --set-section-flags=.foo=readonly -- %t %t.readonly # RUN: llvm-readobj --sections %t.readonly | FileCheck %s --check-prefixes=CHECK,READ -# RUN: llvm-objcopy --set-section-flags=.foo=exclude %t %t.exclude +# RUN: llvm-objcopy --set-section-flags=.foo=exclude -- %t %t.exclude # RUN: llvm-readobj --sections %t.exclude | FileCheck %s --check-prefixes=CHECK,READ,WRITE,REMOVE -# RUN: llvm-objcopy --set-section-flags=.foo=debug %t %t.debug +# RUN: llvm-objcopy --set-section-flags=.foo=debug -- %t %t.debug # RUN: llvm-readobj --sections %t.debug | FileCheck %s --check-prefixes=CHECK,INITDATA,DISCARDABLE,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=code %t %t.code +# RUN: llvm-objcopy --set-section-flags=.foo=code -- %t %t.code # RUN: llvm-readobj --sections %t.code | FileCheck %s --check-prefixes=CHECK,CODE,EXECUTE,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=data %t %t.data +# RUN: llvm-objcopy --set-section-flags=.foo=data -- %t %t.data # RUN: llvm-readobj --sections %t.data | FileCheck %s --check-prefixes=CHECK,INITDATA,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=rom %t %t.rom +# RUN: llvm-objcopy --set-section-flags=.foo=rom -- %t %t.rom # RUN: llvm-readobj --sections %t.rom | FileCheck %s --check-prefixes=CHECK,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=contents %t %t.contents +# RUN: llvm-objcopy --set-section-flags=.foo=contents -- %t %t.contents # RUN: llvm-readobj --sections %t.contents | FileCheck %s --check-prefixes=CHECK,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=merge %t %t.merge +# RUN: llvm-objcopy --set-section-flags=.foo=merge -- %t %t.merge # RUN: llvm-readobj --sections %t.merge | FileCheck %s --check-prefixes=CHECK,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=strings %t %t.strings +# RUN: llvm-objcopy --set-section-flags=.foo=strings -- %t %t.strings # RUN: llvm-readobj --sections %t.strings | FileCheck %s --check-prefixes=CHECK,READ,WRITE -# RUN: llvm-objcopy --set-section-flags=.foo=share %t %t.share +# RUN: llvm-objcopy --set-section-flags=.foo=share -- %t %t.share # RUN: llvm-readobj --sections %t.share | FileCheck %s --check-prefixes=CHECK,READ,SHARED,WRITE ## Multiple flags: -# RUN: llvm-objcopy --set-section-flags=.foo=alloc,readonly,share %t %t.alloc_ro_share +# RUN: llvm-objcopy --set-section-flags=.foo=alloc,readonly,share -- %t %t.alloc_ro_share # RUN: llvm-readobj --sections %t.alloc_ro_share | FileCheck %s --check-prefixes=CHECK,UNINITDATA,READ,SHARED -# RUN: llvm-objcopy --set-section-flags=.foo=alloc,code %t %t.alloc_code +# RUN: llvm-objcopy --set-section-flags=.foo=alloc,code -- %t %t.alloc_code # RUN: llvm-readobj --sections %t.alloc_code | FileCheck %s --check-prefixes=CHECK,CODE,UNINITDATA,EXECUTE,READ,WRITE ## Invalid flags: -# RUN: not llvm-objcopy --set-section-flags=.foo=xyzzy %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG +# RUN: not llvm-objcopy --set-section-flags=.foo=xyzzy -- %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG ## Bad flag format: -# RUN: not llvm-objcopy --set-section-flags=.foo %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT +# RUN: not llvm-objcopy --set-section-flags=.foo -- %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT ## Setting flags for the same section multiple times: -# RUN: not llvm-objcopy --set-section-flags=.foo=alloc --set-section-flags=.foo=load %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-SETS +# RUN: not llvm-objcopy --set-section-flags=.foo=alloc --set-section-flags=.foo=load -- %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-SETS ## Upper-case flags: -# RUN: llvm-objcopy --set-section-flags=.foo=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE %t %t.upper +# RUN: llvm-objcopy --set-section-flags=.foo=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE -- %t %t.upper # RUN: llvm-readobj --sections %t.upper | FileCheck %s --check-prefixes=CHECK,CODE,INITDATA,REMOVE,DISCARDABLE,EXECUTE,READ,SHARED ## Mixed-case flags: -# RUN: llvm-objcopy --set-section-flags=.foo=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE %t %t.mixed +# RUN: llvm-objcopy --set-section-flags=.foo=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE -- %t %t.mixed # RUN: llvm-readobj --sections %t.mixed | FileCheck %s --check-prefixes=CHECK,CODE,INITDATA,REMOVE,DISCARDABLE,EXECUTE,READ,SHARED --- !COFF Index: llvm/test/tools/llvm-objcopy/ELF/add-section.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/add-section.test +++ llvm/test/tools/llvm-objcopy/ELF/add-section.test @@ -1,7 +1,7 @@ # RUN: yaml2obj %s -o %t -# RUN: llvm-objcopy -O binary -j .test2 %t %t.sec -# RUN: llvm-objcopy -R .test2 %t %t2 -# RUN: llvm-objcopy --add-section=.test2=%t.sec %t2 %t3 +# RUN: llvm-objcopy -O binary -j .test2 -- %t %t.sec +# RUN: llvm-objcopy -R .test2 -- %t %t2 +# RUN: llvm-objcopy --add-section=.test2=%t.sec -- %t2 %t3 # RUN: llvm-readobj --file-headers --sections --section-data %t3 | FileCheck %s !ELF @@ -49,16 +49,16 @@ ## Test that llvm-objcopy produces an error if the file with section contents ## to be added does not exist. -# RUN: not llvm-objcopy --add-section=.section.name=%t.missing %t %t.out 2>&1 | FileCheck -DFILE1=%t -DFILE2=%t.missing -DMSG=%errc_ENOENT %s --check-prefixes=ERR1 +# RUN: not llvm-objcopy --add-section=.section.name=%t.missing -- %t %t.out 2>&1 | FileCheck -DFILE1=%t -DFILE2=%t.missing -DMSG=%errc_ENOENT %s --check-prefixes=ERR1 # ERR1: error: '[[FILE1]]': '[[FILE2]]': [[MSG]] ## Negative test for invalid --add-sections argument - missing '='. -# RUN: not llvm-objcopy --add-section=.section.name %t %t.out 2>&1 | FileCheck %s --check-prefixes=ERR2 +# RUN: not llvm-objcopy --add-section=.section.name -- %t %t.out 2>&1 | FileCheck %s --check-prefixes=ERR2 # ERR2: error: bad format for --add-section: missing '=' ## Negative test for invalid --add-sections argument - missing file name. -# RUN: not llvm-objcopy --add-section=.section.name= %t %t.out 2>&1 | FileCheck %s --check-prefixes=ERR3 +# RUN: not llvm-objcopy --add-section=.section.name= -- %t %t.out 2>&1 | FileCheck %s --check-prefixes=ERR3 # ERR3: error: bad format for --add-section: missing file name Index: llvm/test/tools/llvm-objcopy/ELF/set-section-flags.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/set-section-flags.test +++ llvm/test/tools/llvm-objcopy/ELF/set-section-flags.test @@ -2,78 +2,78 @@ # Single flags on a section with no flags: # RUN: llvm-objcopy --set-section-flags=.foo=alloc \ -# RUN: --set-section-flags=.baz=alloc --set-section-flags=.rela.baz=alloc %t %t.alloc +# RUN: --set-section-flags=.baz=alloc --set-section-flags=.rela.baz=alloc -- %t %t.alloc # RUN: llvm-readobj --sections %t.alloc | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=load \ -# RUN: --set-section-flags=.baz=load --set-section-flags=.rela.baz=load %t %t.load +# RUN: --set-section-flags=.baz=load --set-section-flags=.rela.baz=load -- %t %t.load # RUN: llvm-readobj --sections %t.load | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=noload \ -# RUN: --set-section-flags=.baz=noload --set-section-flags=.rela.baz=noload %t %t.noload +# RUN: --set-section-flags=.baz=noload --set-section-flags=.rela.baz=noload -- %t %t.noload # RUN: llvm-readobj --sections %t.noload | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=readonly \ -# RUN: --set-section-flags=.baz=readonly --set-section-flags=.rela.baz=readonly %t %t.readonly +# RUN: --set-section-flags=.baz=readonly --set-section-flags=.rela.baz=readonly -- %t %t.readonly # RUN: llvm-readobj --sections %t.readonly | FileCheck %s --check-prefixes=CHECK,PROGBITS # RUN: llvm-objcopy --set-section-flags=.foo=exclude \ -# RUN: --set-section-flags=.baz=exclude --set-section-flags=.rela.baz=exclude %t %t.exclude +# RUN: --set-section-flags=.baz=exclude --set-section-flags=.rela.baz=exclude -- %t %t.exclude # RUN: llvm-readobj --sections %t.exclude | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXCLUDE,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=debug \ -# RUN: --set-section-flags=.baz=debug --set-section-flags=.rela.baz=debug %t %t.debug +# RUN: --set-section-flags=.baz=debug --set-section-flags=.rela.baz=debug -- %t %t.debug # RUN: llvm-readobj --sections %t.debug | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=code \ -# RUN: --set-section-flags=.baz=code --set-section-flags=.rela.baz=code %t %t.code +# RUN: --set-section-flags=.baz=code --set-section-flags=.rela.baz=code -- %t %t.code # RUN: llvm-readobj --sections %t.code | FileCheck %s --check-prefixes=CHECK,PROGBITS,EXEC,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=data \ -# RUN: --set-section-flags=.baz=data --set-section-flags=.rela.baz=data %t %t.data +# RUN: --set-section-flags=.baz=data --set-section-flags=.rela.baz=data -- %t %t.data # RUN: llvm-readobj --sections %t.data | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=rom \ -# RUN: --set-section-flags=.baz=rom --set-section-flags=.rela.baz=rom %t %t.rom +# RUN: --set-section-flags=.baz=rom --set-section-flags=.rela.baz=rom -- %t %t.rom # RUN: llvm-readobj --sections %t.rom | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=contents \ -# RUN: --set-section-flags=.baz=contents --set-section-flags=.rela.baz=contents %t %t.contents +# RUN: --set-section-flags=.baz=contents --set-section-flags=.rela.baz=contents -- %t %t.contents # RUN: llvm-readobj --sections %t.contents | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=merge \ -# RUN: --set-section-flags=.baz=merge --set-section-flags=.rela.baz=merge %t %t.merge +# RUN: --set-section-flags=.baz=merge --set-section-flags=.rela.baz=merge -- %t %t.merge # RUN: llvm-readobj --sections %t.merge | FileCheck %s --check-prefixes=CHECK,MERGE,PROGBITS,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=strings \ -# RUN: --set-section-flags=.baz=strings --set-section-flags=.rela.baz=strings %t %t.strings +# RUN: --set-section-flags=.baz=strings --set-section-flags=.rela.baz=strings -- %t %t.strings # RUN: llvm-readobj --sections %t.strings | FileCheck %s --check-prefixes=CHECK,STRINGS,PROGBITS,WRITE # RUN: llvm-objcopy --set-section-flags=.foo=share \ -# RUN: --set-section-flags=.baz=share --set-section-flags=.rela.baz=share %t %t.share +# RUN: --set-section-flags=.baz=share --set-section-flags=.rela.baz=share -- %t %t.share # RUN: llvm-readobj --sections %t.share | FileCheck %s --check-prefixes=CHECK,PROGBITS,WRITE # Multiple flags: # RUN: llvm-objcopy --set-section-flags=.foo=alloc,readonly,strings \ # RUN: --set-section-flags=.baz=alloc,readonly,strings \ -# RUN: --set-section-flags=.rela.baz=alloc,readonly,strings %t %t.alloc_ro_strings +# RUN: --set-section-flags=.rela.baz=alloc,readonly,strings -- %t %t.alloc_ro_strings # RUN: llvm-readobj --sections %t.alloc_ro_strings | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,STRINGS # RUN: llvm-objcopy --set-section-flags=.foo=alloc,code \ # RUN: --set-section-flags=.baz=alloc,code \ -# RUN: --set-section-flags=.rela.baz=alloc,code %t %t.alloc_code +# RUN: --set-section-flags=.rela.baz=alloc,code -- %t %t.alloc_code # RUN: llvm-readobj --sections %t.alloc_code | FileCheck %s --check-prefixes=CHECK,NOBITS,ALLOC,EXEC,WRITE # Invalid flags: -# RUN: not llvm-objcopy --set-section-flags=.foo=xyzzy %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG +# RUN: not llvm-objcopy --set-section-flags=.foo=xyzzy -- %t %t.xyzzy 2>&1 | FileCheck %s --check-prefix=BAD-FLAG # Bad flag format: -# RUN: not llvm-objcopy --set-section-flags=.foo %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT +# RUN: not llvm-objcopy --set-section-flags=.foo -- %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT # Setting flags for the same section multiple times: -# RUN: not llvm-objcopy --set-section-flags=.foo=alloc --set-section-flags=.foo=load %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-SETS +# RUN: not llvm-objcopy --set-section-flags=.foo=alloc --set-section-flags=.foo=load -- %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-SETS # Upper-case flags: # RUN: llvm-objcopy --set-section-flags=.foo=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE \ # RUN: --set-section-flags=.baz=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE \ -# RUN: --set-section-flags=.rela.baz=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE %t %t.upper +# RUN: --set-section-flags=.rela.baz=ALLOC,LOAD,NOLOAD,READONLY,DEBUG,CODE,DATA,ROM,CONTENTS,MERGE,STRINGS,SHARE -- %t %t.upper # RUN: llvm-readobj --sections %t.upper | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS # Mixed-case flags: # RUN: llvm-objcopy --set-section-flags=.foo=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE \ # RUN: --set-section-flags=.baz=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE \ -# RUN: --set-section-flags=.rela.baz=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE %t %t.mixed +# RUN: --set-section-flags=.rela.baz=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE -- %t %t.mixed # RUN: llvm-readobj --sections %t.mixed | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS ## Unspecified sections are not affected: -# RUN: llvm-objcopy --set-section-flags=.foo=alloc %t %t.unspecified +# RUN: llvm-objcopy --set-section-flags=.foo=alloc -- %t %t.unspecified # RUN: llvm-readobj --sections %t.unspecified | FileCheck %s --check-prefixes=UNSPECIFIED !ELF Index: llvm/test/tools/llvm-objcopy/MachO/add-section-32.test =================================================================== --- llvm/test/tools/llvm-objcopy/MachO/add-section-32.test +++ llvm/test/tools/llvm-objcopy/MachO/add-section-32.test @@ -5,17 +5,17 @@ # RUN: echo -n abcdefg > %t.data ## Case 1: Add a new section into an existing segment. -# RUN: llvm-objcopy --add-section __TEXT,__bar=%t.data %t %t.out1 +# RUN: llvm-objcopy --add-section __TEXT,__bar=%t.data -- %t %t.out1 # RUN: llvm-readobj --sections --section-data %t.out1 \ # RUN: | FileCheck %s --check-prefixes=COMMON,CASE1 ## Case 2: Add a new section into a nonexistent segment. -# RUN: llvm-objcopy --add-section __FOO,__bar=%t.data %t %t.out2 +# RUN: llvm-objcopy --add-section __FOO,__bar=%t.data -- %t %t.out2 # RUN: llvm-readobj --sections --section-data %t.out2 \ # RUN: | FileCheck %s --check-prefixes=COMMON,CASE2 ## Case 3: Add a new section into an existing segment using /dev/null as an input. -# RUN: llvm-objcopy --add-section __TEXT,__bar=/dev/null %t %t.out3 +# RUN: llvm-objcopy --add-section __TEXT,__bar=/dev/null -- %t %t.out3 # RUN: llvm-readobj --sections --section-data %t.out3 \ # RUN: | FileCheck %s --check-prefixes=COMMON,CASE3 Index: llvm/test/tools/llvm-objcopy/MachO/add-section-64.test =================================================================== --- llvm/test/tools/llvm-objcopy/MachO/add-section-64.test +++ llvm/test/tools/llvm-objcopy/MachO/add-section-64.test @@ -5,19 +5,19 @@ # RUN: echo -n abcdefg > %t.data ## Case 1: Add a new section into an existing segment. -# RUN: llvm-objcopy --add-section __TEXT,__bar=%t.data %t %t.out1 +# RUN: llvm-objcopy --add-section __TEXT,__bar=%t.data -- %t %t.out1 # RUN: llvm-readobj --sections --section-data %t.out1 \ # RUN: | FileCheck %s --check-prefixes=COMMON,CASE1 ## Case 2: Add a new section into a nonexistent segment. -# RUN: llvm-objcopy --add-section __FOO,__bar=%t.data %t %t.out2 +# RUN: llvm-objcopy --add-section __FOO,__bar=%t.data -- %t %t.out2 # RUN: llvm-readobj --sections --section-data %t.out2 \ # RUN: | FileCheck %s --check-prefixes=COMMON,CASE2 # RUN: llvm-readobj --sections --section-data %t.out2 \ # RUN: | FileCheck %s --check-prefixes=COMMON,CASE2 ## Case 3: Add a new section into an existing segment using /dev/null as an input. -# RUN: llvm-objcopy --add-section __TEXT,__bar=/dev/null %t %t.out3 +# RUN: llvm-objcopy --add-section __TEXT,__bar=/dev/null -- %t %t.out3 # RUN: llvm-readobj --sections --section-data %t.out3 \ # RUN: | FileCheck %s --check-prefixes=COMMON,CASE3 Index: llvm/test/tools/llvm-objcopy/wasm/add-section.test =================================================================== --- llvm/test/tools/llvm-objcopy/wasm/add-section.test +++ llvm/test/tools/llvm-objcopy/wasm/add-section.test @@ -1,8 +1,8 @@ ## Test --add-section. This test dumps and removes the section first and checks ## that adding it back doesn't change the result. # RUN: yaml2obj %s -o %t -# RUN: llvm-objcopy --dump-section=producers=%t.sec --remove-section=producers %t %t2 -# RUN: llvm-objcopy --add-section=producers=%t.sec %t2 %t3 +# RUN: llvm-objcopy --dump-section=producers=%t.sec --remove-section=producers -- %t %t2 +# RUN: llvm-objcopy --add-section=producers=%t.sec -- %t2 %t3 # RUN: obj2yaml %t3 | FileCheck %s ## Check that the producers section has been added back unchanged. @@ -13,7 +13,7 @@ # Check that the section is replaced with new content in one invocation. # RUN: echo "123" > %t4 -# RUN: llvm-objcopy --remove-section=foo --add-section=foo=%t4 %t %t5 +# RUN: llvm-objcopy --remove-section=foo --add-section=foo=%t4 -- %t %t5 # RUN: obj2yaml %t5 | FileCheck %s --check-prefix=REPLACE # REPLACE: - Type: CUSTOM Index: llvm/tools/llvm-objcopy/CopyConfig.cpp =================================================================== --- llvm/tools/llvm-objcopy/CopyConfig.cpp +++ llvm/tools/llvm-objcopy/CopyConfig.cpp @@ -470,15 +470,23 @@ // help flag is set then ParseObjcopyOptions will print the help messege and // exit. Expected -parseObjcopyOptions(ArrayRef ArgsArr, +parseObjcopyOptions(ArrayRef RawArgsArr, llvm::function_ref ErrorCallback) { DriverConfig DC; ObjcopyOptTable T; + + const auto *DashDash = + std::find_if(RawArgsArr.begin(), RawArgsArr.end(), + [](StringRef Str) { return Str == "--"; }); + ArrayRef ArgsArr = makeArrayRef(RawArgsArr.begin(), DashDash); + if (DashDash != RawArgsArr.end()) + DashDash = std::next(DashDash); + unsigned MissingArgumentIndex, MissingArgumentCount; llvm::opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount); - if (InputArgs.size() == 0) { + if (InputArgs.size() == 0 && DashDash == RawArgsArr.end()) { printHelp(T, errs(), ToolType::Objcopy); exit(1); } @@ -502,6 +510,7 @@ for (auto Arg : InputArgs.filtered(OBJCOPY_INPUT)) Positional.push_back(Arg->getValue()); + std::copy(DashDash, RawArgsArr.end(), std::back_inserter(Positional)); if (Positional.empty()) return createStringError(errc::invalid_argument, "no input file specified");