"Error case 1:" is meaningless without other error cases.
How easy would it be to use FileCheck --check-prefixes, and possibly -D<NAME> options to share this block with the previous test case? That would avoid duplicating a big chunk of the expected output. You could do something like:
# RUN: ... | FileCheck --check-prefixes=REMOVE-COMMON,REMOVE-TEXT-ONLY # RUN: ... | FileCheck --check-prefixes=REMOVE-COMMON # REMOVE-COMMON: # REMOVE-COMMON-NEXT: ... # REMOVE-TEXT-ONLY-NEXT: # REMOVE-TEXT-ONLY-NEXT: ... # REMOVE-COMMON-NEXT:
Not related to this patch, but looks like this discards RemovePred, e.g. --strip-all --only-section will effectively work like --only-section.
I found this after noticing that RemovePred is not referenced in the bit you added, which is actually fine there but error prone if the iterative construction of RemovePred is ever reordered. ELF objcopy works like this too, but correctly chains RemovePred for the --only-section switch.