[llvm] [llvm-objcopy] Add --verbose option to llvm-strip/llvm-objcopy (PR #196611)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue May 12 00:36:21 PDT 2026
================
@@ -0,0 +1,78 @@
+## Test --verbose / -v option for llvm-objcopy and llvm-strip.
+## The output should match GNU strip's format:
+## copy from `<input>' [<format>] to `<output>' [<format>]
+
+# RUN: yaml2obj %s -o %t.o
+
+## llvm-objcopy --verbose and -v both print the copy message to stdout.
+# RUN: llvm-objcopy --verbose %t.o %t.out 2>/dev/null \
+# RUN: | FileCheck %s --check-prefix=OBJCOPY -DIN=%t.o -DOUT=%t.out
+# RUN: llvm-objcopy -v %t.o %t.out 2>/dev/null \
+# RUN: | FileCheck %s --check-prefix=OBJCOPY -DIN=%t.o -DOUT=%t.out
+# OBJCOPY: copy from `[[IN]]' [elf64-x86-64] to `[[OUT]]' [elf64-x86-64]
+
+## Each run produces exactly one line.
+# RUN: llvm-objcopy --verbose %t.o %t.out 2>/dev/null | count 1
+
+## llvm-objcopy with a single positional argument modifies the file in-place;
+## input and output file names in the message match.
+# RUN: cp %t.o %t.inplace.o
+# RUN: llvm-objcopy --verbose %t.inplace.o 2>/dev/null \
+# RUN: | FileCheck %s --check-prefix=INPLACE -DF=%t.inplace.o
+# INPLACE: copy from `[[F]]' [elf64-x86-64] to `[[F]]' [elf64-x86-64]
+
+## llvm-strip --verbose and -v print one line per input file.
+# RUN: cp %t.o %t.strip1.o
+# RUN: cp %t.o %t.strip2.o
+# RUN: llvm-strip --verbose %t.strip1.o %t.strip2.o 2>/dev/null \
+# RUN: | FileCheck %s --check-prefix=STRIP \
+# RUN: -DF1=%t.strip1.o -DF2=%t.strip2.o
+# RUN: cp %t.o %t.strip3.o
+# RUN: cp %t.o %t.strip4.o
+# RUN: llvm-strip -v %t.strip3.o %t.strip4.o 2>/dev/null \
+# RUN: | FileCheck %s --check-prefix=STRIP \
+# RUN: -DF1=%t.strip3.o -DF2=%t.strip4.o
+# STRIP: copy from `[[F1]]' [elf64-x86-64] to `[[F1]]' [elf64-x86-64]
+# STRIP-NEXT: copy from `[[F2]]' [elf64-x86-64] to `[[F2]]' [elf64-x86-64]
+
+## Two inputs produce exactly two lines.
+# RUN: cp %t.o %t.cnt1.o
+# RUN: cp %t.o %t.cnt2.o
+# RUN: llvm-strip --verbose %t.cnt1.o %t.cnt2.o 2>/dev/null | count 2
+
----------------
jh7370 wrote:
As noted in my previous round of comments, you can use `--implicit-check-not={{.}}` to show that the output matches exactly what is checked for. You add this to the FileCheck commands in each case.
https://github.com/llvm/llvm-project/pull/196611
More information about the llvm-commits
mailing list