hexdump returning varying results
2 Attachment(s)
I have been playing with hex dump to look at binary files compiled with GCC, I am specifically looking at the structure of ELF files. I created a C program and compiled it and ran
Code:
hexdump temp Code:
hexdump -C temp In the attached images you can see the hex results are not the same for each run, temp was not recompiled in between each run of hexdump. Is anyone able to explain why I am getting different results? |
Welcome to the joys of Endianness and whether hexdump is reading bytes or words.
|
Coming from big-endian, I find the x86 little endian format arcane beyond words.
|
Quote:
Code:
$ hexdump /bin/bash | head -n1 However, byte 7f is located at position 0, byte 45 is located at position 1. This is so because Intel CPUs (and the ARM CPU in my tiny server, as I just confirmed) are little-endian: numbers are stored so that the lower bytes come first. hexdump -C shows each byte as it is positioned: First 7f, then 45 and so on. This works for strings and, in general, one-byte values. Quote:
|
Thanks. Make sense now, just couldn't figure out what was happening
|
All times are GMT -5. The time now is 09:33 PM. |