Chinaunix首页 | 论坛 | 博客
  • 博客访问: 603574
  • 博文数量: 113
  • 博客积分: 2554
  • 博客等级: 少校
  • 技术积分: 1428
  • 用 户 组: 普通用户
  • 注册时间: 2011-12-21 19:53
文章分类

全部博文(113)

文章存档

2014年(1)

2013年(2)

2012年(94)

2011年(16)

分类: LINUX

2012-04-26 09:29:34


点击(此处)折叠或打开

  1. #include <stdio.h>
  2. greeting()
  3. {
  4. printf("Hello, world!\n");
  5. }
  6. main()
  7. {
  8. greeting();
  9. }
  10. 08048368 <greeting>:
  11.  8048368: 55 push %ebp
  12.  8048369: 89 e5 mov %esp,%ebp
  13.  804836b: 83 ec 08 sub $0x8,%esp
  14.  804836e: 83 ec 0c sub $0xc,%esp
  15.  8048371: 68 84 84 04 08 push $0x8048484
  16.  8048376: e8 35 ff ff ff call 80482b0 <printf@plt>
  17.  804837b: 83 c4 10 add $0x10,%esp
  18.  804837e: c9 leave
  19. 37
  20.  804837f: c3 ret
  21. 08048380 <main>:
  22.  8048380: 55 push %ebp
  23.  8048381: 89 e5 mov %esp,%ebp
  24.  8048383: 83 ec 08 sub $0x8,%esp
  25.  8048386: 83 e4 f0 and $0xfffffff0,%esp
  26.  8048389: b8 00 00 00 00 mov $0x0,%eax
  27.  804838e: 83 c0 0f add $0xf,%eax
  28.  8048391: 83 c0 0f add $0xf,%eax
  29.  8048394: c1 e8 04 shr $0x4,%eax
  30.  8048397: c1 e0 04 shl $0x4,%eax
  31.  804839a: 29 c4 sub %eax,%esp
  32.  804839c: e8 c7 ff ff ff call 8048368 <greeting>
  33.  80483a1: c9 leave
  34.  80483a2: c3 ret
  35.  80483a3: 90 nop
  36. 0x08048368是程序入口
  37. 1、从段寄存器开始取值,即段选择符
  38. ==================== include/asm-i386/segment.h 4 8 ====================
  39. 4 #define __KERNEL_CS 0x10
  40. 5 #define __KERNEL_DS 0x18
  41. 6
  42. 7 #define __USER_CS 0x23
  43. 8 #define __USER_DS 0x2B
  44. 2、然后根据__USER_CS 0x23找全局描述符表,找到如下的东西
  45. 450 ENTRY(gdt_table)
  46. 451 .quad 0x0000000000000000 /* NULL descriptor */
  47. 452 .quad 0x0000000000000000 /* not used */
  48. 453 .quad 0x00cf9a000000ffff /* 0x10 kernel 4GB code at 0x00000000 */
  49. 454 .quad 0x00cf92000000ffff /* 0x18 kernel 4GB data at 0x00000000 */
  50. 455 .quad 0x00cffa000000ffff /* 0x23 user 4GB code at 0x00000000 */
  51. 456 .quad 0x00cff2000000ffff /* 0x2b user 4GB data at 0x00000000 */
  52. 457 .quad 0x0000000000000000 /* not used */
  53. 458 .quad 0x0000000000000000 /* not used */

点击(此处)折叠或打开

  1. 3、之后进行线性地址的页式转换
  2. Linux实际将持续入口地址映射为自身0x08048368
  3. 0000 1000 0000 0100 1000 0011 0110 1000
阅读(982) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~