tools/objtool/arch/loongarch/decode.c
Source file repositories/reference/linux-study-clean/tools/objtool/arch/loongarch/decode.c
File Facts
- System
- Linux kernel
- Corpus path
tools/objtool/arch/loongarch/decode.c- Extension
.c- Size
- 10404 bytes
- Lines
- 440
- 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
string.hobjtool/check.hobjtool/disas.hobjtool/warn.hasm/inst.hasm/orc_types.hlinux/objtool_types.harch/elf.h
Detected Declarations
function arch_ftrace_matchfunction arch_jump_destinationfunction arch_insn_adjusted_addendfunction arch_pc_relative_relocfunction arch_callee_saved_regfunction arch_decode_hint_regfunction is_loongarchfunction decode_insn_reg0i26_fomatfunction decode_insn_reg1i21_fomatfunction decode_insn_reg2i12_fomatfunction ADD_OPfunction ADD_OPfunction ADD_OPfunction decode_insn_reg2i14_fomatfunction ADD_OPfunction ADD_OPfunction decode_insn_reg2i16_fomatfunction decode_insn_reg3_fomatfunction arch_decode_instructionfunction arch_initial_func_cfi_statefunction arch_reloc_sizefunction arch_jump_table_sym_offsetfunction arch_disas_info_init
Annotated Snippet
if ((inst.reg2i12_format.rd == CFI_SP) || (inst.reg2i12_format.rj == CFI_SP)) {
/* addi.d sp,sp,si12 or addi.d fp,sp,si12 or addi.d sp,fp,si12 */
insn->immediate = sign_extend64(inst.reg2i12_format.immediate, 11);
ADD_OP(op) {
op->src.type = OP_SRC_ADD;
op->src.reg = inst.reg2i12_format.rj;
op->src.offset = insn->immediate;
op->dest.type = OP_DEST_REG;
op->dest.reg = inst.reg2i12_format.rd;
}
}
if ((inst.reg2i12_format.rd == CFI_SP) && (inst.reg2i12_format.rj == CFI_FP)) {
/* addi.d sp,fp,si12 */
struct symbol *func = find_func_containing(insn->sec, insn->offset);
if (!func)
return false;
func->frame_pointer = true;
}
break;
case ldd_op:
if (inst.reg2i12_format.rj == CFI_SP) {
/* ld.d rd,sp,si12 */
insn->immediate = sign_extend64(inst.reg2i12_format.immediate, 11);
ADD_OP(op) {
op->src.type = OP_SRC_REG_INDIRECT;
op->src.reg = CFI_SP;
op->src.offset = insn->immediate;
op->dest.type = OP_DEST_REG;
op->dest.reg = inst.reg2i12_format.rd;
}
}
break;
case std_op:
if (inst.reg2i12_format.rj == CFI_SP) {
/* st.d rd,sp,si12 */
insn->immediate = sign_extend64(inst.reg2i12_format.immediate, 11);
ADD_OP(op) {
op->src.type = OP_SRC_REG;
op->src.reg = inst.reg2i12_format.rd;
op->dest.type = OP_DEST_REG_INDIRECT;
op->dest.reg = CFI_SP;
op->dest.offset = insn->immediate;
}
}
break;
case andi_op:
if (inst.reg2i12_format.rd == 0 &&
inst.reg2i12_format.rj == 0 &&
inst.reg2i12_format.immediate == 0)
/* andi r0,r0,0 */
insn->type = INSN_NOP;
break;
default:
return false;
}
return true;
}
static bool decode_insn_reg2i14_fomat(union loongarch_instruction inst,
struct instruction *insn,
struct stack_op **ops_list,
struct stack_op *op)
{
switch (inst.reg2i14_format.opcode) {
case ldptrd_op:
if (inst.reg2i14_format.rj == CFI_SP) {
/* ldptr.d rd,sp,si14 */
insn->immediate = sign_extend64(inst.reg2i14_format.immediate, 13);
ADD_OP(op) {
op->src.type = OP_SRC_REG_INDIRECT;
op->src.reg = CFI_SP;
op->src.offset = insn->immediate;
op->dest.type = OP_DEST_REG;
op->dest.reg = inst.reg2i14_format.rd;
}
}
break;
case stptrd_op:
if (inst.reg2i14_format.rj == CFI_SP) {
/* stptr.d ra,sp,0 */
if (inst.reg2i14_format.rd == LOONGARCH_GPR_RA &&
inst.reg2i14_format.immediate == 0)
break;
/* stptr.d rd,sp,si14 */
insn->immediate = sign_extend64(inst.reg2i14_format.immediate, 13);
ADD_OP(op) {
Annotation
- Immediate include surface: `string.h`, `objtool/check.h`, `objtool/disas.h`, `objtool/warn.h`, `asm/inst.h`, `asm/orc_types.h`, `linux/objtool_types.h`, `arch/elf.h`.
- Detected declarations: `function arch_ftrace_match`, `function arch_jump_destination`, `function arch_insn_adjusted_addend`, `function arch_pc_relative_reloc`, `function arch_callee_saved_reg`, `function arch_decode_hint_reg`, `function is_loongarch`, `function decode_insn_reg0i26_fomat`, `function decode_insn_reg1i21_fomat`, `function decode_insn_reg2i12_fomat`.
- 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.