I'm using bochs to debug the JOS of MIT. I'm confused at the address of the bochs's output:
(0) [0x0010002e] 0008:0xf010002e (unk. ctxt): mov ebp, 0x00000000 ; bd00000000
I'm trying to figure out how 0008:0xf010002e
is transfered to [0x0010002e]
.
Based on the transfermation from logic addr. to linear address, I think I should use the base address from the GDT's 8th entry to plus the offset 0xf010002e
.
However, I got the GDT's content as follows:
<bochs:6> x /16wx 0x0010f000
[bochs]:
0x0010f000 <bogus+ 0>: 0x00000000 0x00000000 0x0000ffff 0x10cf9a00
0x0010f010 <bogus+ 16>: 0x0000ffff 0x10cf9300 0xf0000017 0x00000010
0x0010f020 <bogus+ 32>: 0x32311b00 0x36353433 0x30393837 0x09083d2d
0x0010f030 <bogus+ 48>: 0x72657771 0x69757974 0x5d5b706f 0x7361000a
The 8th entry is:
0x69757974 0x5d5b706f
Based on the entry's format at Fig 5-3, the base address is: 0x730a8d5b
. However, 0x730a8d5b + 0xf010002e is not 0x0010002e!
Can anyone help me point out where I'm wrong?
Thank you so much in advance!
0008
means first segment, not 8th.
Thus, 0x0000ffff 0x10cf9a00
means segment base = 0x10000000, so 0008:0xf010002e
overlaps to 0x0010002e.
Edit: (answering the comment)
The lowest bits 0 and 1 of segment selector is used as privilege level (ring) selector, bit 2 - selects between GDT and LDT, all the other bits are used as offset to relevant descriptors table. Thus, 0x0008
to 0x000b
means 0x0008
offset in GDT with privilege levels 0..3
Pointer for the explanation: Intel Software Developer Manual, vol.3, ch.3