最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

linux - Understanding Assembly Code from Kernel Entry Point - Stack Overflow

programmeradmin3浏览0评论

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

  1. What is held in $esi on the first line?
  2. Since this is the start of a new program, what is held on the stack and popped to store in %edx?
  3. 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.
  4. Finally, why are all the segment registers loaded with the __BOOT_DS constant?
发布评论

评论列表(0)

  1. 暂无评论