[LLVMdev] Address space extension

Charles Davis cdavis5x at gmail.com
Fri Aug 9 01:48:00 PDT 2013


On Aug 8, 2013, at 3:04 AM, David Chisnall wrote:
> The correct code for this should be (I believe):
> 
> _toglobal:                              ## @toglobal
> ## BB#0:
> 	pushq	%rbp
> 	movq	%rsp, %rbp
> 	lea		%gs:(%rdi), %rax
> 	popq	%rbp
> 	ret
This won't have the effect you're hoping for. LEA stands for "Load Effective Address"; it only operates on the offset part of a logical (far) address. It's no different from before, when RDI was MOV'd into RAX.

In fact, there is no instruction you can use to turn a seg:offset logical address into a linear address. That's why most systems that use the FS and GS registers for thread-specific data have a field for the linear address of the TSD structure.

Chip





More information about the llvm-dev mailing list