《Linux_0_01_内核分析与操作系统设计》实践问题记录

本篇是2022年学习linux0.01操作系统,在编译和安装过程中遇到的问题以及过程记录。2022年4月之前做的,后来在linux0.01安装过程中还有问题没有处理完,不知道以后还会不会把这本书学完了。

在后面还有红帽系统的安装问题记录。

    • Bochs下载:

http://sourceforge.net/projects/bochs/

查看所有版本:

Bochs x86 PCemulator - Browse /bochs at SourceForge.net

最新版本只支持64位系统,XP上运行不了,所以安装旧版本,比如2.0.2版本;

虽然书上例子是2.0.2版本,但是实际运行总有问题,屏幕总是自动清空。

最终使用2.6版本的exe安装可正常运行;

    • RawWrite下载:

需使用软盘驱动器,可在XP虚拟机中使用;

RawWritefor Windows – Freecode (sourceforge.net)

    • 虚拟软驱下载vfloppy

该软件仅支持win95/98/Me,仅支持32位系统,可在XP虚拟机中使用;

Virtual Floppy forWindows (sourceforge.net)

    • 通过XP虚拟机添加软盘

(59条消息) 在VMware Workstation中创建一个虚拟软盘,并在WindowsXP上使用_Apollon_krj的博客-CSDN博客_创建虚拟软盘

    • 下载安装DJGPP

DJGPPZip File Picker Results (delorie.com)

安装步骤:

unzip32 c:\dos_os\djgpp\djdev205.zip

unzip32 c:\dos_os\djgpp\faq230b.zip

unzip32 c:\dos_os\djgpp\rhid15ab.zip

unzip32 c:\dos_os\djgpp\bnu2351b.zip

unzip32 c:\dos_os\djgpp\gcc930b.zip

unzip32 c:\dos_os\djgpp\gdb801b.zip

unzip32 c:\dos_os\djgpp\mak43b.zip

    • masm下载安装:

Download TheMASM32 SDK

从最后两个链接:从中国的程序员下载;

安装后添加环境变量:

include项中添加C:\masm32\include

lib中添加C:\masm32\lib

path中添加C:\masm32\bin

dos下的masm是随vc6.0安装包一起的;

    • nasm下载

NASM

nasm编译hello.com后无法在命令行执行,需要在DosBox执行;

    • 编译错误:

i386 architecture of input file:

解决方法:sudo apt install gcc-multilibg++-multilib module-assistant

root@Kylin:/home/kylin/文档# nasm -f elf hello.asm

root@Kylin:/home/kylin/文档# gcc -o hello hello.o

/usr/bin/ld: i386 architecture of inputfile `hello.o' is incompatible with i386:x86-64 output

collect2: error: ld returned 1 exit status

解决方法:

nasm -f elf64 hello.asm -o hello.o

gcc -o hello hello.o

root@Kylin:/home/kylin/文档# gcc -o hello hello.o

/usr/bin/ld: hello.o: relocationR_X86_64_32 against `.text' can not be used when making a PIE object; recompilewith -fPIE

collect2: error: ld returned 1 exit status

解决方法:

gcc -m64 hello.o -o hello -no-pie

正确做法:

root@Kylin:/home/kylin/文档# nasm -f elf64 hello.asm -o hello.o

root@Kylin:/home/kylin/文档# gcc -m64 hello.o -o hello -no-pie

root@Kylin:/home/kylin/文档# ./hello

Hello World!

root@Kylin:/home/kylin/文档#

    • Red Hat Linux 7.2下载安装

(63条消息) RedHat红帽RHEL7.2镜像下载以及安装教程(内含下载链接)_qixiaochuandashabi的博客-CSDN博客_redhat7下载

Red Hat Enterprise LinuxISO 全镜像下载 - JackGIS - 博客园 (cnblogs.com)

[原]红帽Red Hat Linux相关产品iso镜像下载【百度云】【更新7.7】 - linuxの飘扬 - Powerby www.linuxfly.org

root密码:******

    • 安装gas

Redhat7安装yum(换成免费版),在线更新GCC,无视依赖困扰 - 知乎(zhihu.com)

wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm

wget安装失败,所以直接从网站下载后复制到虚拟机;

升级安装rpm:

rpm -Uvh rpm-4.11.3-45.el7.x86_64.rpm--nodeps

升级安装python:

rpm -Uvh rpm-4.11.3-45.el7.x86_64.rpm--nodeps

rpm -Uvh python-iniparse-0.4-9.el7.noarch.rpm--nodeps

rpm -Uvh python-urlgrabber-3.10-10.el7.noarch.rpm–nodeps

rpm -ivh yum-*

yum

rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpmyum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpmyum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

配置.repo文件,内容如下:

#CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client. You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$7 - Base - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os

baseurl=http://mirrors.163.com/centos/7/os/$basearch/

gpgcheck=1

gpgkey= http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-$7 - Updates - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates

baseurl= http://mirrors.163.com/centos/7/extras/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-$7 - Extras - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras

baseurl=http://mirrors.163.com/centos/7/extras/$basearch/

gpgcheck=1

gpgkey= http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$7 - Plus - 163.com

baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

安装gcc:

yum install gcc

gas过时替换:

(69条消息) Ubuntu64位编译Linux0.0.1所遇到的Bug(copy的,之后会总结)_靳皓屹工作站的博客-CSDN博客

错误:../include/linux/sched.h:186:1:error: ‘asm’ operand has impossible constraints

__asm__("movw %%dx,%0\n\t" \

(75条消息) C语言进阶——内联汇编_Li-Yongjun的博客-CSDN博客_c语言内联汇编

错误:keyboard.s:37: Error: `%al' not allowedwith `xorl'

解决方法:

(78条消息) linux0.11编译_咖小哩的博客-CSDN博客_编译linux0.11

sed -i 's/xorl/xor/g' keyboard.s

错误:make[1]: gld: Command not found

解决方法:msed gld ld

将 makefile文件中的gld替换为ld

错误:ld: Relocatable linking with relocationsfrom format elf32-i386 (sched.o) to format elf64-x86-64 (kernel.o) is notsupported

解决方法:告诉ld以32位链接,在ld命令后面加 -melf_i386

错误:

mm/mm.o: In function `_page_fault':

(.text+0x4a8): undefined reference to`_do_wp_page'

kernel/kernel.o:(.data+0x2bc): undefinedreference to `pg_dir'

kernel/kernel.o:(.data+0x1148): undefinedreference to `sys_fork'

kernel/kernel.o:(.data+0x116c): undefinedreference to `sys_execve'

解决方法:

-fleading-underscore

错误:

kernel/kernel.o: In function `_scrup':

console.c:(.text+0x1e96): undefinedreference to `_columns'

console.c:(.text+0x1f4e): undefinedreference to `_columns'

解决方法:

将_columns 替换为0x0050

错误:

ld -s -x -M boot/head.o init/main.o \

kernel/kernel.o mm/mm.o fs/fs.o \

lib/lib.a \

-o tools/system > System.map

ld: i386 architecture of input file`boot/head.o' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`init/main.o' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`kernel/kernel.o' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`mm/mm.o' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`fs/fs.o' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(ctype.o)' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(_exit.o)' is incompatible with i386:x86-64 output

ld: i386 architecture of input file `lib/lib.a(open.o)'is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(close.o)' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(errno.o)' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(write.o)' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(dup.o)' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(setsid.o)' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(execve.o)' is incompatible with i386:x86-64 output

ld: i386 architecture of input file`lib/lib.a(wait.o)' is incompatible with i386:x86-64 output

ld: warning: cannot find entry symbol_start; defaulting to 00000000004000f0

make: *** [tools/system] Error 1

解决方法:

ld: i386 架构于输入文件foo.o 与 i386:x86-64 输出不兼容- jenningszheng - 博客园(cnblogs.com)

ld -m elf_i386

错误:

-o tools/system > System.map

ld: warning: cannot find entry symbol_start; defaulting to 00000000080480a0

(echo -n "SYSSIZE = (";ls -ltools/system | grep system \

|cut -c25-31 | tr '\012' ' '; echo "+ 15 ) / 16") > tmp.s

cat boot/boot.s >> tmp.s

as -a -o boot/boot.o tmp.s

tmp.s: Assembler messages:

tmp.s:1: Error: missing ')'

tmp.s:1: Error: junk at end of line, firstunrecognized character is `M'

tmp.s:2: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:3: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:4: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:5: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:6: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:7: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:8: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:9: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:10: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:11: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:12: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:13: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:14: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:15: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:16: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:17: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:18: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:19: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:20: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:21: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:22: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:23: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:24: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:25: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:26: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:27: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:28: Error: junk at end of line, firstunrecognized character is `|'

tmp.s:29: Error: junk at end of line, firstunrecognized character is `|'

UNDEFINED SYMBOLS

SYSSEG

system

ax

ds

es

cx

si

di

ss

sp

ah

bh

bx

bp

save

load

al

jmp

This

yes

loop

current

GAS LISTING tmp.s page 9

dx

ch

dh

dl

dummy

base

code

granularity

data

idt

make: *** [boot/boot] Error 1

解决方法:

修改./boot/boot.s ,把注释符由"|" 改为"!" ;

注释不正确

    • redhat7.2联网

(67条消息) VMware虚拟网络编辑器用法_只想整天学习的博客-CSDN博客_vmware虚拟网络编辑器

(67条消息) Redhat7虚拟机 NAT 网络配置_小白菜duang的博客-CSDN博客_redhat7虚拟机网络配置

(67条消息) VMware redhat7.4 虚拟机无法上网_倩妹子Z的博客-CSDN博客

(67条消息) Vmware redhat 使用Nat方式上网_PrettyJade的博客-CSDN博客

虚拟机网络配置(NAT模式无法上网问题) - 简书(jianshu.com)

vi ifcfg-eno16777736

原来是网卡没有激活

我第一次没有成功,重新设置了“DNS”,把DNS和网关设置成一样的,这样就可以了。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值