orange 一个操作系统的实现 较新的gcc和ld编译后无法运行的问题

手贱更新了全部东西,然后用最新gcc编译后发现项目运行不了了
错误表现为mov byte ptr es:[edi],al这一行无法继续运行
在这里插入图片描述
尝试从原版文件运行,发现是可行的。
然后尝试怀疑boot或loader问题,但是拖了能运行的kernel到img中是可运行的,排除
用bochs断点单步,发现elf拷贝内存时出错,尝试用readelf给出的信息和调试信息做对比
在这里插入图片描述
单步调试时发现前三个程序头无错,但是第四个就不行了,分析VirtAddr
0x80480f4=134512884(10)byte=128.2815mb
但是默认的bochsrc中配置的内存大小为32mb,显然越界了
重新配置内存大小就可以解决

但是这样做会和原先设计的内存分布有冲突,需要解决为什么elf会分配到128的位置

因为于老师的教程出得很早了,所以有些配置还是需要修改的,除了上面说的内存
最新的bochs也不能运行,因为相关联的文件存储地址变化了,不再是

romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/vgabios/vgabios.bin
keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map

可以直接#屏蔽或者使用标准写法

romimage: file=$BXSHARE/BIOS-bochs-latest
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
keyboard_mapping: enabled=1, map=gui/keymaps/x11-pc-de.map

另外Makefile中的CFLAGS和LDFLAGS分别添加

-m32 -fno-stack-protector
-m elf_i386

看了下elf文件越界位置的内容,发现只是一些版本说明的东西,没什么用?
在这里插入图片描述
对比原先正常的elf文件
在这里插入图片描述
在这里插入图片描述

现在唯一知道的是最新的ld在elf里添加了新的段.not.gnu.property,而根据ld手册上说的
在这里插入图片描述
确实-Ttext无法管到.not.gnu.property它们的位置,所以导致了越界
看了下于老师的内存分布,决定把这个多出来的段放在kernel.bin加载位置的最后这个地方
在这里插入图片描述
在这里插入图片描述

最后编译运行,问题解决

一个小型的操作系统,采用gcc进行开发,几千行的代码,方便初学者学习,内含有编译好的映像文件,及bochs模拟器配置文件,可在bochs下模拟运行。如下为源码包内的README文件: # # Snixos Project version 1.0, 2003.6 # (C) Copyright 2003,2004,2005 Jockeyson,KeqianGao # All Rights Reserved. # Distributed under the terms of the GNU General Public License. # # This program is a free and open source software and you can redistribute # it and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation. As no any liability is assumed # for any incidental or consequential damages in connection with the # information or program fragments contained herein,so any exception arised # is at your own risk. It is ABSOLUTELY WITHOUT ANY WARRANTY. # Bug report please send to Snallie@tom.com . # 0. What is Snixos Project? Snixos Project is an experimental operating system designed by Jockeyson , KeqianGao aiming at multitask/multithread, Chinese envionment including Chinese characters input and ouput etc... 1. What you need to run Snixos PC with the following minimum configuration: CPU: i386 or above MEM: 2M extended memory or more DISPLAY: VGA or above Floppy Drive: 1.44M 2. Compile Environment RH Linux 7.2 or above (kernel 2.4.7-10 ) NASM 0.98 gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98) 3. Compile and install a. unpack the source package tar zxvf snixos_x.x_YYYYMMDD_HHMMSS.tgz b. cd to snixos cd snixos c. before make insert a 1.44M floppy in drive c.1 to make snixos run in VGA text mode make clean make VIDEO=TEXT diskimg make floppy c.2 to make snixos run VGA graphics mode make clean make diskimg make floppy d. bootup with the floppy just created in step c also you can follow this way to run snixos in bochs either in Windows or Linux a. just as the above b. just as the above c. invoke these command: make clean; make diskimg you'll get a snixos ima
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值