[PATCH 0/3] disassembler syntax highlighting in objdump (via libopcodes)

Nelson Chu nelson.chu@sifive.com
Thu Feb 17 03:57:34 GMT 2022


Hi Andrew,

I get gas/testsuite/gas/riscv/insn testcase fail after applying the
series of patches.  Here is the reduced case,

$ cat tmp.s
.word 0x68c58543
fmadd.s fa0,fa1,fa2,fa3,rne
.insn r  MADD, 0, 0, a0, a1, a2, a3
.insn 0x68c58543

All these are the same instruction encoding - fmadd.s, but the first
".word" will be marked and dumped as data rather than instruction.  We
are used to get the following dump result,

$ /scratch/nelsonc/build-upstream/rv64gc-elf/build-install/bin/riscv64-unknown-elf-objdump
-d tmp.o

0000000000000000 <.text>:
   0:   68c58543                .word   0x68c58543
   4:   68c58543                fmadd.s fa0,fa1,fa2,fa3,rne
   8:   68c58543                fmadd.s fa0,fa1,fa2,fa3,rne
   c:   68c58543                fmadd.s fa0,fa1,fa2,fa3,rne

But now with the patches, I will get segmentation fault when trying to
dump fmadd.s as instruction,

$ /scratch/nelsonc/build-upstream/rv64gc-elf/build-install/bin/riscv64-unknown-elf-objdump
-d tmp.o

0000000000000000 <.text>:
   0:   68c58543                .word   0x68c58543
Segmentation fault (core dumped)

Is it possible if you could help to see what happened?  Thanks!


Nelson

On Thu, Feb 17, 2022 at 4:53 AM Andrew Burgess via Binutils
<binutils@sourceware.org> wrote:
>
> This series is a serious attempt at what I discussed here:
>
>   https://sourceware.org/pipermail/binutils/2021-December/118806.html
>
> This series changes libopcodes so that this disassemblers can supply
> styling information with every piece of disassembly output, e.g. is
> this a register?  an address?  a mnemonic?  etc.
>
> Users of the disassembler can then choose to make use of this
> information to add styling to the disassembler output.
>
> And that is what I do for objdump in this series.  The styling is off
> by default, but can be turned on with a new command line flag:
>     --disassembler-color=off|color|extended-color
>
> I've updated GDB enough to keep it building and running after this
> change, though at this point GDB doesn't make use of the new styling
> information, that will come later.
>
> All feedback would be welcome.
>
> Thanks,
> Andrew
>
> ---
>
> Andrew Burgess (3):
>   objdump/opcodes: add syntax highlighting to disassembler output
>   opcodes/riscv: implement style support in the disassembler
>   opcodes/i386: partially implement disassembler style support
>
>  binutils/NEWS              |   4 +
>  binutils/doc/binutils.texi |  11 ++
>  binutils/objdump.c         | 245 ++++++++++++++++++++++++++++++++-----
>  gdb/disasm.c               |  34 ++++-
>  gdb/disasm.h               |   7 ++
>  include/dis-asm.h          |  62 +++++++++-
>  opcodes/dis-init.c         |   5 +-
>  opcodes/disassemble.c      |  23 +++-
>  opcodes/i386-dis.c         |  71 +++++++----
>  opcodes/riscv-dis.c        | 147 +++++++++++-----------
>  10 files changed, 475 insertions(+), 134 deletions(-)
>
> --
> 2.25.4
>


More information about the Binutils mailing list