[PATCH] or1k: Add support for a little-endian target variant
Stafford Horne
shorne@gmail.com
Thu Jun 9 11:21:19 GMT 2022
On Thu, Jun 09, 2022 at 01:01:33AM -0500, Samuel Holland wrote:
> While not officially sanctioned by the architecture spec, little-endian
> or1k processors do exist in the wild, for example the Allwinner AR100.
> Let's add native support for this, instead of hacks like using objcopy
> to byteswap ELF file contents.
Hello,
In general I have no objections to this. If there are processors that
hare little endian it makes sense to support it. Do you have any details
of how people built for these before? I am curious.
> diff --git a/gas/config/tc-or1k.c b/gas/config/tc-or1k.c
> index ae4e3452f48..9dc5a46f2e2 100644
> --- a/gas/config/tc-or1k.c
> +++ b/gas/config/tc-or1k.c
> @@ -58,8 +58,16 @@ const char FLT_CHARS[] = "dD";
> #define OR1K_SHORTOPTS "m:"
> const char * md_shortopts = OR1K_SHORTOPTS;
>
> +enum
> +{
> + OPTION_LITTLE_ENDIAN = OPTION_MD_BASE,
> + OPTION_BIG_ENDIAN
> +};
> +
> struct option md_longopts[] =
> {
> + {"EB", no_argument, NULL, OPTION_BIG_ENDIAN},
> + {"EL", no_argument, NULL, OPTION_LITTLE_ENDIAN},
> {NULL, no_argument, NULL, 0}
> };
> size_t md_longopts_size = sizeof (md_longopts);
> @@ -67,14 +75,30 @@ size_t md_longopts_size = sizeof (md_longopts);
> unsigned long or1k_machine = 0; /* default */
>
> int
> -md_parse_option (int c ATTRIBUTE_UNUSED, const char * arg ATTRIBUTE_UNUSED)
> +md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
> {
> - return 0;
> + switch (c)
> + {
> + case OPTION_BIG_ENDIAN:
> + target_big_endian = 1;
> + break;
> + case OPTION_LITTLE_ENDIAN:
> + target_big_endian = 0;
> + break;
> + default:
> + return 0;
> + }
> +
> + return 1;
> }
>
> void
> -md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
> +md_show_usage (FILE * stream)
> {
> + fprintf (stream, _(" OR1K-specific assembler options:\n"));
> + fprintf (stream, _("\
> + --EB generate code for a big endian machine\n\
> + --EL generate code for a little endian machine\n"));
> }
Aboce you mention -EB, -EL, here is is --EB, --EL.
Does this setup big endian as the default? We should specify that in the
options. i.e. "generate code for a big endian machine, this is the default."
But I am not sure how that defaulting works now. I will try to build this
and understand better.
-Stafford
More information about the Binutils
mailing list