[llvm] [llvm-objcopy] Add llvm-objcopy option --set-visibility-sym (PR #80872)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 01:15:32 PST 2024


================
@@ -0,0 +1,43 @@
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: echo 'foo' > %t.symbols
+
+# Check if passing an invalid visibility type generates an error message
+# RUN: not llvm-objcopy %t.o --set-symbols-visibility=%t.symbols=invalid-type --regex 2>&1 | FileCheck %s --check-prefix=TYPE
+# RUN: not llvm-objcopy %t.o --set-symbol-visibility=foo=invalid-type --regex 2>&1 | FileCheck %s --check-prefix=TYPE
+# TYPE: error: 'invalid-type' is not a valid symbol visibility
+
+# Check if using the option multiple times generates an error message
+# RUN: not llvm-objcopy %t.o --set-symbols-visibility=%t.symbols=hidden \
+# RUN:                       --set-symbols-visibility=%t.symbols=default \
+# RUN:                       --regex 2>&1 | FileCheck %s --check-prefix=MULTIPLE
+# RUN: not llvm-objcopy %t.o --set-symbol-visibility=foo=hidden \
+# RUN:                       --set-symbol-visibility=bar=default \
+# RUN:                       --regex 2>&1 | FileCheck %s --check-prefix=MULTIPLE
+# RUN: not llvm-objcopy %t.o --set-symbols-visibility=%t.symbols=hidden \
+# RUN:                       --set-symbol-visibility=bar=default \
+# RUN:                       --regex 2>&1 | FileCheck %s --check-prefix=MULTIPLE
+# MULTIPLE: error: multiple specifications of visibility type
+
+# Check if not using the proper format with character '=' generates an error
+# RUN: not llvm-objcopy %t.o --set-symbols-visibility=%t.symbols,hidden 2>&1 | FileCheck %s --check-prefix=FORMAT
+# RUN: not llvm-objcopy %t.o --set-symbol-visibility=foo default 2>&1 | FileCheck %s --check-prefix=FORMAT
+# FORMAT: error: bad format for --set-symbol{{.?}}-visibility
+
+# Check if using an invalid symbol pattern generates an error
+# RUN: echo '*.' > %t.symbols.regex
+# RUN: not llvm-objcopy %t.o --set-symbols-visibility=%t.symbols.regex=hidden --regex 2>&1 | FileCheck %s --check-prefix=SYMBOL
+# RUN: not llvm-objcopy %t.o --set-symbol-visibility=*.=default --regex 2>&1 | FileCheck %s --check-prefix=SYMBOL
+# SYMBOL: error: cannot compile regular expression '*.': repetition-operator operand invalid
+
+# Check passing an invalid filename generates an error
+# RUN: not llvm-objcopy %t.o --set-symbols-visibility=no_file=hidden 2>&1 | FileCheck %s --check-prefix=FILE
+# FILE: error: 'no_file': No such file or directory
----------------
jh7370 wrote:

This will need to use the lit subsitution that corresponds to the "No such file or directory" message, because different platforms will have different formats for this message. You'll find examples of it elsewhere.

https://github.com/llvm/llvm-project/pull/80872


More information about the llvm-commits mailing list