首页 > 解决方案 > 在将 linux 内核编译为旧版本(2.6.11)时,我被卡住了

问题描述

我是学习linux内核的新手,我收到了一份作业。

我正在尝试编译旧的 linux kernel=2.6.11 并遇到一些错误。当前环境如下:

distro: ubuntu 14.04 64bit
kernel: 4.4.0
gcc: 4.8.4
binutils: 2.24

我将 menuconfig 设置为默认值并尝试了我的第一次编译,我遇到了以下错误:

scripts/kconfig/mconf arch/x86_64/Kconfig
#
# using defaults found in .config
#


*** End of Linux kernel configuration.
*** Execute 'make' to build the kernel or try 'make help'.

ilak@ilak-vm:~/workspace/linux-2.6.11$ make
  CHK     include/linux/version.h
  SPLIT   include/linux/autoconf.h -> include/config/*
make[1]: `arch/x86_64/kernel/asm-offsets.s' is up to date.
  CHK     include/asm-x86_64/offset.h
  CHK     include/linux/compile.h
  CHK     usr/initramfs_list
  CC      arch/x86_64/kernel/process.o
In file included from include/asm/smp.h:18:0,
                 from include/linux/smp.h:19,
                 from include/linux/sched.h:25,
                 from arch/x86_64/kernel/process.c:22:
include/asm/mpspec.h:79:2: warning: ‘packed’ attribute ignored for field of type ‘unsigned char[6]’ [-Wattributes]
  unsigned char mpc_bustype[6] __attribute((packed));
  ^
In file included from include/asm/processor.h:19:0,
                 from include/linux/spinlock.h:16,
                 from include/linux/capability.h:45,
                 from include/linux/sched.h:7,
                 from arch/x86_64/kernel/process.c:22:
include/asm/apic.h: In function ‘apic_write_atomic’:
include/asm/system.h:185:22: warning: value computed is not used [-Wunused-value]
 #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
                      ^
include/asm/apic.h:47:2: note: in expansion of macro ‘xchg’
  xchg((volatile unsigned int *)(APIC_BASE+reg), v);
  ^
In file included from include/asm/mmu_context.h:5:0,
                 from arch/x86_64/kernel/process.c:43:
arch/x86_64/kernel/process.c: At top level:
include/asm/desc.h:202:2: warning: ‘set_ldt_desc’ is static but used in inline function ‘load_LDT_nolock’ which is not static [enabled by default]
  set_ldt_desc(cpu, pc->ldt, count);
  ^
In file included from arch/x86_64/kernel/process.c:37:0:
include/asm/uaccess.h:47:39: warning: ‘current_thread_info’ is static but used in inline function ‘verify_area’ which is not static [enabled by default]
   :"1" (addr),"g" ((long)(size)),"g" (current_thread_info()->addr_limit.seg)); \
                                       ^
include/asm/uaccess.h:50:38: note: in expansion of macro ‘__range_not_ok’
 #define access_ok(type, addr, size) (__range_not_ok(addr,size) == 0)
                                      ^
include/asm/uaccess.h:54:9: note: in expansion of macro ‘access_ok’
  return access_ok(type,addr,size) ? 0 : -EFAULT;
         ^
In file included from include/linux/mm.h:36:0,
                 from arch/x86_64/kernel/process.c:24:
include/asm/pgtable.h:264:46: warning: ‘set_pte’ is static but used in inline function ‘pte_mkwrite’ which is not static [enabled by default]
 extern inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
                                              ^
include/asm/pgtable.h:263:46: warning: ‘set_pte’ is static but used in inline function ‘pte_mkyoung’ which is not static [enabled by default]
 extern inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
                                              ^
include/asm/pgtable.h:262:46: warning: ‘set_pte’ is static but used in inline function ‘pte_mkdirty’ which is not static [enabled by default]
 extern inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
                                              ^
include/asm/pgtable.h:261:45: warning: ‘set_pte’ is static but used in inline function ‘pte_mkexec’ which is not static [enabled by default]
 extern inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
                                             ^
include/asm/pgtable.h:260:45: warning: ‘set_pte’ is static but used in inline function ‘pte_mkread’ which is not static [enabled by default]
 extern inline pte_t pte_mkread(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
                                             ^
include/asm/pgtable.h:259:48: warning: ‘set_pte’ is static but used in inline function ‘pte_wrprotect’ which is not static [enabled by default]
 extern inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; }
                                                ^
include/asm/pgtable.h:258:44: warning: ‘set_pte’ is static but used in inline function ‘pte_mkold’ which is not static [enabled by default]
 extern inline pte_t pte_mkold(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; }
                                            ^
include/asm/pgtable.h:257:46: warning: ‘set_pte’ is static but used in inline function ‘pte_mkclean’ which is not static [enabled by default]
 extern inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
                                              ^
include/asm/pgtable.h:256:48: warning: ‘set_pte’ is static but used in inline function ‘pte_exprotect’ which is not static [enabled by default]
 extern inline pte_t pte_exprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
                                                ^
include/asm/pgtable.h:255:48: warning: ‘set_pte’ is static but used in inline function ‘pte_rdprotect’ which is not static [enabled by default]
 extern inline pte_t pte_rdprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
                                                ^
include/asm/pgtable.h:99:2: warning: ‘set_pgd’ is static but used in inline function ‘pgd_clear’ which is not static [enabled by default]
  set_pgd(pgd, __pgd(0));
  ^
include/asm/pgtable.h:89:2: warning: ‘set_pud’ is static but used in inline function ‘pud_clear’ which is not static [enabled by default]
  set_pud(pud, __pud(0));
  ^
arch/x86_64/kernel/process.c: Assembler messages:
arch/x86_64/kernel/process.c:459: Error: unsupported instruction `mov'
arch/x86_64/kernel/process.c:463: Error: unsupported instruction `mov'
arch/x86_64/kernel/process.c:393: Error: unsupported instruction `mov'
arch/x86_64/kernel/process.c:394: Error: unsupported instruction `mov'
arch/x86_64/kernel/process.c:395: Error: unsupported instruction `mov'
arch/x86_64/kernel/process.c:396: Error: unsupported instruction `mov'
make[1]: *** [arch/x86_64/kernel/process.o] Error 1
make: *** [arch/x86_64/kernel] Error 2

在 Google 上搜索了一些信息后,我认为 binutils 可能是问题所在,并尝试了一些方法,但似乎没有帮助。

怎么回事,编译旧内核版本需要什么?

提前谢谢

标签: linuxcompilationkernel

解决方案


推荐阅读