1 // SPDX-License-Identifier: GPL-2.0-or-later
5 #include <objtool/check.h>
6 #include <objtool/elf.h>
7 #include <objtool/arch.h>
8 #include <objtool/warn.h>
9 #include <objtool/builtin.h>
10 #include <objtool/endianness.h>
12 int arch_ftrace_match(char *name)
14 return !strcmp(name, "_mcount");
17 unsigned long arch_dest_reloc_offset(int addend)
22 bool arch_callee_saved_reg(unsigned char reg)
27 int arch_decode_hint_reg(u8 sp_reg, int *base)
32 const char *arch_nop_insn(int len)
37 const char *arch_ret_insn(int len)
42 int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
43 unsigned long offset, unsigned int maxlen,
44 struct instruction *insn)
51 ins = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
57 case 18: /* b[l][a] */
58 if ((ins & 3) == 1) /* bl */
61 imm = ins & 0x3fffffc;
73 insn->immediate = imm;
78 unsigned long arch_jump_destination(struct instruction *insn)
80 return insn->offset + insn->immediate;
83 bool arch_pc_relative_reloc(struct reloc *reloc)
86 * The powerpc build only allows certain relocation types, see
87 * relocs_check.sh, and none of those accepted are PC relative.
92 void arch_initial_func_cfi_state(struct cfi_init_state *state)
96 for (i = 0; i < CFI_NUM_REGS; i++) {
97 state->regs[i].base = CFI_UNDEFINED;
98 state->regs[i].offset = 0;
101 /* initial CFA (call frame address) */
102 state->cfa.base = CFI_SP;
103 state->cfa.offset = 0;
105 /* initial LR (return address) */
106 state->regs[CFI_RA].base = CFI_CFA;
107 state->regs[CFI_RA].offset = 0;