ubuntu編譯linux kernel v2.6.30 各種錯誤排除


一、資源准備

1、下載一個較穩定的老版本,2.6.30, 並解壓源碼:

1 wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.tar.xz
2 tar Jxf linux-2.6.30.tar.xz
3 cd linux-2.6.30/

 

2、生成基本的配置信息:

make defconfig

  

二、工具配置

接下來要對內核默認配置文件進行修改,有3中方式,gconfig、xconfig和menuconfig, 分別依賴與gtk+2.0、qt3和libncurses5-dev。 通過相應命令安裝依賴的包后,就可一進行配置了;

1、使用menuconfig進行配置

1 sudo apt-get install libncurses5-dev
2 make menuconfig

 

2、使用gconfig進行配置

make gconfig
*
* Unable to find the GTK+ installation. Please make sure that
* the GTK+ 2.0 development package is correctly installed...
* You need gtk+-2.0, glib-2.0 and libglade-2.0.
*
make[1]: *** No rule to make target `scripts/kconfig/.tmp_gtkcheck', needed by `scripts/kconfig/gconf.o'.  Stop.
make: *** [gconfig] Error 2

需要安裝以下軟件包,然后重新開始:

1 sudo apt-get install libgtk2.0-dev libglib2.0-dev libglade2-dev
2 make gconfig

 

3、使用xconfig進行配置

這個對qt3依賴,已經安裝了qt3-dev-tools也不行呢,沒有找到解決方案,所以放棄折騰了;誰有好方法解決請告知哇。

$make gconfig
  HOSTCC  scripts/kconfig/gconf.o
In file included from /usr/include/gtk-2.0/gtk/gtk.h:236:0,
                 from /usr/include/libglade-2.0/glade/glade-xml.h:26,
                 from /usr/include/libglade-2.0/glade/glade.h:28,
                 from scripts/kconfig/gconf.c:16:
/usr/include/gtk-2.0/gtk/gtkitemfactory.h:47:1: warning: function declaration isn’t a prototype
scripts/kconfig/gconf.c: In function ‘text_insert_help’:
scripts/kconfig/gconf.c:469:3: warning: format not a string literal and no format arguments
scripts/kconfig/gconf.c: In function ‘on_introduction1_activate’:
scripts/kconfig/gconf.c:754:6: warning: format not a string literal and no format arguments
scripts/kconfig/gconf.c: In function ‘on_about1_activate’:
scripts/kconfig/gconf.c:772:6: warning: format not a string literal and no format arguments
scripts/kconfig/gconf.c: In function ‘on_license1_activate’:
scripts/kconfig/gconf.c:791:6: warning: format not a string literal and no format arguments
scripts/kconfig/gconf.c: At top level:
scripts/kconfig/images.c:6:20: warning: ‘xpm_load’ defined but not used
scripts/kconfig/images.c:36:20: warning: ‘xpm_save’ defined but not used
scripts/kconfig/images.c:66:20: warning: ‘xpm_back’ defined but not used
scripts/kconfig/images.c:175:20: warning: ‘xpm_symbol_no’ defined but not used
scripts/kconfig/images.c:192:20: warning: ‘xpm_symbol_mod’ defined but not used
scripts/kconfig/images.c:209:20: warning: ‘xpm_symbol_yes’ defined but not used
scripts/kconfig/images.c:226:20: warning: ‘xpm_choice_no’ defined but not used
scripts/kconfig/images.c:243:20: warning: ‘xpm_choice_yes’ defined but not used
scripts/kconfig/images.c:277:20: warning: ‘xpm_menu_inv’ defined but not used
scripts/kconfig/images.c:294:20: warning: ‘xpm_menuback’ defined but not used
scripts/kconfig/gconf.c:957:13: warning: ‘renderer_toggled’ defined but not used
  HOSTLD  scripts/kconfig/gconf
scripts/kconfig/gconf arch/x86/Kconfig

 

 

三、錯誤排除

1、出現錯誤syscall_trace_leave

arch/x86/include/asm/ptrace.h:146:13: note: previous declaration of 'syscall_trace_leave' was here
make[2]: *** [arch/x86/kernel/ptrace.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2

解決方案參考這個補丁: https://patchwork.kernel.org/patch/1301031/

Patch

--- linux-2.6.32.59/arch/x86/include/asm/ptrace.h
+++ fix_ptrace.o_compile_error/arch/x86/include/asm/ptrace.h
@@ -130,6 +130,7 @@ 
 #ifdef __KERNEL__
 
 #include <linux/init.h>
+#include <linux/linkage.h>
 
 struct cpuinfo_x86;
 struct task_struct;
@@ -142,8 +143,8 @@ 
              int error_code, int si_code);
 void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
 
-extern long syscall_trace_enter(struct pt_regs *);
-extern void syscall_trace_leave(struct pt_regs *);
+extern asmregparm long syscall_trace_enter(struct pt_regs *);
+extern asmregparm void syscall_trace_leave(struct pt_regs *);
 
 static inline unsigned long regs_return_value(struct pt_regs *regs)
 {

 

2、錯誤gcc不識別-m參數

gcc: error: unrecognized command line option ‘-m’
gcc: error: elf_i386: No such file or directory
make[1]: *** [arch/x86/vdso/vdso32-int80.so.dbg] Error 1

由於我現在用的是ubuntu 12.10 使用的是gcc-4.7,發現了一個新版本的移植的問題,所以安裝gcc-4.5,然后重新鏈接就搞定了,可以繼續編譯:

sudo apt-get install gcc-4.5
cd /usr/bin
sudo ln -s -f gcc-4.5 gcc

繼續編譯中:

#使用-j4指定4個線程編譯
make -j4

 

四、編譯成功

基本使用的默認設置,就是第一步的make defconfig后的配置參數,然后make -j4,好像編譯的挺快的,后面在詳細研究以下各種參數,已經如何啟用這個自己編譯的內核 :)。

  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-x86
  CALL    scripts/checksyscalls.sh
  CHK     include/linux/compile.h
  VDSOSYM arch/x86/vdso/vdso32-int80-syms.lds
  VDSOSYM arch/x86/vdso/vdso32-sysenter-syms.lds
  VDSOSYM arch/x86/vdso/vdso32-syms.lds
  LD      arch/x86/vdso/built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
WARNING: modpost: Found 3 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
  GEN     .version
  CHK     include/linux/compile.h
  UPD     include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
  KSYM    .tmp_kallsyms1.S
  AS      .tmp_kallsyms1.o
  LD      .tmp_vmlinux2
  KSYM    .tmp_kallsyms2.S
  AS      .tmp_kallsyms2.o
  LD      .tmp_vmlinux3
  KSYM    .tmp_kallsyms3.S
  AS      .tmp_kallsyms3.o
  LD      vmlinux
  SYSMAP  System.map
  SYSMAP  .tmp_System.map
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  GZIP    arch/x86/boot/compressed/vmlinux.bin.gz
  LD      arch/x86/boot/compressed/piggy.o
  LD      arch/x86/boot/compressed/vmlinux
  OFFSETS arch/x86/boot/offsets.h
  AS      arch/x86/boot/header.o
  CC      arch/x86/boot/version.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  BUILD   arch/x86/boot/bzImage
Root device is (8, 11)
Setup is 10060 bytes (padded to 10240 bytes).
System is 3539 kB
CRC d3a625ec
Kernel: arch/x86/boot/bzImage is ready  (#2)
  Building modules, stage 2.
  MODPOST 2 modules


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM