Skip to content

Commit 0c98be8

Browse files
author
Ingo Molnar
committed
objtool: Constify arch_decode_instruction()
Mostly straightforward constification, except that WARN_FUNC() needs a writable pointer while we have read-only pointers, so deflect this to WARN(). Acked-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sami Tolvanen <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent bc359ff commit 0c98be8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tools/objtool/arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct instruction;
7272

7373
void arch_initial_func_cfi_state(struct cfi_init_state *state);
7474

75-
int arch_decode_instruction(struct elf *elf, struct section *sec,
75+
int arch_decode_instruction(const struct elf *elf, const struct section *sec,
7676
unsigned long offset, unsigned int maxlen,
7777
unsigned int *len, enum insn_type *type,
7878
unsigned long *immediate,

tools/objtool/arch/x86/decode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static unsigned char op_to_cfi_reg[][2] = {
2727
{CFI_DI, CFI_R15},
2828
};
2929

30-
static int is_x86_64(struct elf *elf)
30+
static int is_x86_64(const struct elf *elf)
3131
{
3232
switch (elf->ehdr.e_machine) {
3333
case EM_X86_64:
@@ -77,7 +77,7 @@ unsigned long arch_jump_destination(struct instruction *insn)
7777
return insn->offset + insn->len + insn->immediate;
7878
}
7979

80-
int arch_decode_instruction(struct elf *elf, struct section *sec,
80+
int arch_decode_instruction(const struct elf *elf, const struct section *sec,
8181
unsigned long offset, unsigned int maxlen,
8282
unsigned int *len, enum insn_type *type,
8383
unsigned long *immediate,
@@ -98,7 +98,7 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
9898
insn_get_length(&insn);
9999

100100
if (!insn_complete(&insn)) {
101-
WARN_FUNC("can't decode instruction", sec, offset);
101+
WARN("can't decode instruction at %s:0x%lx", sec->name, offset);
102102
return -1;
103103
}
104104

0 commit comments

Comments
 (0)