ucore-Lab1

bootblock

+ cc boot/bootasm.S
gcc -Iboot/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc  -fno-stack-protector -Ilibs/ -Os -nostdinc -c boot/bootasm.S -o obj/boot/bootasm.o
+ cc boot/bootmain.c
gcc -Iboot/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc  -fno-stack-protector -Ilibs/ -Os -nostdinc -c boot/bootmain.c -o obj/boot/bootmain.o
+ cc tools/sign.c
gcc -Itools/ -g -Wall -O2 -c tools/sign.c -o obj/sign/tools/sign.o
gcc -g -Wall -O2 obj/sign/tools/sign.o -o bin/sign

上面是bootblock的编译过程, 生成多个可重定位文件,在通过链接器链接到一起。

语法格式
       gcc [-c|-S|-E] [-std=standard]
       [-g] [-pg] [-Olevel]
       [-Wwarn...] [-Wpedantic]
       [-Idir...] [-Ldir...]
       [-Dmacro[=defn]...] [-Umacro]
       [-foption...] [-mmachine-option...]
       [-o outfile] [@file] infile...

-I : ①指定头文件目录 ②-L-l一起使用,指定程序的链接库
-fno-builtin 禁用C语言的内建函数
-Wall 显示所有警告
-ggdb Produce debugging information for use by GDB.
-m32 生成32位代码
-gstabs Produce debugging information in stabs format (if that is supported), withoutGDB extensions.
-nostdinc Do not search the standard system directories for header files. Only the directories you have specified with ‘-I’ options
-fno-stack-protector
-Os Optimize for size. ‘-Os’ enables all ‘-O2’ optimizations that do not typically increase code size.
-g Produce debugging information in the operating system’s native format

+ ld bin/bootblock
ld -m    elf_i386 -nostdlib -N -e start -Ttext 0x7C00 obj/boot/bootasm.o obj/boot/bootmain.o -o obj/bootblock.o
'obj/bootblock.out' size: 488 bytes
build 512 bytes boot sector: 'bin/bootblock' success!

-m elf_i386
-nostdlib
-N Set the text and data sections to be readable and writable.
-e Use start as the explicit symbol for beginning execution of your program
-Ttext 0x7C00 设置代码段的起始地址

dd if=bin/bootblock of=bin/ucore.img conv=notrunc
1+0 records in
1+0 records out
512 bytes copied, 7.9894e-05 s, 6.4 MB/s

共512字节大小 以0x55AA结尾

分析lootloader进入保护模式的过程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值