I am learning x86 assembly slowly. I understand there are two different syntaxes (Intel and AT&T). The assembly instructions here are the first instructions the Linux Kernel uses to decompress it's image and start KASLR.
00: leal (BP_scratch+4)(%esi), %esp
01: call 1f
02: 1: popl %edx
03: addl $_GLOBAL_OFFSET_TABLE_+(.-1b), %edx
04:
05: /* Load new GDT */
06: leal gdt@GOTOFF(%edx), %eax
07: movl %eax, 2(%eax)
08: lgdt (%eax)
09:
0A: /* Load segment registers with our descriptors */
0B: movl $__BOOT_DS, %eax
0C: movl %eax, %ds
0D: movl %eax, %es
0E: movl %eax, %fs
0F: movl %eax, %gs
10: movl %eax, %ss
- What is held in
$esi
on the first line? - Since this is the start of a new program, what is held on the stack and popped to store in
%edx
? - On line 7, since this is AT&T syntax, what is going on with
movl
? Is%eax
set to%eax + 2
? This does not follow the AT&T syntax. - Finally, why are all the segment registers loaded with the
__BOOT_DS
constant?