# Global Descriptor Table

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Global_Descriptor_Table
> Markdown URL: https://mediated.wiki/source/Global_Descriptor_Table.md
> Source: https://en.wikipedia.org/wiki/Global_Descriptor_Table
> Source revision: 1326226945
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Memory data structure in Intel processors}}

The '''Global Descriptor Table''' ('''GDT''') is a core part of [Intel](/source/Intel)'s [x86](/source/x86) architecture that helps manage how memory is accessed and protected. Introduced with the Intel [80286](/source/80286) processor, it plays a key role in defining [memory segments](/source/x86_memory_segmentation) and their attributes: the base address, the size, and access privileges like executability and writability.<ref name='Intel'>{{cite web |title=Intel 64 and IA-32 Architectures Software Developer’s Manual, Chapter 5: “Memory Management” |url=https://cdrdv2.intel.com/v1/dl/getContent/671200 |publisher=[Intel](/source/Intel) |access-date=May 19, 2025}}</ref>

Even though modern [64-bit](/source/64-bit) systems rarely rely on segmentation, the GDT remains a required component for starting up the [processor](/source/processor_(computing)) and managing certain system-level tasks.

==Description==
The GDT helps isolate memory between [application software](/source/application_software) and the [operating system](/source/operating_system).

In [protected mode](/source/protected_mode) (a more advanced processor mode that allows [memory protection](/source/memory_protection)), the GDT defines:

* Code segments: regions of memory that contain executable instructions.
* Data segments: areas used to store program data.
* System segments, like the [Task State Segment](/source/Task_State_Segment) (TSS), which is used for multitasking support.<ref name='Intel'></ref><ref name='Tanenbaum & Bos'>{{cite book |last1=Tanenbaum |first1=Andrew S. |last2=Bos |first2=Herbert |date=2014 |title=Modern Operating Systems (4th ed.) |url=https://csc-knu.github.io/sys-prog/books/Andrew%20S.%20Tanenbaum%20-%20Modern%20Operating%20Systems.pdf|publisher=Pearson |page=249 |isbn=978-0133591620 |access-date=May 19, 2025}}</ref>

Each entry in the GDT is 8 or 16 bytes long and holds a [segment descriptor](/source/segment_descriptor) that defines the properties of one segment. Each descriptor includes access rights, ensuring programs cannot modify protected memory.<ref name='Intel'></ref>

[[File:SegmentDescriptor.svg|none|thumb|580px|Format of a [segment descriptor](/source/segment_descriptor)]]

To use a segment, a program refers to it using a [segment selector](/source/segment_selector) — a special value that tells the processor which GDT entry to use. The processor then loads this descriptor into a [segment register](/source/segment_register), which holds both visible and hidden metadata about the segment.

== GDT in 64-bit ==

In 64-bit mode, segmentation is mostly disabled: all segment bases are treated as zero, and limits are ignored, creating a flat address space. However, the GDT is still required to define system descriptors such as the [Task State Segment](/source/Task_State_Segment) (TSS). Two segment registers, FS and GS, remain active and are often used by operating systems for thread-local storage or process-specific data (e.g., the [Thread Environment Block](/source/Thread_Environment_Block) in [Windows](/source/Windows) or gs_base in [Linux](/source/Linux)).<ref name='Intel'></ref>

Notably, Windows enforces strict protections: attempts to [hook](/source/hooking) or modify the GDT in 64-bit versions will trigger a system crash ([bug check](/source/bug_check)).<ref name="Patching Policy for x64-Based Systems">{{cite web
|url=https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc759759(v=ws.10)
|title=Patching Policy for x64-Based Systems
|date=8 October 2009
|quote=If the operating system detects one of these modifications or any other unauthorized patch, it will generate a bug check and shut down the system.
|access-date=11 December 2020
|archive-date=19 January 2022
|archive-url=https://web.archive.org/web/20220119231124/https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc759759(v=ws.10)
|url-status=live
}}</ref>

==Local Descriptor Table==

While the GDT defines system-wide segments, the '''Local Descriptor Table''' ('''LDT''') can define segments that are private to a single process. Historically, operating systems used the LDT to separate each program’s memory into private regions, especially before paging was introduced with the Intel 80386.

Today, LDTs are mostly obsolete but may still appear for compatibility with 16-bit or older 32-bit applications (e.g., [DOS](/source/DOS) or [OS/2](/source/OS%2F2) programs). The LDT is defined by an entry in the GDT and can include up to 8192 segment descriptors.<ref name='Tanenbaum & Bos'></ref>

== History and modern usage ==
In early x86 systems (like the [80286](/source/80286)), segmentation via the GDT and LDT was critical to implementing [multitasking](/source/computer_multitasking) and memory isolation. Each process had its own LDT, while the GDT held global definitions. The system could automatically switch the current LDT when changing tasks, making segment-based isolation efficient.

However, with the introduction of [paging](/source/memory_paging) on the [80386](/source/80386), operating systems began using page-based virtual memory instead of segment-based memory. Paging allows fine-grained memory management in 4KB chunks and makes it easier to share or protect memory.

As a result, modern operating systems like [Windows](/source/Windows), [Linux](/source/Linux), and [macOS](/source/macOS) use a flat memory model, where all code and data segments span the entire [address space](/source/address_space). The GDT is still involved in system initialization, interrupt handling, and defining special structures like the TSS and LDT pointer.<ref name='Intel'></ref>

Legacy or compatibility modes (e.g., running 16-bit DOS or OS/2 code) may still use segmentation more actively. In such cases, a technique known as LDT tiling can be used, where the LDT is filled with descriptors that map fixed-size memory blocks (e.g., 64 KB each) to provide coverage for legacy applications.

== References ==
{{Reflist}}

== External links ==
* [https://web.archive.org/web/20050505161222/http://download.intel.com/design/PentiumII/manuals/24319202.pdf Intel Architecture Software Developer's Manual]
* [http://wiki.osdev.org/Global_Descriptor_Table Global Descriptor Table] {{Webarchive|url=https://web.archive.org/web/20091017082325/http://wiki.osdev.org/Global_Descriptor_Table |date=2009-10-17 }} at OSDev.org
* [http://wiki.osdev.org/GDT_Tutorial GDT Tutorial] {{Webarchive|url=https://web.archive.org/web/20090214221429/http://wiki.osdev.org/GDT_Tutorial |date=2009-02-14 }} at OSDev.org
* [http://www.osdever.net/bkerndev/Docs/gdt.htm Bran's Kernel Dev GDT Tutorial] {{Webarchive|url=https://web.archive.org/web/20080203044751/http://www.osdever.net/bkerndev/Docs/gdt.htm |date=2008-02-03 }}
* [http://www.brokenthorn.com/Resources/OSDev8.html BrokenThorn Protected Mode] {{Webarchive|url=https://web.archive.org/web/20180423112351/http://brokenthorn.com/Resources/OSDev8.html |date=2018-04-23 }}

Category:X86 architecture
Category:Memory management

---
Adapted from the Wikipedia article [Global Descriptor Table](https://en.wikipedia.org/wiki/Global_Descriptor_Table) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Global_Descriptor_Table?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
