xref: /llvm-project/llvm/docs/CommandGuide/llvm-strings.rst (revision bbce75e352be0637305a1b59ac5eca7175bceece)
1llvm-strings - print strings
2============================
3
4.. program:: llvm-strings
5
6SYNOPSIS
7--------
8
9:program:`llvm-strings` [*options*] [*input...*]
10
11DESCRIPTION
12-----------
13
14:program:`llvm-strings` is a tool intended as a drop-in replacement for GNU's
15:program:`strings`, which looks for printable strings in files and writes them
16to the standard output stream. A printable string is any sequence of four (by
17default) or more printable ASCII characters. The end of the file, or any other
18byte, terminates the current sequence.
19
20:program:`llvm-strings` looks for strings in each ``input`` file specified.
21Unlike GNU :program:`strings` it looks in the entire input file, regardless of
22file format, rather than restricting the search to certain sections of object
23files. If "``-``" is specified as an ``input``, or no ``input`` is specified,
24the program reads from the standard input stream.
25
26EXAMPLE
27-------
28
29.. code-block:: console
30
31 $ cat input.txt
32 bars
33 foo
34 wibble blob
35 $ llvm-strings input.txt
36 bars
37 wibble blob
38
39OPTIONS
40-------
41
42.. option:: --all, -a
43
44 Silently ignored. Present for GNU :program:`strings` compatibility.
45
46.. option:: --bytes=<length>, -n
47
48 Set the minimum number of printable ASCII characters required for a sequence of
49 bytes to be considered a string. The default value is 4.
50
51.. option:: --help, -h
52
53 Display a summary of command line options.
54
55.. option:: --print-file-name, -f
56
57 Display the name of the containing file before each string.
58
59 Example:
60
61 .. code-block:: console
62
63  $ llvm-strings --print-file-name test.o test.elf
64  test.o: _Z5hellov
65  test.o: some_bss
66  test.o: test.cpp
67  test.o: main
68  test.elf: test.cpp
69  test.elf: test2.cpp
70  test.elf: _Z5hellov
71  test.elf: main
72  test.elf: some_bss
73
74.. option:: --radix=<radix>, -t
75
76 Display the offset within the file of each string, before the string and using
77 the specified radix. Valid ``<radix>`` values are ``o``, ``d`` and ``x`` for
78 octal, decimal and hexadecimal respectively.
79
80 Example:
81
82 .. code-block:: console
83
84  $ llvm-strings --radix=o test.o
85      1054 _Z5hellov
86      1066 .rela.text
87      1101 .comment
88      1112 some_bss
89      1123 .bss
90      1130 test.cpp
91      1141 main
92  $ llvm-strings --radix=d test.o
93      556 _Z5hellov
94      566 .rela.text
95      577 .comment
96      586 some_bss
97      595 .bss
98      600 test.cpp
99      609 main
100  $ llvm-strings -t x test.o
101      22c _Z5hellov
102      236 .rela.text
103      241 .comment
104      24a some_bss
105      253 .bss
106      258 test.cpp
107      261 main
108
109.. option:: --version
110
111 Display the version of the :program:`llvm-strings` executable.
112
113.. option:: @<FILE>
114
115 Read command-line options from response file ``<FILE>``.
116
117EXIT STATUS
118-----------
119
120:program:`llvm-strings` exits with a non-zero exit code if there is an error.
121Otherwise, it exits with code 0.
122
123BUGS
124----
125
126To report bugs, please visit <https://github.com/llvm/llvm-project/labels/tools:llvm-strings/>.
127