Reputation: 2304
0x0 0x6 0x0 0x1
BIG - 00000000 00000110 00000000 00000001
LIT - 00000001 00000000 00000110 00000000
So I was expecting 0xcfb01420 + 2 to be 0x6, but that is not the case. Am I missing something?
(gdb) p &tx_q_sem->mlock.u.mtxa_owner
$41 = (volatile __uintptr_t *) 0xcfb01420
(gdb) p/x tx_q_sem->mlock.u.mtxa_owner
$34 = 0x601
(gdb) p (char)*(char*)(0xcfb01420+0)
$36 = 0x1
(gdb) p (char)*(char*)(0xcfb01420+1)
$37 = 0x6
(gdb) p (char)*(char*)(0xcfb01420+2)
$38 = 0x0
(gdb) p (char)*(char*)(0xcfb01420+3)
$39 = 0x0
My assumption is that byte sequence for 0x601 in little endian format should match the way I represented it above. Therefore second byte should have been all zeros. There I have put all the nibbles correctly I guess.
Upvotes: 0
Views: 1421
Reputation: 22589
Your initial hex values are all missing digits, relative to what you're actually examining.
00000001
is 0x01
-- it is 8 binary digits, so a full byte.
So 0x601
== 0x0601
== 00000110 00000001
.
You can see this in gdb with:
(gdb) print /t 0x601
$1 = 11000000001
Upvotes: 2