When does segment selector comes in picture. The line in Intel Guide says:
"Each segment descriptor has an associated segment selector. A segment selector provides the software that uses it with an index into the GDT or LDT (the offset of its associated segment descriptor), a global/local flag (determines whether the selector points to the GDT or the LDT), and access rights information."
I didn't quite get it.
Are there separate segment selector register(s)? How is it calculated? Why we need it.?
So what happens is:
Whenever a program is loaded, the linking loader loads the "Segment Registers" with the appropriate selectors.
A Segment Register ( e.g. CS, DS, SS, etc) is divided in two parts: Visible and Hidden.
It is the visible part which is loaded by the loader with the appropriate value.
This value is an index in GDT or LDT, depending on the TI flag of the selector.
The processor loads the hidden part by itself. The information in hidden part is the segment base address in the linear address space, segment limit, access information.