public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* how to know host endianness in binutils
@ 2023-12-21 14:30 Jan Beulich
  2023-12-21 15:11 ` H.J. Lu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jan Beulich @ 2023-12-21 14:30 UTC (permalink / raw)
  To: Binutils; +Cc: Nick Clifton, Alan Modra

Hello,

looking around, I can't seem to be able to find any standardized way of
knowing host endianness in binutils (in gas/ in particular). As was
pointed out to me, the new cpu_flags_from_attr() in config/tc-i386.c
won't work as is on big-endian hosts, yet I would really, really like
to avoid needing to enumerate all of the dozens of bitfields in that
function (converting one kind of bitfield to another). That's not the
least because this set constantly grows.

I can see config/tc-bpf.c checking WORDS_BIGENDIAN, but I couldn't
convince myself (from looking at the generated config.h) that one can
really rely on that.

Jan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to know host endianness in binutils
  2023-12-21 14:30 how to know host endianness in binutils Jan Beulich
@ 2023-12-21 15:11 ` H.J. Lu
  2024-01-02 11:29 ` Nick Clifton
  2024-01-09 16:19 ` Michael Matz
  2 siblings, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2023-12-21 15:11 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils, Nick Clifton, Alan Modra

On Thu, Dec 21, 2023 at 6:31 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> Hello,
>
> looking around, I can't seem to be able to find any standardized way of
> knowing host endianness in binutils (in gas/ in particular). As was
> pointed out to me, the new cpu_flags_from_attr() in config/tc-i386.c
> won't work as is on big-endian hosts, yet I would really, really like
> to avoid needing to enumerate all of the dozens of bitfields in that
> function (converting one kind of bitfield to another). That's not the
> least because this set constantly grows.
>
> I can see config/tc-bpf.c checking WORDS_BIGENDIAN, but I couldn't
> convince myself (from looking at the generated config.h) that one can
> really rely on that.
>
> Jan

WORDS_BIGENDIAN is generated by AC_C_BIGENDIAN.  It
should be correct.

-- 
H.J.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to know host endianness in binutils
  2023-12-21 14:30 how to know host endianness in binutils Jan Beulich
  2023-12-21 15:11 ` H.J. Lu
@ 2024-01-02 11:29 ` Nick Clifton
  2024-01-09 16:19 ` Michael Matz
  2 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2024-01-02 11:29 UTC (permalink / raw)
  To: Jan Beulich, Binutils; +Cc: Alan Modra

Hi Jan,

> looking around, I can't seem to be able to find any standardized way of
> knowing host endianness in binutils (in gas/ in particular).

There is a CYG_AC_C_ENDIAN function in config/acinclude.m4 that defines
LITTLE_ENDIAN_HOST for little endian hosts, but as far as I can tell this
function is never invoked.

> I can see config/tc-bpf.c checking WORDS_BIGENDIAN, but I couldn't
> convince myself (from looking at the generated config.h) that one can
> really rely on that.

Other code seems to rely upon this define too.  For example gdb/tracectf.c.

Also as H.J. mentioned it does appear that the code in the script configure
does do the right thing.  I would suggest that you can safely use it.

Cheers
   Nick





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to know host endianness in binutils
  2023-12-21 14:30 how to know host endianness in binutils Jan Beulich
  2023-12-21 15:11 ` H.J. Lu
  2024-01-02 11:29 ` Nick Clifton
@ 2024-01-09 16:19 ` Michael Matz
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Matz @ 2024-01-09 16:19 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils, Nick Clifton, Alan Modra

Hey,

On Thu, 21 Dec 2023, Jan Beulich wrote:

> looking around, I can't seem to be able to find any standardized way of
> knowing host endianness in binutils (in gas/ in particular).

I've added a use of AC_C_BIGENDIAN into bfd/ last year (defining 
WORDS_BIGENDIAN).  Seems to have worked fine so far.


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-09 16:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-21 14:30 how to know host endianness in binutils Jan Beulich
2023-12-21 15:11 ` H.J. Lu
2024-01-02 11:29 ` Nick Clifton
2024-01-09 16:19 ` Michael Matz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).