[Bug 907180] Re: od(1) doesn't compensate for Endianness of CPU

C de-Avillez hggdh2 at ubuntu.com
Wed Dec 21 19:07:56 UTC 2011


Thank you for opening this bug and helping make Ubuntu better. This is
not a bug, but a requirement form POSIX. Please see the thread at
http://lists.gnu.org/archive/html/bug-coreutils/2011-11/msg00120.html
for an expanded explanation.

"> Is this a big-endian/little-endian issue?

Absolutely, which means it's not a bug, but a requirement by POSIX.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/od.html

If you want to output bytes in hex, then don't use the shorthand '-x'
(which is hardcoded to picking up machine-size short words, as in -tx2,
and thus exposes endianness issues), but instead use an explicit '-tx1'."

As such I am closing this bug as INVALID. Please do not hesitate in
reopening it if you do not agree, and please do keep on reporting other
issues you may find.

** Changed in: coreutils (Ubuntu)
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to coreutils in Ubuntu.
https://bugs.launchpad.net/bugs/907180

Title:
  od(1) doesn't compensate for Endianness of CPU

Status in “coreutils” package in Ubuntu:
  Invalid

Bug description:
  Try the following experiment: pick a small binary file on your system
  where the data and locations are unequivocally known. I recommend
  something like /sys/firmware/acpi/tables/BOOT. Since only root can
  read these files, you'll need to prefix each od(1) command with sudo
  or do "sudo sh" to get a root command prompt.

  Execute the following commands:

  1)  od -t xz /sys/firmware/acpi/tables/BOOT

  2)  od -t x2z /sys/firmware/acpi/tables/BOOT

  3)  od -t x1z /sys/firmware/acpi/tables/BOOT

  If you're running on a Little Endian (x86) machine you'll note that
  what gets output in the left field is actually what gets loaded into
  the CPU's registers & not the order of data in the file. In example 1,
  a 32-bit integer is loaded while a 16-bit integer is loaded in example
  2 and a single byte is loaded into the register in example 3.

  Note also that the right hand (ASCII strings) field remains constant
  in all 3 examples.

  I've never seen this issue on a Big Endian machine, but I'm surprised
  that it still occurs this late in time on Little Endian machines.

  
  xxx at yyyyyy:~$ lsb_release -rd
  Description:	Ubuntu 10.04.3 LTS
  Release:	10.04

  xxx at yyyyyy:~$ apt-cache policy coreutils
  coreutils:
    Installed: 7.4-2ubuntu3
    Candidate: 7.4-2ubuntu3
    Version table:
   *** 7.4-2ubuntu3 0
          500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages
          100 /var/lib/dpkg/status
       7.4-2ubuntu2 0
          500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/907180/+subscriptions




More information about the foundations-bugs mailing list