Endianness is a quite simple concept. They are 2 types of endianness: big endian and little endian. Nowadays most machines use little endian but for some old machines, they adopted big endian.
- Big Endian (BE)
Big endian is closer to human intuition. A big-endian system stores the most significant byte of a word at the smallest memory address and the least significant byte at the largest.
- Little Endian (LE)
A little-endian system, in contrast, stores the least-significant byte at the smallest address. It is more machine-friendly.
Here is a picture illustrates 2 types of endianness:
Check endianness of your machine
1 |
|
And the result is:
1 | data = 0x12345678 |
This suggests that my machine is little endian because the lowest address least significant byte.
Or just use file ./path/to/binary
to check, the result is:
1 | test: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, |
LSB
means this executable file is little endian.