使用 GNU 汇编的主引导记录

问题描述

我正在尝试编译以下简单的 MBR:

.code16
.globl _start
.text
_start: 
end:
    jmp end
; Don't bother with 0xAA55 yet

我运行以下命令:

> as --32 -o boot.o boot.s
> ld -m elf_i386 boot.o --oformat=binary -o mbr  -Ttext 0x7c00

然而,我得到一个超过 129MB 的二进制文件,这对我来说很奇怪。因此, 我想知道在构建过程中发生了什么?非常感谢。

通过 boot.o 运行 objdump 给我:

> objdump -s boot.o
boot.o:     format de fichier elf32-i386

Contenu de la section .text :
 0000 ebfe                                 ..              
Contenu de la section .note.gnu.property :
 0000 04000000 18000000 05000000 474e5500  ............GNU.
 0010 020001c0 04000000 00000000 010001c0  ................
 0020 04000000 01000000 

在调用 ld 之前手动删除 .note.gnu.property 部分似乎可以解决问题。不过不知道为什么默认会出现这个部分……运行下面的build命令好像也能解决问题:

> as --32 -o boot.o boot.s -mx86-used-note=no
> ld -m elf_i386 boot.o --oformat=binary -o mbr  -Ttext 0x7c00

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...