Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1502911
  • 博文数量: 108
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 997
  • 用 户 组: 普通用户
  • 注册时间: 2013-06-29 09:58
个人简介

兴趣是坚持一件事永不衰竭的动力

文章分类

全部博文(108)

文章存档

2021年(1)

2020年(10)

2019年(19)

2018年(9)

2016年(23)

2015年(43)

2013年(3)

我的朋友

分类: 嵌入式

2019-04-16 16:30:28

linux源码包含了大量的头文件,又包宏定义的条件编译,给人工阅读可能带来困难,突然想起gcc -E 可以输出源文件展开所有头文件及宏后的预处理后的文件内容,当然,直接arm-linux-gnueabihf-gcc -E xxx.c肯定是不行的,会找不到头文件,这里借助顶层makefile 的 V=1 选项,将要包含的目录给打印出来

例如,想要看 arch/arm/boot/compressed/head.S预处理后是什么样子
第一步
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage -j4 V=1

然后找到编译 arch/arm/boot/compressed/head.o的那一条完整命令

arm-linux-gnueabihf-gcc -Wp,-MD,arch/arm/boot/compressed/.head.o.d  -nostdinc -isystem /home/fang/ti-processor-sdk-linux-am335x-evm-04.00.00.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/arm-linux-gnueabihf/6.2.1/include -I./arch/arm/include -I./arch/arm/include/generated/uapi -I./arch/arm/include/generated  -I./include -I./arch/arm/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -D__ASSEMBLY__ -fno-PIE -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -marm -D__LINUX_ARM_ARCH__=7 -march=armv7-a -include asm/unified.h -msoft-float -DCC_HAVE_ASM_GOTO -DZIMAGE -DTEXT_OFFSET=0x00008000   -c -o arch/arm/boot/compressed/head.o arch/arm/boot/compressed/head.S
第二步:应用-E选项
将上面的完整命令,改一改
arm-linux-gnueabihf-gcc  -nostdinc -isystem /home/fang/ti-processor-sdk-linux-am335x-evm-04.00.00.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/arm-linux-gnueabihf/6.2.1/include -I./arch/arm/include -I./arch/arm/include/generated/uapi -I./arch/arm/include/generated  -I./include -I./arch/arm/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -D__ASSEMBLY__ -fno-PIE -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -marm -D__LINUX_ARM_ARCH__=7 -march=armv7-a -include asm/unified.h -msoft-float -DCC_HAVE_ASM_GOTO -DZIMAGE -DTEXT_OFFSET=0x00008000   -E arch/arm/boot/compressed/head.S -o arch/arm/boot/compressed/head.i
这样,arch/arm/boot/compressed/head.i就是预处理head.S后的内容了

阅读(210170) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~