# Re: \[PATCH v4 2/4\] objtool/powerpc: Add support for decoding all types of uncond branches

- From: Segher Boessenkool \<hidden\>
- Date: 2024-12-04 14:16:48 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2024/12/2846416
- Thread: https://ratatoskr.run/linuxppc-dev/2024/12/2845167/t.md

```text
On Tue, Dec 03, 2024 at 08:44:50PM +0100, Christophe Leroy wrote:
> 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.

The AA field already is there, so why not, eh :-)

> Also add support for 'b' and 'ba' instructions. Objtool call them jumps.

> Signed-off-by: Christophe Leroy <redacted>

Reviewed-by: Segher Boessenkool <redacted>

> --- a/tools/objtool/arch/powerpc/decode.c
> +++ b/tools/objtool/arch/powerpc/decode.c
> @@ -55,12 +55,15 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
>  
>  	switch (opcode) {
>  	case 18: /* b[l][a] */
> -		if ((ins & 3) == 1) /* bl */
> +		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 */

You could of course put that together with the 3fffffc thing, but you
can leave that to the compiler as well :-)


Segher

```
