MCPcopy Index your code
hub / github.com/encounter/objdiff / push_operand

Function push_operand

objdiff-core/src/arch/arm64.rs:2109–2283  ·  view source on GitHub ↗
(args: &mut Cb, o: &Operand, ctx: &mut DisplayCtx)

Source from the content-addressed store, hash-verified

2107}
2108
2109fn push_operand<Cb>(args: &mut Cb, o: &Operand, ctx: &mut DisplayCtx)
2110where Cb: FnMut(InstructionPart<'static>) {
2111 match o {
2112 Operand::Nothing => unreachable!(),
2113 Operand::PCOffset(off) => {
2114 if let Some(resolved) = is_pc_offset_reloc(ctx.reloc) {
2115 let target_address =
2116 resolved.symbol.address.checked_add_signed(resolved.relocation.addend);
2117 if resolved.symbol.section == Some(ctx.section_index)
2118 && matches!(target_address, Some(addr) if addr > ctx.start_address && addr < ctx.end_address)
2119 {
2120 let dest = target_address.unwrap();
2121 push_plain(args, "$");
2122 args(InstructionPart::branch_dest(dest));
2123 } else {
2124 args(InstructionPart::reloc());
2125 }
2126 } else {
2127 let dest = ctx.address.saturating_add_signed(*off);
2128 push_plain(args, "$");
2129 args(InstructionPart::branch_dest(dest));
2130 }
2131 }
2132 Operand::Immediate(imm) => {
2133 if is_imm_reloc(ctx.reloc) {
2134 args(InstructionPart::reloc());
2135 } else {
2136 push_unsigned(args, *imm as u64);
2137 }
2138 }
2139 Operand::Imm64(imm) => {
2140 push_unsigned(args, *imm);
2141 }
2142 Operand::Imm16(imm) => {
2143 push_unsigned(args, *imm as u64);
2144 }
2145 Operand::Register(size, reg) => {
2146 push_register(args, *size, *reg, false);
2147 }
2148 Operand::RegisterPair(size, reg) => {
2149 push_register(args, *size, *reg, false);
2150 push_separator(args);
2151 push_register(args, *size, *reg + 1, false);
2152 }
2153 Operand::RegisterOrSP(size, reg) => {
2154 push_register(args, *size, *reg, true);
2155 }
2156 Operand::ConditionCode(cond) => match cond {
2157 0b0000 => push_opaque(args, "eq"),
2158 0b0010 => push_opaque(args, "hs"),
2159 0b0100 => push_opaque(args, "mi"),
2160 0b0110 => push_opaque(args, "vs"),
2161 0b1000 => push_opaque(args, "hi"),
2162 0b1010 => push_opaque(args, "ge"),
2163 0b1100 => push_opaque(args, "gt"),
2164 0b1110 => push_opaque(args, "al"),
2165 0b0001 => push_opaque(args, "ne"),
2166 0b0011 => push_opaque(args, "lo"),

Callers 1

display_instructionFunction · 0.85

Calls 11

is_pc_offset_relocFunction · 0.85
push_plainFunction · 0.85
branch_destFunction · 0.85
is_imm_relocFunction · 0.85
push_unsignedFunction · 0.85
push_registerFunction · 0.85
push_separatorFunction · 0.85
push_opaqueFunction · 0.85
push_shiftFunction · 0.85
is_reg_index_relocFunction · 0.85
push_signedFunction · 0.85

Tested by

no test coverage detected