~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/objtool/arch/powerpc/decode.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 int arch_ftrace_match(char *name)
 13 {
 14         return !strcmp(name, "_mcount");
 15 }
 16 
 17 unsigned long arch_dest_reloc_offset(int addend)
 18 {
 19         return addend;
 20 }
 21 
 22 bool arch_callee_saved_reg(unsigned char reg)
 23 {
 24         return false;
 25 }
 26 
 27 int arch_decode_hint_reg(u8 sp_reg, int *base)
 28 {
 29         exit(-1);
 30 }
 31 
 32 const char *arch_nop_insn(int len)
 33 {
 34         exit(-1);
 35 }
 36 
 37 const char *arch_ret_insn(int len)
 38 {
 39         exit(-1);
 40 }
 41 
 42 int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
 43                             unsigned long offset, unsigned int maxlen,
 44                             struct instruction *insn)
 45 {
 46         unsigned int opcode;
 47         enum insn_type typ;
 48         unsigned long imm;
 49         u32 ins;
 50 
 51         ins = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
 52         opcode = ins >> 26;
 53         typ = INSN_OTHER;
 54         imm = 0;
 55 
 56         switch (opcode) {
 57         case 18: /* b[l][a] */
 58                 if ((ins & 3) == 1) /* bl */
 59                         typ = INSN_CALL;
 60 
 61                 imm = ins & 0x3fffffc;
 62                 if (imm & 0x2000000)
 63                         imm -= 0x4000000;
 64                 break;
 65         }
 66 
 67         if (opcode == 1)
 68                 insn->len = 8;
 69         else
 70                 insn->len = 4;
 71 
 72         insn->type = typ;
 73         insn->immediate = imm;
 74 
 75         return 0;
 76 }
 77 
 78 unsigned long arch_jump_destination(struct instruction *insn)
 79 {
 80         return insn->offset + insn->immediate;
 81 }
 82 
 83 bool arch_pc_relative_reloc(struct reloc *reloc)
 84 {
 85         /*
 86          * The powerpc build only allows certain relocation types, see
 87          * relocs_check.sh, and none of those accepted are PC relative.
 88          */
 89         return false;
 90 }
 91 
 92 void arch_initial_func_cfi_state(struct cfi_init_state *state)
 93 {
 94         int i;
 95 
 96         for (i = 0; i < CFI_NUM_REGS; i++) {
 97                 state->regs[i].base = CFI_UNDEFINED;
 98                 state->regs[i].offset = 0;
 99         }
100 
101         /* initial CFA (call frame address) */
102         state->cfa.base = CFI_SP;
103         state->cfa.offset = 0;
104 
105         /* initial LR (return address) */
106         state->regs[CFI_RA].base = CFI_CFA;
107         state->regs[CFI_RA].offset = 0;
108 }
109 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php