LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1057|回复: 0

求助:如何用-O0优化级别编译Linux内核?

[复制链接]
发表于 2010-4-15 16:34:08 | 显示全部楼层 |阅读模式
我想调试嵌入式Linux内核源码,发现代码执行顺序与源码不太一致,根据经验,这应该是打开优化选项的结果,于是我想关闭优化编译Linux内核,也就是将内核的编译选项 -O2 改为 -O0,我直接修改了内核源码顶层目录下 Makefile 文件的 525 行(嵌入式Linux是montavista pro 4.0.1,上位机是Fedora12,编译器是arm_v5t_le-gcc):
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
#CFLAGS    += -Os
CFLAGS      += -O0
else
#CFLAGS    += -O2
CFLAGS      += -O0
endif
其中注释掉到是原来的,注释下面是我改动的地方,也就是只是将-Os和-O2改成-O0而已。
修改了Makefile之后,重新编译内核出现很多错误,错误信息在后面。
错误信息中提到的那些未定义标号肯定是定义过的,因为用-O2或者-O1优化选项都能够顺利编译通过,那么仅仅修改了优化级别,为什么结果就不一样了呢?
希望高手解答啊 !!

以下是编译错误:
[hugeice@rdserver ti-davinci]$ make ARCH=arm CROSS_COMPILE=arm_v5t_le- uImage
  CHK    include/linux/version.h
  SPLIT  include/linux/autoconf.h -> include/config/*
  SYMLINK include/asm-arm/arch -> include/asm-arm/arch-davinci
make[1]: `arch/arm/kernel/asm-offsets.s' is up to date.
make[1]: `include/asm-arm/mach-types.h' is up to date.
  CHK    include/linux/compile.h
  UPD    include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  CHK    usr/initramfs_list
  GEN    .version
  CHK    include/linux/compile.h
dnsdomainname: 未知的主机
  UPD    include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
init/built-in.o(.init.text+0x1e8c): In function `identify_ramdisk_image':
init/do_mounts_rd.c:92: undefined reference to `ntohl'
arch/arm/mm/built-in.o(.text+0x1624): In function `adjust_pte':
arch/arm/mm/fault-armv.c:77: undefined reference to `cpu_tlb'
arch/arm/mm/built-in.o(.text+0x2360): In function `do_translation_fault':
arch/arm/mm/fault.c:363: undefined reference to `cpu_tlb'
arch/arm/mm/built-in.o(.text+0x3c44): In function `free_pgd_slow':
arch/arm/mm/mm-armv.c:249: undefined reference to `cpu_tlb'
arch/arm/mm/built-in.o(.text+0x3de4): In function `setup_mm_for_reboot':
arch/arm/mm/mm-armv.c:590: undefined reference to `cpu_tlb'
arch/arm/mm/built-in.o(.init.text+0x1414): In function `paging_init':
arch/arm/mm/init.c:519: undefined reference to `cpu_tlb'
arch/arm/mm/built-in.o(.init.text+0x2734):arch/arm/mm/mm-armv.c:559: more undefined references to `cpu_tlb' follow
fs/built-in.o(.text+0xf2460): In function `xdr_decode_fattr':
fs/nfs/nfs2xdr.c:125: undefined reference to `ntohl'
fs/built-in.o(.text+0xf2480)s/nfs/nfs2xdr.c:126: undefined reference to `ntohl'
fs/built-in.o(.text+0xf24a0)s/nfs/nfs2xdr.c:127: undefined reference to `ntohl'
fs/built-in.o(.text+0xf24c0)s/nfs/nfs2xdr.c:128: undefined reference to `ntohl'
fs/built-in.o(.text+0xf24e0)s/nfs/nfs2xdr.c:129: undefined reference to `ntohl'
fs/built-in.o(.text+0xf2500)s/nfs/nfs2xdr.c:130: more undefined references to `ntohl' follow
fs/built-in.o(.text+0xf2958): In function `nfs_xdr_sattrargs':
fs/nfs/nfs2xdr.c:155: undefined reference to `htonl'
fs/built-in.o(.text+0xf29ac):fs/nfs/nfs2xdr.c:156: undefined reference to `htonl'
fs/built-in.o(.text+0xf2a00):fs/nfs/nfs2xdr.c:157: undefined reference to `htonl'
fs/built-in.o(.text+0xf2a54):fs/nfs/nfs2xdr.c:158: undefined reference to `htonl'
fs/built-in.o(.text+0xf2aa8):fs/nfs/nfs2xdr.c9: undefined reference to `htonl'
fs/built-in.o(.text+0xf2b04):fs/nfs/nfs2xdr.c:91: more undefined references to `htonl' follow
……
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表