[PATCH v1 4/8] aarch64: improve debuggability on array of enum

Richard Earnshaw (lists) Richard.Earnshaw@arm.com
Tue Nov 5 17:29:58 GMT 2024


On 23/10/2024 11:48, Matthieu Longo wrote:
> The current space optmization on enum aarch64_opn_qualifier forced its
> encoding using an unsigned char. This "hard-coded" optimization has the
> bad consequence of making the array of such enums being completely
> unreadable when debugging with GDB because the enum type is lost along
> the way.
> Keeping this space optimization, and the enum type as well, is possible
> when the declaration of the enum is tagged with attribute((packed)).
> attribute((packed)) is a GNU extension, and is wrapped in the macro
> ATTRIBUTE_PACKED (defined in ansidecl.h), and should be used instead.
> ---
>  include/opcode/aarch64.h | 6 +++---
>  opcodes/aarch64-opc.c    | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/include/opcode/aarch64.h b/include/opcode/aarch64.h
> index c96bad61ca0..1955ca45c67 100644
> --- a/include/opcode/aarch64.h
> +++ b/include/opcode/aarch64.h
> @@ -985,7 +985,7 @@ enum aarch64_opnd_qualifier
>  
>    /* Special qualifier used for indicating error in qualifier retrieval.  */
>    AARCH64_OPND_QLF_ERR,
> -};
> +} ATTRIBUTE_PACKED;

This is one of those cases where C++ really does do this better: "enum aarch64_opnd_qualifier : uint8_t".

But while we are still using C, this is OK.

R.



More information about the Binutils mailing list