(
&self,
resolved: ResolvedInstructionRef,
_diff_config: &DiffObjConfig,
cb: &mut dyn FnMut(InstructionPart) -> Result<()>,
)
| 133 | } |
| 134 | |
| 135 | fn display_instruction( |
| 136 | &self, |
| 137 | resolved: ResolvedInstructionRef, |
| 138 | _diff_config: &DiffObjConfig, |
| 139 | cb: &mut dyn FnMut(InstructionPart) -> Result<()>, |
| 140 | ) -> Result<()> { |
| 141 | let ins = self.parse_ins_ref(resolved)?.simplified(); |
| 142 | |
| 143 | cb(InstructionPart::opcode(ins.mnemonic, resolved.ins_ref.opcode))?; |
| 144 | |
| 145 | let reloc_arg = self.find_reloc_arg(&ins, resolved.relocation); |
| 146 | |
| 147 | let mut writing_offset = false; |
| 148 | for (idx, arg) in ins.args_iter().enumerate() { |
| 149 | if idx > 0 && !writing_offset { |
| 150 | cb(InstructionPart::separator())?; |
| 151 | } |
| 152 | |
| 153 | if reloc_arg == Some(idx) { |
| 154 | let reloc = resolved.relocation.unwrap(); |
| 155 | display_reloc(reloc, cb)?; |
| 156 | // For @sda21, we can omit the register argument |
| 157 | if matches!(reloc.relocation.flags, RelocationFlags::Elf(elf::R_PPC_EMB_SDA21)) |
| 158 | // Sanity check: the next argument should be r0 |
| 159 | && matches!(ins.args.get(idx + 1), Some(powerpc::Argument::GPR(powerpc::GPR(0)))) |
| 160 | { |
| 161 | break; |
| 162 | } |
| 163 | } else { |
| 164 | match arg { |
| 165 | powerpc::Argument::Simm(simm) => cb(InstructionPart::signed(simm.0)), |
| 166 | powerpc::Argument::Uimm(uimm) => cb(InstructionPart::unsigned(uimm.0)), |
| 167 | powerpc::Argument::Offset(offset) => cb(InstructionPart::signed(offset.0)), |
| 168 | powerpc::Argument::BranchDest(dest) => cb(InstructionPart::branch_dest( |
| 169 | (resolved.ins_ref.address as u32).wrapping_add_signed(dest.0), |
| 170 | )), |
| 171 | _ => cb(InstructionPart::opaque(arg.to_string())), |
| 172 | }?; |
| 173 | } |
| 174 | |
| 175 | if writing_offset { |
| 176 | cb(InstructionPart::basic(")"))?; |
| 177 | writing_offset = false; |
| 178 | } |
| 179 | if is_offset_arg(arg) { |
| 180 | cb(InstructionPart::basic("("))?; |
| 181 | writing_offset = true; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | Ok(()) |
| 186 | } |
| 187 | |
| 188 | // Could be replaced by data_flow_analysis once that feature stabilizes |
| 189 | fn generate_pooled_relocations( |
nothing calls this directly
no test coverage detected