Skip to content

Commit 3e7be63

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool: Change "warning:" to "error: " for fatal errors
This is similar to GCC's behavior and makes it more obvious why the build failed. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/0ea76f4b0e7a370711ed9f75fd0792bb5979c2bf.1743481539.git.jpoimboe@kernel.org
1 parent 0b10177 commit 3e7be63

File tree

11 files changed

+226
-222
lines changed

11 files changed

+226
-222
lines changed

tools/objtool/arch/loongarch/decode.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static bool is_loongarch(const struct elf *elf)
6363
if (elf->ehdr.e_machine == EM_LOONGARCH)
6464
return true;
6565

66-
WARN("unexpected ELF machine type %d", elf->ehdr.e_machine);
66+
ERROR("unexpected ELF machine type %d", elf->ehdr.e_machine);
6767
return false;
6868
}
6969

@@ -327,8 +327,10 @@ const char *arch_nop_insn(int len)
327327
{
328328
static u32 nop;
329329

330-
if (len != LOONGARCH_INSN_SIZE)
331-
WARN("invalid NOP size: %d\n", len);
330+
if (len != LOONGARCH_INSN_SIZE) {
331+
ERROR("invalid NOP size: %d\n", len);
332+
return NULL;
333+
}
332334

333335
nop = LOONGARCH_INSN_NOP;
334336

@@ -339,8 +341,10 @@ const char *arch_ret_insn(int len)
339341
{
340342
static u32 ret;
341343

342-
if (len != LOONGARCH_INSN_SIZE)
343-
WARN("invalid RET size: %d\n", len);
344+
if (len != LOONGARCH_INSN_SIZE) {
345+
ERROR("invalid RET size: %d\n", len);
346+
return NULL;
347+
}
344348

345349
emit_jirl((union loongarch_instruction *)&ret, LOONGARCH_GPR_RA, LOONGARCH_GPR_ZERO, 0);
346350

tools/objtool/arch/loongarch/orc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, struct instruct
4141
orc->type = ORC_TYPE_REGS_PARTIAL;
4242
break;
4343
default:
44-
WARN_INSN(insn, "unknown unwind hint type %d", cfi->type);
44+
ERROR_INSN(insn, "unknown unwind hint type %d", cfi->type);
4545
return -1;
4646
}
4747

@@ -55,7 +55,7 @@ int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, struct instruct
5555
orc->sp_reg = ORC_REG_FP;
5656
break;
5757
default:
58-
WARN_INSN(insn, "unknown CFA base reg %d", cfi->cfa.base);
58+
ERROR_INSN(insn, "unknown CFA base reg %d", cfi->cfa.base);
5959
return -1;
6060
}
6161

@@ -72,7 +72,7 @@ int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, struct instruct
7272
orc->fp_reg = ORC_REG_FP;
7373
break;
7474
default:
75-
WARN_INSN(insn, "unknown FP base reg %d", fp->base);
75+
ERROR_INSN(insn, "unknown FP base reg %d", fp->base);
7676
return -1;
7777
}
7878

@@ -89,7 +89,7 @@ int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, struct instruct
8989
orc->ra_reg = ORC_REG_FP;
9090
break;
9191
default:
92-
WARN_INSN(insn, "unknown RA base reg %d", ra->base);
92+
ERROR_INSN(insn, "unknown RA base reg %d", ra->base);
9393
return -1;
9494
}
9595

tools/objtool/arch/x86/decode.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int is_x86_64(const struct elf *elf)
3636
case EM_386:
3737
return 0;
3838
default:
39-
WARN("unexpected ELF machine type %d", elf->ehdr.e_machine);
39+
ERROR("unexpected ELF machine type %d", elf->ehdr.e_machine);
4040
return -1;
4141
}
4242
}
@@ -173,7 +173,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
173173
ret = insn_decode(&ins, sec->data->d_buf + offset, maxlen,
174174
x86_64 ? INSN_MODE_64 : INSN_MODE_32);
175175
if (ret < 0) {
176-
WARN("can't decode instruction at %s:0x%lx", sec->name, offset);
176+
ERROR("can't decode instruction at %s:0x%lx", sec->name, offset);
177177
return -1;
178178
}
179179

@@ -321,7 +321,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
321321
break;
322322

323323
default:
324-
/* WARN ? */
324+
/* ERROR ? */
325325
break;
326326
}
327327

@@ -561,8 +561,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
561561
if (ins.prefixes.nbytes == 1 &&
562562
ins.prefixes.bytes[0] == 0xf2) {
563563
/* ENQCMD cannot be used in the kernel. */
564-
WARN("ENQCMD instruction at %s:%lx", sec->name,
565-
offset);
564+
WARN("ENQCMD instruction at %s:%lx", sec->name, offset);
566565
}
567566

568567
} else if (op2 == 0xa0 || op2 == 0xa8) {
@@ -646,7 +645,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
646645
if (disp->sym->type == STT_SECTION)
647646
func = find_symbol_by_offset(disp->sym->sec, reloc_addend(disp));
648647
if (!func) {
649-
WARN("no func for pv_ops[]");
648+
ERROR("no func for pv_ops[]");
650649
return -1;
651650
}
652651

@@ -776,7 +775,7 @@ const char *arch_nop_insn(int len)
776775
};
777776

778777
if (len < 1 || len > 5) {
779-
WARN("invalid NOP size: %d\n", len);
778+
ERROR("invalid NOP size: %d\n", len);
780779
return NULL;
781780
}
782781

@@ -796,7 +795,7 @@ const char *arch_ret_insn(int len)
796795
};
797796

798797
if (len < 1 || len > 5) {
799-
WARN("invalid RET size: %d\n", len);
798+
ERROR("invalid RET size: %d\n", len);
800799
return NULL;
801800
}
802801

tools/objtool/arch/x86/orc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, struct instruct
4040
orc->type = ORC_TYPE_REGS_PARTIAL;
4141
break;
4242
default:
43-
WARN_INSN(insn, "unknown unwind hint type %d", cfi->type);
43+
ERROR_INSN(insn, "unknown unwind hint type %d", cfi->type);
4444
return -1;
4545
}
4646

@@ -72,7 +72,7 @@ int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, struct instruct
7272
orc->sp_reg = ORC_REG_DX;
7373
break;
7474
default:
75-
WARN_INSN(insn, "unknown CFA base reg %d", cfi->cfa.base);
75+
ERROR_INSN(insn, "unknown CFA base reg %d", cfi->cfa.base);
7676
return -1;
7777
}
7878

@@ -87,7 +87,7 @@ int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, struct instruct
8787
orc->bp_reg = ORC_REG_BP;
8888
break;
8989
default:
90-
WARN_INSN(insn, "unknown BP base reg %d", bp->base);
90+
ERROR_INSN(insn, "unknown BP base reg %d", bp->base);
9191
return -1;
9292
}
9393

tools/objtool/builtin-check.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,22 @@ int cmd_parse_options(int argc, const char **argv, const char * const usage[])
139139
static bool opts_valid(void)
140140
{
141141
if (opts.mnop && !opts.mcount) {
142-
WARN("--mnop requires --mcount");
142+
ERROR("--mnop requires --mcount");
143143
return false;
144144
}
145145

146146
if (opts.noinstr && !opts.link) {
147-
WARN("--noinstr requires --link");
147+
ERROR("--noinstr requires --link");
148148
return false;
149149
}
150150

151151
if (opts.ibt && !opts.link) {
152-
WARN("--ibt requires --link");
152+
ERROR("--ibt requires --link");
153153
return false;
154154
}
155155

156156
if (opts.unret && !opts.link) {
157-
WARN("--unret requires --link");
157+
ERROR("--unret requires --link");
158158
return false;
159159
}
160160

@@ -171,7 +171,7 @@ static bool opts_valid(void)
171171
opts.static_call ||
172172
opts.uaccess) {
173173
if (opts.dump_orc) {
174-
WARN("--dump can't be combined with other actions");
174+
ERROR("--dump can't be combined with other actions");
175175
return false;
176176
}
177177

@@ -181,7 +181,7 @@ static bool opts_valid(void)
181181
if (opts.dump_orc)
182182
return true;
183183

184-
WARN("At least one action required");
184+
ERROR("At least one action required");
185185
return false;
186186
}
187187

@@ -194,30 +194,30 @@ static int copy_file(const char *src, const char *dst)
194194

195195
src_fd = open(src, O_RDONLY);
196196
if (src_fd == -1) {
197-
WARN("can't open %s for reading: %s", src, strerror(errno));
197+
ERROR("can't open %s for reading: %s", src, strerror(errno));
198198
return 1;
199199
}
200200

201201
dst_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, 0400);
202202
if (dst_fd == -1) {
203-
WARN("can't open %s for writing: %s", dst, strerror(errno));
203+
ERROR("can't open %s for writing: %s", dst, strerror(errno));
204204
return 1;
205205
}
206206

207207
if (fstat(src_fd, &stat) == -1) {
208-
WARN_GLIBC("fstat");
208+
ERROR_GLIBC("fstat");
209209
return 1;
210210
}
211211

212212
if (fchmod(dst_fd, stat.st_mode) == -1) {
213-
WARN_GLIBC("fchmod");
213+
ERROR_GLIBC("fchmod");
214214
return 1;
215215
}
216216

217217
for (to_copy = stat.st_size; to_copy > 0; to_copy -= copied) {
218218
copied = sendfile(dst_fd, src_fd, &offset, to_copy);
219219
if (copied == -1) {
220-
WARN_GLIBC("sendfile");
220+
ERROR_GLIBC("sendfile");
221221
return 1;
222222
}
223223
}
@@ -231,14 +231,14 @@ static void save_argv(int argc, const char **argv)
231231
{
232232
orig_argv = calloc(argc, sizeof(char *));
233233
if (!orig_argv) {
234-
WARN_GLIBC("calloc");
234+
ERROR_GLIBC("calloc");
235235
exit(1);
236236
}
237237

238238
for (int i = 0; i < argc; i++) {
239239
orig_argv[i] = strdup(argv[i]);
240240
if (!orig_argv[i]) {
241-
WARN_GLIBC("strdup(%s)", argv[i]);
241+
ERROR_GLIBC("strdup(%s)", argv[i]);
242242
exit(1);
243243
}
244244
};
@@ -257,7 +257,7 @@ void print_args(void)
257257
*/
258258
backup = malloc(strlen(objname) + strlen(ORIG_SUFFIX) + 1);
259259
if (!backup) {
260-
WARN_GLIBC("malloc");
260+
ERROR_GLIBC("malloc");
261261
goto print;
262262
}
263263

@@ -319,7 +319,7 @@ int objtool_run(int argc, const char **argv)
319319
return 1;
320320

321321
if (!opts.link && has_multiple_files(file->elf)) {
322-
WARN("Linked object requires --link");
322+
ERROR("Linked object requires --link");
323323
return 1;
324324
}
325325

0 commit comments

Comments
 (0)