1. (arm-linux-)gcc编译过程
预处理: 处理以“#”开头的行
(arm-linux-)gcc -E hello.c -o hello.i
编译: compiling C->asm, 会根据语法规则把C代码编译成相应的汇编代码
(arm-linux-)gcc -S hello.i(.c) -o hello.s
汇编: assembling 根据语法规则把汇编程序编译成相应的机器指令(0101)
(arm-linux-)gcc -c hello.s -o hello.o
or
(arm-linux-)as hello.s -o hello.o
链接:linking, ld,装入,解决冲突(重定位)
(arm-linux-)ld -Ttext=30008000 hello.o a.o b.o -o hello
arm-linux-gcc hello.s
2. gdb调试
gcc -g hello.c -o hello
gdb hello
gdb调试命令
(gdb)b
breakpoint 断点,设置断点info
“断点”:运行在此处,就暂停
b 行号
b 符号(函数名,语句标号)
设置多个断点
(gdb) info b
information of breakpoints
查看断点信息
(gdb) r
runnihelp ng
运行代码
(gdb) l
list
查看文件
(gdb) p n
print
输出变量n的值
(gdb) n
next
单步运行
n与s的命令,仅在当前行为子函数调用时,
n把子函数调用当作是一条语句,
s(step)进入子函数中执行
(gdb) s
step
单步运行
(gdb) chh
continue
恢复程序运行
(gdb) quit
退出
(gdb) help command
帮助
预处理: 处理以“#”开头的行
(arm-linux-)gcc -E hello.c -o hello.i
编译: compiling C->asm, 会根据语法规则把C代码编译成相应的汇编代码
(arm-linux-)gcc -S hello.i(.c) -o hello.s
汇编: assembling 根据语法规则把汇编程序编译成相应的机器指令(0101)
(arm-linux-)gcc -c hello.s -o hello.o
or
(arm-linux-)as hello.s -o hello.o
链接:linking, ld,装入,解决冲突(重定位)
(arm-linux-)ld -Ttext=30008000 hello.o a.o b.o -o hello
arm-linux-gcc hello.s
2. gdb调试
gcc -g hello.c -o hello
gdb hello
gdb调试命令
(gdb)b
breakpoint 断点,设置断点info
“断点”:运行在此处,就暂停
b 行号
b 符号(函数名,语句标号)
设置多个断点
(gdb) info b
information of breakpoints
查看断点信息
(gdb) r
runnihelp ng
运行代码
(gdb) l
list
查看文件
(gdb) p n
输出变量n的值
(gdb) n
next
单步运行
n与s的命令,仅在当前行为子函数调用时,
n把子函数调用当作是一条语句,
s(step)进入子函数中执行
(gdb) s
step
单步运行
(gdb) chh
continue
恢复程序运行
(gdb) quit
退出
(gdb) help command
帮助