tools/objtool/arch/powerpc/decode.c
Source file repositories/reference/linux-study-clean/tools/objtool/arch/powerpc/decode.c
File Facts
- System
- Linux kernel
- Corpus path
tools/objtool/arch/powerpc/decode.c- Extension
.c- Size
- 2934 bytes
- Lines
- 154
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hobjtool/check.hobjtool/disas.hobjtool/elf.hobjtool/arch.hobjtool/warn.hobjtool/builtin.h
Detected Declarations
function arch_ftrace_matchfunction arch_insn_adjusted_addendfunction arch_callee_saved_regfunction arch_decode_hint_regfunction arch_decode_instructionfunction arch_jump_destinationfunction arch_pc_relative_relocfunction arch_initial_func_cfi_statefunction arch_reloc_sizefunction arch_disas_info_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdio.h>
#include <stdlib.h>
#include <objtool/check.h>
#include <objtool/disas.h>
#include <objtool/elf.h>
#include <objtool/arch.h>
#include <objtool/warn.h>
#include <objtool/builtin.h>
const char *arch_reg_name[CFI_NUM_REGS] = {
"r0", "sp", "r2", "r3",
"r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11",
"r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19",
"r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27",
"r28", "r29", "r30", "r31",
"ra"
};
int arch_ftrace_match(const char *name)
{
return !strcmp(name, "_mcount");
}
s64 arch_insn_adjusted_addend(struct instruction *insn, struct reloc *reloc)
{
return reloc_addend(reloc);
}
bool arch_callee_saved_reg(unsigned char reg)
{
return false;
}
int arch_decode_hint_reg(u8 sp_reg, int *base)
{
exit(-1);
}
const char *arch_nop_insn(int len)
{
exit(-1);
}
const char *arch_ret_insn(int len)
{
exit(-1);
}
int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
unsigned long offset, unsigned int maxlen,
struct instruction *insn)
{
unsigned int opcode;
enum insn_type typ;
unsigned long imm;
u32 ins;
ins = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
opcode = ins >> 26;
typ = INSN_OTHER;
imm = 0;
switch (opcode) {
case 18: /* b[l][a] */
if (ins == 0x48000005) /* bl .+4 */
typ = INSN_OTHER;
else if (ins & 1) /* bl[a] */
typ = INSN_CALL;
else /* b[a] */
typ = INSN_JUMP_UNCONDITIONAL;
imm = ins & 0x3fffffc;
if (imm & 0x2000000)
imm -= 0x4000000;
imm |= ins & 2; /* AA flag */
break;
}
if (opcode == 1)
insn->len = 8;
else
insn->len = 4;
insn->type = typ;
insn->immediate = imm;
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `objtool/check.h`, `objtool/disas.h`, `objtool/elf.h`, `objtool/arch.h`, `objtool/warn.h`, `objtool/builtin.h`.
- Detected declarations: `function arch_ftrace_match`, `function arch_insn_adjusted_addend`, `function arch_callee_saved_reg`, `function arch_decode_hint_reg`, `function arch_decode_instruction`, `function arch_jump_destination`, `function arch_pc_relative_reloc`, `function arch_initial_func_cfi_state`, `function arch_reloc_size`, `function arch_disas_info_init`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.