Re: X86: Question about GDT loading

From: Brian Gerst

Date: Sun Aug 16 2026 - 17:17:41 EST


On Sun, Aug 16, 2026 at 4:58 PM Alexandre <alexramos25.pt@xxxxxxxxx> wrote:
>
> I was tracing the execution of the file
> "arch/x86/boot/compressed/head_32.S" with gdb when I noticed that the
> address used for the GDT in the GDTR structure pointed to the GDTR
> itself.
>
> This is weird because it would make the GDTR an entry in the GDT.

The first slot of the GDT is unused, as it corresponds to the null
selector. So it's a common trick to use that space for the GDT
descriptor, at least on 32-bit. There isn't enough space for a 64-bit
base address.