Skip to content

Commit 8b56d9e

Browse files
authored
[llvm-objcopy] Improve help messages (#82830)
https://reviews.llvm.org/D63820 added llvm/docs/CommandGuide/llvm-objcopy.rst with clearer semantics, e.g. ``` Read a list of names from the file <filename> and mark defined symbols with those names as global in the output instead of the help message Read a list of symbols from <filename> and marks them global" (omits "defined") Rename sections called <old> to <new> in the output instead of the help message Rename a section from old to new (multiple sections may be named <old> ``` Sync the help messages to incorporate the CommandGuide improvement. While here, switch to the conventional imperative sentences for a few options. Additionally, mark some options as grp_coff or grp_macho.
1 parent b70f42a commit 8b56d9e

File tree

3 files changed

+54
-52
lines changed

3 files changed

+54
-52
lines changed

llvm/docs/CommandGuide/llvm-objcopy.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ them.
450450
Set the type of section ``<section>`` to the integer ``<type>``. Can be
451451
specified multiple times to update multiple sections.
452452

453-
.. option:: --set-start-addr <addr>
453+
.. option:: --set-start <addr>
454454

455455
Set the start address of the output to ``<addr>``. Overrides any previously
456456
specified :option:`--change-start` or :option:`--adjust-start` options.
@@ -484,7 +484,7 @@ them.
484484

485485
.. option:: --weaken-symbol <symbol>, -W
486486

487-
Mark any global symbol named ``<symbol>`` as a weak symbol in the output. Can
487+
Mark global symbols named ``<symbol>`` as weak symbols in the output. Can
488488
be specified multiple times to mark multiple symbols as weak.
489489

490490
.. option:: --weaken-symbols <filename>

llvm/tools/llvm-objcopy/CommonOpts.td

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ multiclass Eq<string name, string help> {
77
HelpText<help>;
88
}
99

10+
def grp_coff : OptionGroup<"kind">, HelpText<"OPTIONS (COFF specific)">;
11+
def grp_macho : OptionGroup<"kind">, HelpText<"OPTIONS (Mach-O specific)">;
12+
1013
def help : Flag<["--"], "help">;
1114
def h : Flag<["-"], "h">, Alias<help>;
1215

@@ -39,13 +42,13 @@ def p : Flag<["-"], "p">,
3942
HelpText<"Alias for --preserve-dates">;
4043

4144
def strip_all : Flag<["--"], "strip-all">,
42-
HelpText<"Remove non-allocated sections outside segments. "
43-
".gnu.warning* and .ARM.attribute sections are not "
44-
"removed">;
45+
HelpText<"For ELF, remove all symbols and non-alloc sections not within "
46+
"segments, except for .gnu.warning*, .ARM.attribute, and the section name table. "
47+
"For COFF and Mach-O, remove all symbols, debug sections, and relocations">;
4548

4649
def strip_all_gnu
4750
: Flag<["--"], "strip-all-gnu">,
48-
HelpText<"Compatible with GNU's --strip-all">;
51+
HelpText<"Remove all symbols, debug sections and relocations. Compatible with GNU's --strip-all">;
4952

5053
def strip_debug : Flag<["--"], "strip-debug">,
5154
HelpText<"Remove all debug sections">;
@@ -64,7 +67,7 @@ def R : JoinedOrSeparate<["-"], "R">,
6467

6568
def strip_sections
6669
: Flag<["--"], "strip-sections">,
67-
HelpText<"Remove all section headers and all sections not in segments">;
70+
HelpText<"Remove all section headers and all section data not within segments">;
6871

6972
defm strip_symbol : Eq<"strip-symbol", "Strip <symbol>">,
7073
MetaVarName<"symbol">;
@@ -75,17 +78,17 @@ def N : JoinedOrSeparate<["-"], "N">,
7578
defm keep_section : Eq<"keep-section", "Keep <section>">,
7679
MetaVarName<"section">;
7780

78-
defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
81+
defm keep_symbol : Eq<"keep-symbol", "When removing symbols, do not remove <symbol>">,
7982
MetaVarName<"symbol">;
8083
def K : JoinedOrSeparate<["-"], "K">,
8184
Alias<keep_symbol>,
8285
HelpText<"Alias for --keep-symbol">;
8386

8487
def keep_file_symbols : Flag<["--"], "keep-file-symbols">,
85-
HelpText<"Do not remove file symbols">;
88+
HelpText<"Keep symbols of type STT_FILE, even if they would otherwise be stripped">;
8689

8790
def keep_undefined : Flag<["--"], "keep-undefined">,
88-
HelpText<"Do not remove undefined symbols">;
91+
HelpText<"Do not remove undefined symbols">, Group<grp_macho>;
8992

9093
def only_keep_debug
9194
: Flag<["--"], "only-keep-debug">,
@@ -94,16 +97,16 @@ def only_keep_debug
9497
"sections useful for debugging purposes">;
9598

9699
def discard_locals : Flag<["--"], "discard-locals">,
97-
HelpText<"Remove compiler-generated local symbols, (e.g. "
98-
"symbols starting with .L)">;
100+
HelpText<"Remove local symbols starting with .L">;
99101
def X : Flag<["-"], "X">,
100102
Alias<discard_locals>,
101103
HelpText<"Alias for --discard-locals">;
102104

103105
def discard_all
104106
: Flag<["--"], "discard-all">,
105-
HelpText<"Remove all local symbols except file and section symbols. Also "
106-
"remove all debug sections">;
107+
HelpText<"Remove most local symbols. Different file formats may limit this to a subset. "
108+
"For ELF, file and section symbols are not discarded. "
109+
"Additionally, remove all debug sections">;
107110
def x : Flag<["-"], "x">,
108111
Alias<discard_all>,
109112
HelpText<"Alias for --discard-all">;

llvm/tools/llvm-objcopy/ObjcopyOpts.td

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,25 @@ def B : JoinedOrSeparate<["-"], "B">,
66
Alias<binary_architecture>,
77
HelpText<"Alias for --binary-architecture">;
88

9-
defm target : Eq<"target", "Format of the input and output file">,
9+
defm target : Eq<"target", "Equivalent to --input-target and --output-target for the specified format">,
1010
Values<"binary">;
1111
def F : JoinedOrSeparate<["-"], "F">,
1212
Alias<target>,
1313
HelpText<"Alias for --target">;
1414

15-
defm input_target : Eq<"input-target", "Format of the input file">,
16-
Values<"binary">;
15+
defm input_target : Eq<"input-target", "Read the input as the specified format">, MetaVarName<"format">;
1716
def I : JoinedOrSeparate<["-"], "I">,
1817
Alias<input_target>,
1918
HelpText<"Alias for --input-target">;
2019

21-
defm output_target : Eq<"output-target", "Format of the output file">,
22-
Values<"binary">;
20+
defm output_target : Eq<"output-target", "Write the output as the specified format">, MetaVarName<"format">;
2321
def O : JoinedOrSeparate<["-"], "O">,
2422
Alias<output_target>,
2523
HelpText<"Alias for --output-target">;
2624

27-
defm new_symbol_visibility : Eq<"new-symbol-visibility", "Visibility of "
28-
"symbols generated for binary input or added"
29-
" with --add-symbol unless otherwise"
30-
" specified. The default value is 'default'">;
25+
defm new_symbol_visibility
26+
: Eq<"new-symbol-visibility", "Specify the visibility of symbols automatically "
27+
"created when using binary input or --add-symbol. The default is 'default'">;
3128

3229
def compress_debug_sections
3330
: Joined<["--"], "compress-debug-sections=">,
@@ -39,8 +36,8 @@ def : Flag<["--"], "compress-debug-sections">, Alias<compress_debug_sections>,
3936
def decompress_debug_sections : Flag<["--"], "decompress-debug-sections">,
4037
HelpText<"Decompress DWARF debug sections">;
4138
defm split_dwo
42-
: Eq<"split-dwo", "Equivalent to extract-dwo on the input file to "
43-
"<dwo-file>, then strip-dwo on the input file">,
39+
: Eq<"split-dwo", "Equivalent to --extract-dwo and <dwo-file> as the output file and no other options, "
40+
"and then --strip-dwo on the input file">,
4441
MetaVarName<"dwo-file">;
4542

4643
defm add_gnu_debuglink
@@ -49,17 +46,15 @@ defm add_gnu_debuglink
4946

5047
defm rename_section
5148
: Eq<"rename-section",
52-
"Renames a section from old to new, optionally with specified flags. "
53-
"Flags supported for GNU compatibility: alloc, load, noload, "
54-
"readonly, exclude, debug, code, data, rom, share, contents, merge, "
55-
"strings, large">,
49+
"Rename sections called <old> to <new>, and apply any specified <flag> values. "
50+
"See --set-section-flags for a list of supported flags">,
5651
MetaVarName<"old=new[,flag1,...]">;
5752
defm redefine_symbol
5853
: Eq<"redefine-sym", "Change the name of a symbol old to new">,
5954
MetaVarName<"old=new">;
6055
defm redefine_symbols
6156
: Eq<"redefine-syms",
62-
"Reads a list of symbol pairs from <filename> and runs as if "
57+
"Read a list of symbol pairs from <filename> and run as if "
6358
"--redefine-sym=<old>=<new> is set for each one. <filename> "
6459
"contains two symbols per line separated with whitespace and may "
6560
"contain comments beginning with '#'. Leading and trailing "
@@ -74,7 +69,7 @@ def j : JoinedOrSeparate<["-"], "j">,
7469
HelpText<"Alias for --only-section">;
7570
defm add_section
7671
: Eq<"add-section",
77-
"Make a section named <section> with the contents of <file>">,
72+
"Add a section named <section> with the contents of <file>">,
7873
MetaVarName<"section=file">;
7974

8075
defm set_section_alignment
@@ -83,8 +78,8 @@ defm set_section_alignment
8378

8479
defm set_section_flags
8580
: Eq<"set-section-flags",
86-
"Set section flags for a given section. Flags supported for GNU "
87-
"compatibility: alloc, load, noload, readonly, exclude, debug, code, "
81+
"Set section properties based on the specified <flags>. Supported flag names are: "
82+
"alloc, load, noload, readonly, exclude, debug, code, "
8883
"data, rom, share, contents, merge, strings, large">,
8984
MetaVarName<"section=flag1[,flag2,...]">;
9085

@@ -97,24 +92,25 @@ def S : Flag<["-"], "S">,
9792
Alias<strip_all>,
9893
HelpText<"Alias for --strip-all">;
9994
def strip_dwo : Flag<["--"], "strip-dwo">,
100-
HelpText<"Remove all DWARF .dwo sections from file">;
95+
HelpText<"Remove all DWARF .dwo sections">;
10196
def strip_non_alloc
10297
: Flag<["--"], "strip-non-alloc">,
103-
HelpText<"Remove all non-allocated sections outside segments">;
98+
HelpText<"Remove all non-allocated sections that are not within segments">;
10499
defm strip_unneeded_symbol
105100
: Eq<"strip-unneeded-symbol",
106-
"Remove symbol <symbol> if it is not needed by relocations">,
101+
"Remove all symbols named <symbol> that are local or undefined and "
102+
"are not required by any relocation">,
107103
MetaVarName<"symbol">;
108104
defm strip_unneeded_symbols
109105
: Eq<"strip-unneeded-symbols",
110-
"Reads a list of symbols from <filename> and removes them "
111-
"if they are not needed by relocations">,
106+
"Remove all symbols whose names appear in the file <file>, if they "
107+
"are local or undefined and are not required by any relocation">,
112108
MetaVarName<"filename">;
113109

114110
defm subsystem
115111
: Eq<"subsystem",
116-
"Set PE subsystem and version">,
117-
MetaVarName<"name[:version]">;
112+
"Set the PE subsystem, and optionally subsystem version">,
113+
MetaVarName<"name[:version]">, Group<grp_coff>;
118114

119115
def extract_dwo
120116
: Flag<["--"], "extract-dwo">,
@@ -132,11 +128,13 @@ def localize_hidden
132128
: Flag<["--"], "localize-hidden">,
133129
HelpText<
134130
"Mark all symbols that have hidden or internal visibility as local">;
135-
defm localize_symbol : Eq<"localize-symbol", "Mark <symbol> as local">,
136-
MetaVarName<"symbol">;
131+
defm localize_symbol
132+
: Eq<"localize-symbol", "Mark any defined non-common symbol named <symbol> as local">,
133+
MetaVarName<"symbol">;
137134
defm localize_symbols
138135
: Eq<"localize-symbols",
139-
"Reads a list of symbols from <filename> and marks them local">,
136+
"Read a list of names from <filename> and mark any defined non-common "
137+
"symbols with those names as local">,
140138
MetaVarName<"filename">;
141139

142140
def L : JoinedOrSeparate<["-"], "L">,
@@ -148,48 +146,49 @@ defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">,
148146

149147
defm globalize_symbols
150148
: Eq<"globalize-symbols",
151-
"Reads a list of symbols from <filename> and marks them global">,
149+
"Read a list of symbols from <filename> and mark defined symbols"
150+
" with those names as global">,
152151
MetaVarName<"filename">;
153152

154153
defm keep_global_symbol
155154
: Eq<"keep-global-symbol",
156-
"Convert all symbols except <symbol> to local. May be repeated to "
157-
"convert all except a set of symbols to local">,
155+
"Mark all symbols local, except for symbols with the name <symbol>. "
156+
"Can be specified multiple times to ignore multiple symbols">,
158157
MetaVarName<"symbol">;
159158
def G : JoinedOrSeparate<["-"], "G">,
160159
Alias<keep_global_symbol>,
161160
HelpText<"Alias for --keep-global-symbol">;
162161

163162
defm keep_global_symbols
164163
: Eq<"keep-global-symbols",
165-
"Reads a list of symbols from <filename> and runs as if "
164+
"Read a list of symbols from <filename> and run as if "
166165
"--keep-global-symbol=<symbol> is set for each one. <filename> "
167166
"contains one symbol per line and may contain comments beginning with "
168167
"'#'. Leading and trailing whitespace is stripped from each line. May "
169168
"be repeated to read symbols from many files">,
170169
MetaVarName<"filename">;
171170

172-
defm weaken_symbol : Eq<"weaken-symbol", "Mark <symbol> as weak">,
171+
defm weaken_symbol : Eq<"weaken-symbol", "Mark global symbols named <symbol> as weak">,
173172
MetaVarName<"symbol">;
174173
defm weaken_symbols
175174
: Eq<"weaken-symbols",
176-
"Reads a list of symbols from <filename> and marks them weak">,
175+
"Read a list of symbols from <filename> and mark global symbols with those names as weak">,
177176
MetaVarName<"filename">;
178177

179178
def W : JoinedOrSeparate<["-"], "W">,
180179
Alias<weaken_symbol>,
181180
HelpText<"Alias for --weaken-symbol">;
182181
def weaken : Flag<["--"], "weaken">,
183-
HelpText<"Mark all global symbols as weak">;
182+
HelpText<"Mark all defined global symbols as weak">;
184183

185184
defm strip_symbols
186185
: Eq<"strip-symbols",
187-
"Reads a list of symbols from <filename> and removes them">,
186+
"Remove all symbols whose names appear in the file <filename>">,
188187
MetaVarName<"filename">;
189188

190189
defm keep_symbols
191190
: Eq<"keep-symbols",
192-
"Reads a list of symbols from <filename> and runs as if "
191+
"Read a list of symbols from <filename> and run as if "
193192
"--keep-symbol=<symbol> is set for each one. <filename> "
194193
"contains one symbol per line and may contain comments beginning with "
195194
"'#'. Leading and trailing whitespace is stripped from each line. May "

0 commit comments

Comments
 (0)