1 Star 0 Fork 0

WHC/xv6-course

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
34b-Q&A.org 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
殊蕤 提交于 2023-11-24 23:31 . add: 添加视频链接

答疑三

如何系统地学习 makefile 和 ld 链接脚本

  1. GNU project by RMS(author)
  2. make https://www.gnu.org/software/make/
  3. binutils https://sourceware.org/binutils/docs/

视频 33 中 swtch 中 bt 输出变化是为什么

x86 ebp

       |   ... ...    |
       | return addr  |
ebp -> | prev ebp     |
       |    ... ...   |
esp -> |    ... ...   |

frame 0: scheduler ebp=0x80115488

       | ... ...    |
       | 0x8010303f |
ebp -> | 0x801154a8 | 0x80115488
       |  ... ...   |
esp -> |  ... ...   |

frame 1: mpmain ebp=0x80115488

       | ... ...    |
       | 0x8010318c |
ebp -> | 0x801154c8 | 0x801154a8
       |  ... ...   |
esp -> |  ... ...   |

frame 2: main ebp=0x80115488

       | ... ...    |
       | 0x00000000 |
ebp -> | 0x00007bf8 | 0x801154c8
       |  ... ...   |
esp -> |  ... ...   |
(gdb) backtrace
#0  scheduler () at proc.c:324
#1  0x8010303f in mpmain () at main.c:57
#2  0x8010318c in main () at main.c:37

违反 x86 call convention

(gdb) bt
#0  swtch () at swtch.S:25
#1  0x00000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) p/x $esp
$3 = 0x8dffff9c
(gdb) p/x $ebp
$4 = 0x80115488

视频 42 中 initcode 系统调用 exec 如何切换到 _init 地址空间

  1. initcode 到 _init 的切换流程
  2. 切换到 0x0
(gdb) bt
#0  exec (path=0x1c "", argv=0x8dfffed0) at exec.c:104
#1  0x801055aa in sys_exec () at sysfile.c:418
#2  0x80104a89 in syscall () at syscall.c:139
#3  0x80105aad in trap (tf=0x8dffffb4) at trap.c:42
#4  0x8010584f in alltraps () at trapasm.S:20

alltraps 里面的 通过汇编执行下一条指令来

  pushl %esp
  call trap
  addl $4, %esp

  # Return falls through to trapret...
.globl trapret
trapret:
  popal
  popl %gs
  popl %fs
  popl %es
  popl %ds
  addl $0x8, %esp  # trapno and errcode
  iret

esp => 0x00000000 next PC = 0

(gdb) x/4x $esp
0x8dffffec:     0x00000000      0x0000001b      0x00000202      0x00002fe4
(gdb)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/whc_softHardware/xv6-course.git
git@gitee.com:whc_softHardware/xv6-course.git
whc_softHardware
xv6-course
xv6-course
master

搜索帮助