[PATCH] LoongArch: Discard extra spaces in objdump output

WANG Xuerui i.swmail@xen0n.name
Fri Jan 5 07:05:32 GMT 2024


Hi,

On 1/5/24 10:00, Lulu Cai wrote:
> Due to the formatted output of objdump, some instructions
> that do not require output operands (such as nop/ret) will
> have extra spaces added after them.
>
> Determine whether to output operands through the format
> of opcodes. When opc->format is an empty string, no extra
> spaces are output.
> ---
>   gas/testsuite/gas/loongarch/64_pcrel.d             |  2 +-
>   .../gas/loongarch/deprecated_reg_aliases.d         |  2 +-
>   gas/testsuite/gas/loongarch/jmp_op.d               |  4 ++--
>   gas/testsuite/gas/loongarch/nop.d                  |  2 +-
>   gas/testsuite/gas/loongarch/privilege_op.d         | 14 +++++++-------
>   gas/testsuite/gas/loongarch/reloc.d                |  2 +-
>   opcodes/loongarch-dis.c                            |  5 ++++-
>   7 files changed, 17 insertions(+), 14 deletions(-)
>
> <snip>
>
> diff --git a/opcodes/loongarch-dis.c b/opcodes/loongarch-dis.c
> index 969ea28f96f..c1b284bcd8a 100644
> --- a/opcodes/loongarch-dis.c
> +++ b/opcodes/loongarch-dis.c
> @@ -267,7 +267,10 @@ disassemble_one (insn_t insn, struct disassemble_info *info)
>       }
>   
>     info->insn_type = dis_nonbranch;
> -  info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%-12s", opc->name);
> +  if (strcmp (opc->format, "") == 0)
Why not simply check if (opc->format == NULL || opc->format[0] == '\0')?
> +    info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", opc->name);
> +  else
> +    info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%-12s", opc->name);
>   
>     {
>       char *fake_args = xmalloc (strlen (opc->format) + 1);
Otherwise, thanks for the patch!


More information about the Binutils mailing list