Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Marius Nita" <shrimpx@gmail.com>
To: gdb@sourceware.org
Subject: a question
Date: Thu, 16 Aug 2007 00:20:00 -0000	[thread overview]
Message-ID: <f72a771a0708151720q50d424a6v23b3a961ac851202@mail.gmail.com> (raw)

Hi, I am trying to understand some endian-specific code in GDB (well,
BFD for the purpose of this message). I would greatly appreciate any
help.

I have a rather specific question regarding the code below, which is
in bfd/aout-arm.c line 420. This code seems to deal with bit-level
endianness. E.g. a "char" address holding a bit pattern 00010000
represents 0x10 on one endianness and 0x08 on the other. The r_length
left-shift below shifts data by 5 bits on big-endian and 1 bit on
little-endian. The r_length data will end up occupying 2 bits in the
natptr->r_type[0] byte. On big-endian, they'll be bits 6 and 7, and on
little-endian, they are bits 2 and 3.

My question is: why aren't the bits in r_length "reversed" to conform
with bit-level endianness? For example, if the r_length bits are "10",
this left-shift results in "0100 0000" on big-endian and "0000 0100"
on little-endian. These bit strings are clearly not the reverse of
each other.

Any help would be much appreciated!

Thank you!

-m

  if (bfd_header_big_endian (abfd))
    {
      natptr->r_index[0] = r_index >> 16;
      natptr->r_index[1] = r_index >> 8;
      natptr->r_index[2] = r_index;
      natptr->r_type[0] =
    (  (r_extern ?   RELOC_STD_BITS_EXTERN_BIG: 0)
     | (r_pcrel  ?   RELOC_STD_BITS_PCREL_BIG: 0)
     | (r_neg    ?   RELOC_ARM_BITS_NEG_BIG: 0)
     | (r_length <<  RELOC_STD_BITS_LENGTH_SH_BIG));
    }
  else
    {
      natptr->r_index[2] = r_index >> 16;
      natptr->r_index[1] = r_index >> 8;
      natptr->r_index[0] = r_index;
      natptr->r_type[0] =
    (  (r_extern ?   RELOC_STD_BITS_EXTERN_LITTLE: 0)
     | (r_pcrel  ?   RELOC_STD_BITS_PCREL_LITTLE: 0)
     | (r_neg    ?   RELOC_ARM_BITS_NEG_LITTLE: 0)
     | (r_length <<  RELOC_STD_BITS_LENGTH_SH_LITTLE));
    }


             reply	other threads:[~2007-08-16  0:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-16  0:20 Marius Nita [this message]
2007-08-16  0:30 ` Daniel Jacobowitz
2014-02-04 18:06 A Question Thomas Dineen
2014-02-04 19:07 ` Eli Zaretskii
2014-02-05  0:55 ` Christopher Faylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f72a771a0708151720q50d424a6v23b3a961ac851202@mail.gmail.com \
    --to=shrimpx@gmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox