Skip to contentSkip to conversation

Disassembler location

DISCUSSION Michael Morrell 4 participants 5 messages Jul 10, 2024 – Jul 11, 2024 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

I'm working on a port to a new architecture and was noticing a discrepancy in where the disassembler code lives. There is a file "target/<arch>/disas.c" for 4 architectures (avr, loongarch, openrisc, and rx), but a file "disas/<arch>.c" for 14 architectures (if I counted right). It seems the 4 architectures using "target/<arch>/disas.c" are more recently added so I was wondering if that is now the preferred location. I couldn't find information on this, but I wasn't sure where to look.

Any advice?

Thanks,

Michael

#2 lore raw
Quoted 8 lines · Michael Morrell

I'm working on a port to a new architecture and was noticing a discrepancy in where the disassembler code lives. There is a file "target/<arch>/disas.c" for 4 architectures (avr, loongarch, openrisc, and rx), but a file "disas/<arch>.c" for 14 architectures (if I counted right). It seems the 4 architectures using "target/<arch>/disas.c" are more recently added so I was wondering if that is now the preferred location. I couldn't find information on this, but I wasn't sure where to look.

loongarch puts it in target/<arch>/ because it reuses some code between disassembler and translator.

The others are not hosts, only targets. By putting the file in target/<arch>/, they do not need to add it to the "disassemblers" variable in meson.build---but they add it anyway. :)

All in all, if you're not in the loongarch situation I'd put it in disas/.

Paolo

#4 lore raw
In reply to Michael Morrell
Quoted 3 lines · Michael Morrell

I'm working on a port to a new architecture and was noticing a discrepancy in where the disassembler code lives. There is a file "target/<arch>/disas.c" for 4 architectures (avr, loongarch, openrisc, and rx), but a file "disas/<arch>.c" for 14 architectures (if I counted right). It seems the 4 architectures using "target/<arch>/disas.c" are more recently added so I was wondering if that is now the preferred location. I couldn't find information on this, but I wasn't sure where to look.

Any advice?

The older disas/arch.c files come from binutils, prior to the GPLv3 license change. These are generally very old architectures, or not up to date.

The newer target/arch/disas.c are for architectures for which the translator and the disassembler share generated code via decodetree. If you're implementing a new architecture from scratch, this is your best choice.

The "best" supported are those with support in system libcapstone. :-)

r~

#3 lore raw
In reply to Paolo Bonzini
Quoted 1 line · Paolo Bonzini

The others are not hosts, only targets.  By putting the file in target/<arch>/, they do not need to add it to the "disassemblers" variable in meson.build---but they add it anyway. :)

We should clean that up. :-)

r~