@@ -131,6 +131,26 @@ int cmd_parse_options(int argc, const char **argv, const char * const usage[])
131
131
132
132
static bool opts_valid (void )
133
133
{
134
+ if (opts .mnop && !opts .mcount ) {
135
+ ERROR ("--mnop requires --mcount" );
136
+ return false;
137
+ }
138
+
139
+ if (opts .noinstr && !opts .link ) {
140
+ ERROR ("--noinstr requires --link" );
141
+ return false;
142
+ }
143
+
144
+ if (opts .ibt && !opts .link ) {
145
+ ERROR ("--ibt requires --link" );
146
+ return false;
147
+ }
148
+
149
+ if (opts .unret && !opts .link ) {
150
+ ERROR ("--unret requires --link" );
151
+ return false;
152
+ }
153
+
134
154
if (opts .hack_jump_label ||
135
155
opts .hack_noinstr ||
136
156
opts .ibt ||
@@ -158,45 +178,6 @@ static bool opts_valid(void)
158
178
return false;
159
179
}
160
180
161
- static bool mnop_opts_valid (void )
162
- {
163
- if (opts .mnop && !opts .mcount ) {
164
- ERROR ("--mnop requires --mcount" );
165
- return false;
166
- }
167
-
168
- return true;
169
- }
170
-
171
- static bool link_opts_valid (struct objtool_file * file )
172
- {
173
- if (opts .link )
174
- return true;
175
-
176
- if (has_multiple_files (file -> elf )) {
177
- ERROR ("Linked object detected, forcing --link" );
178
- opts .link = true;
179
- return true;
180
- }
181
-
182
- if (opts .noinstr ) {
183
- ERROR ("--noinstr requires --link" );
184
- return false;
185
- }
186
-
187
- if (opts .ibt ) {
188
- ERROR ("--ibt requires --link" );
189
- return false;
190
- }
191
-
192
- if (opts .unret ) {
193
- ERROR ("--unret requires --link" );
194
- return false;
195
- }
196
-
197
- return true;
198
- }
199
-
200
181
int objtool_run (int argc , const char * * argv )
201
182
{
202
183
const char * objname ;
@@ -216,11 +197,10 @@ int objtool_run(int argc, const char **argv)
216
197
if (!file )
217
198
return 1 ;
218
199
219
- if (!mnop_opts_valid ())
220
- return 1 ;
221
-
222
- if (!link_opts_valid (file ))
223
- return 1 ;
200
+ if (!opts .link && has_multiple_files (file -> elf )) {
201
+ ERROR ("Linked object detected, forcing --link" );
202
+ opts .link = true;
203
+ }
224
204
225
205
ret = check (file );
226
206
if (ret )
0 commit comments