*%gs:0x10 在汇编程序中做什么?

What does *%gs:0x10 do in assembler?

以下语法在 GASM 中有什么作用?

*%gs:0x10

我知道 call *%gs:0x10 调用会 __kernel_vsyscall,但我不知道 *%register:value 会做什么。

它的 NASM 等价物如下所示:call DWORD PTR gs:0x10

这是对gs:0x10中指针目标的near absolute indirect (FF /2)调用。
请注意 gs 是一个选择器寄存器,而不是通用寄存器(参见 Protected mode)。
该指令读取偏移量 0x10 处的 DWORD(相对于段 gs)并调用其值。
直接调用会完全产生另一种效果,可能涉及调用门。


gs:0x10libc copies the address of __kernel_vsyscall during its initialization.

AT&T syntax for the control transfer instructions

Branch addressing using registers or memory operands must be prefixed by a '*'. To specify a "far" control tranfers, a 'l' must be prefixed, as in ljmp, lcall, etc. For example,

GAS syntax          NASM syntax
==========          ===========

jmp *100            jmp  near [100]
call *100           call near [100]
jmp *%eax           jmp  near eax
jmp *%ecx           call near ecx
jmp *(%eax)         jmp  near [eax]
call *(%ebx)        call near [ebx]
ljmp *100           jmp  far  [100]
lcall *100          call far  [100]
ljmp *(%eax)        jmp  far  [eax]
lcal *(%ebx)        call far  [ebx]
ret                 retn
lret                retf
lret [=10=]x100         retf 0x100

Segment-offset pointers are specified using the following format:

jmp $segment, $offset