1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#安装xbuild用于交叉编译:
cargo install cargo-xbuild

cargo install bootimage --version "^0.7.7"

rustup component add llvm-tools-preview

#构建.bin文件
cargo bootimage
qemu-system-x86_64 -drive format=raw,file=target/x86_64-blog_os/debug/bootimage-blog_os.bin
#可以直接使用:
cargo xrun

工具

1.readelf

用于读取elf文件的各种信息,使用说明:

https://man.linuxde.net/readelf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-S 
--section-headers  
--sections 显示节头信息(如果有的话)。

-t 
--section-details 显示节的详细信息(-S的)。 

-s 
--syms        
--symbols 显示符号表段中的项(如果有的话)。 

-e 
--headers 显示全部头信息,等价于: -h -l -S 

-r 
--relocs 显示可重定位段的信息。 

-u 
--unwind 显示unwind段信息。当前只支持IA64 ELF的unwind段信息。 

-d 
--dynamic 显示动态段的信息。 


-A 
--arch-specific 显示CPU构架信息。

2.objdump

查看目标文件或者可执行的目标文件的构成,使用说明:

https://man.linuxde.net/objdump

常用指令:

1
2
3
4
5
6
7
--disassemble 
-d 
从objfile中反汇编那些特定指令机器码的section。 

-D 
--disassemble-all 
与 -d 类似,但反汇编所有section.