|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | + |
| 3 | +#include <stdio.h> |
| 4 | +#include <stdlib.h> |
| 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> |
| 11 | + |
| 12 | +unsigned long arch_dest_reloc_offset(int addend) |
| 13 | +{ |
| 14 | + return addend; |
| 15 | +} |
| 16 | + |
| 17 | +bool arch_callee_saved_reg(unsigned char reg) |
| 18 | +{ |
| 19 | + return false; |
| 20 | +} |
| 21 | + |
| 22 | +int arch_decode_hint_reg(u8 sp_reg, int *base) |
| 23 | +{ |
| 24 | + exit(-1); |
| 25 | +} |
| 26 | + |
| 27 | +const char *arch_nop_insn(int len) |
| 28 | +{ |
| 29 | + exit(-1); |
| 30 | +} |
| 31 | + |
| 32 | +const char *arch_ret_insn(int len) |
| 33 | +{ |
| 34 | + exit(-1); |
| 35 | +} |
| 36 | + |
| 37 | +int arch_decode_instruction(struct objtool_file *file, const struct section *sec, |
| 38 | + unsigned long offset, unsigned int maxlen, |
| 39 | + unsigned int *len, enum insn_type *type, |
| 40 | + unsigned long *immediate, |
| 41 | + struct list_head *ops_list) |
| 42 | +{ |
| 43 | + unsigned int opcode; |
| 44 | + enum insn_type typ; |
| 45 | + unsigned long imm; |
| 46 | + u32 insn; |
| 47 | + |
| 48 | + insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset)); |
| 49 | + opcode = insn >> 26; |
| 50 | + typ = INSN_OTHER; |
| 51 | + imm = 0; |
| 52 | + |
| 53 | + if (opcode == 1) |
| 54 | + *len = 8; |
| 55 | + else |
| 56 | + *len = 4; |
| 57 | + |
| 58 | + *type = typ; |
| 59 | + *immediate = imm; |
| 60 | + |
| 61 | + return 0; |
| 62 | +} |
| 63 | + |
| 64 | +unsigned long arch_jump_destination(struct instruction *insn) |
| 65 | +{ |
| 66 | + return insn->offset + insn->immediate; |
| 67 | +} |
| 68 | + |
| 69 | +void arch_initial_func_cfi_state(struct cfi_init_state *state) |
| 70 | +{ |
| 71 | + int i; |
| 72 | + |
| 73 | + for (i = 0; i < CFI_NUM_REGS; i++) { |
| 74 | + state->regs[i].base = CFI_UNDEFINED; |
| 75 | + state->regs[i].offset = 0; |
| 76 | + } |
| 77 | + |
| 78 | + /* initial CFA (call frame address) */ |
| 79 | + state->cfa.base = CFI_SP; |
| 80 | + state->cfa.offset = 0; |
| 81 | + |
| 82 | + /* initial LR (return address) */ |
| 83 | + state->regs[CFI_RA].base = CFI_CFA; |
| 84 | + state->regs[CFI_RA].offset = 0; |
| 85 | +} |
0 commit comments