Skip to content

Commit bb7f054

Browse files
chleroymaddy-kerneldev
authored andcommitted
objtool/powerpc: Add support for decoding all types of uncond branches
Add support for 'bla' instruction. This is done by 'flagging' the address as an absolute address so that arch_jump_destination() can calculate it as expected. Because code is _always_ 4 bytes aligned, use bit 30 as flag. Also add support for 'b' and 'ba' instructions. Objtool call them jumps. And make sure the special 'bl .+4' used by clang in relocatable code is not seen as an 'unannotated intra-function call'. clang should use the special 'bcl 20,31,.+4' form like gcc but for the time being it does not so lets work around that. Link: llvm/llvm-project#128644 Reviewed-by: Segher Boessenkool <segher@kewrnel.crashing.org> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/bf0b4d554547bc34fa3d1af5b4e62a84c0bc182b.1740470510.git.christophe.leroy@csgroup.eu
1 parent d856bc3 commit bb7f054

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/objtool/arch/powerpc/decode.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
5555

5656
switch (opcode) {
5757
case 18: /* b[l][a] */
58-
if ((ins & 3) == 1) /* bl */
58+
if (ins == 0x48000005) /* bl .+4 */
59+
typ = INSN_OTHER;
60+
else if (ins & 1) /* bl[a] */
5961
typ = INSN_CALL;
62+
else /* b[a] */
63+
typ = INSN_JUMP_UNCONDITIONAL;
6064

6165
imm = ins & 0x3fffffc;
6266
if (imm & 0x2000000)
6367
imm -= 0x4000000;
68+
imm |= ins & 2; /* AA flag */
6469
break;
6570
}
6671

@@ -77,6 +82,9 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
7782

7883
unsigned long arch_jump_destination(struct instruction *insn)
7984
{
85+
if (insn->immediate & 2)
86+
return insn->immediate & ~2;
87+
8088
return insn->offset + insn->immediate;
8189
}
8290

0 commit comments

Comments
 (0)