[PATCH,RFC 8/9] gas: synthesize CFI for hand-written asm
Nick Clifton
nickc@redhat.com
Thu Sep 28 14:58:57 GMT 2023
Hi Indu,
> A ginsn is a target-independent representation of the machine
> instructions. One machine instruction may need one or more ginsn.
Is there a way to display the ginins as they are created, maybe in the
listing output ?
I think that this might be a useful feature when it comes to debugging the
ginsn generation code in the future...
> - Hand-written asm block must begin with a .type foo, @function
> - Hand-written asm block must end with a .size foo, .-foo
Must it ? Can't you assume that all the assembler instructions
between one ".type <name>,@function" and the next ".type <name>,@function"
must belong to a single function ?
The reason for my hesitation is that I imagine that there is hand written
assembler out there that does not bother to set the size of function
symbols. Probably on the (mistaken) grounds that nothing really needs to
know the size of functions. So relying on a .size directive might not
be that safe.
> +bool
> +x86_scfi_callee_saved_p (uint32_t dw2reg_num)
> +{
> + if (dw2reg_num == 3 /* rbx. */
> + || dw2reg_num == REG_FP /* rbp. */
> + || dw2reg_num == REG_SP /* rsp. */
> + || (dw2reg_num >= 12 && dw2reg_num <= 15) /* r12 - r15. */)
> + return true;
Why do you have defines for REG_FP and REG_SP but not the other registers ?
(Answer: because REG_SP and REG_FP are in part generic and used by ginsns,
whereas the other register numbers are totally specific to the x86
architecture. But, my nerd brain replies, that is no reason why those registers
cannot have defines of their own).
> + if (opcode == 0x8b)
I dislike magic numbers. It would be much better, IMHO, if the code read as:
if (opcode == MOV_INSN)
This is not a criticism of your code, since these hard coded instruction values
are used throughout the i386 backend of the assembler. But one fine day I would
love to see a patch replacing magic constants with descriptive names.
Cheers
Nick
More information about the Binutils
mailing list