Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

linux - How to interpret %gs:0x14?

I am a little confused with the use of colon in x86 assembly. I know that in real mode %gs:0x14 will be the address of %gs shift 4 bits left and adds with 0x14. But it is the same in protected mode? For example in protected mode,

movl %gs:0x14 %eax 

In what way %gs:0x14 is accessed? It is like 0x14(%gs) or same as in real mode?

Update: to make my question clearer, assume %gs = 0x1234 what is the value of %eax after instruction movl %gs:0x14 %eax.

Further information:

Just found this document useful for the function of gs and fs in different system http://www.akkadia.org/drepper/tls.pdf

And this link provide information about segment:offset address.

http://thestarman.pcministry.com/asm/debug/Segments.html

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to carefully read the application binary interface specification for your architecture (probably x86-64), i.e. X86-64 ABI.

You'll find out that %gs is related to thread local storage. See this answer.

So your machine instruction is probably loading the word at offset 0x14 of the current TLS.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...