欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

编译linux2.6.24 博客分类: linux linux内核 

程序员文章站 2024-03-19 23:45:16
...
真是每个linux的小版本编译的时候都有不同的问题啊,
最近在看《独辟蹊径品内核》《linux2.6内核标准教程》
用到linux2.6.24.编译的问题汇总到这里
环境
[root@centos140_11 boot]# gcc --version
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@centos140_11 boot]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 
[root@centos140_11 boot]# 


https://www.kernel.org/pub/linux/kernel/v2.6/
下的2.6.24

解压后
设置menuconfig 选debug

make O=/home/haoning/rtclinux/websocket/web/jslinux/tmp/linux2.6.24.build/kernel/ menuconfig


开始编译:
time make O=/home/haoning/rtclinux/websocket/web/jslinux/tmp/linux2.6.24.build/kernel/ -j10

遇到问题:

错误1
参考
http://blog.sina.com.cn/s/blog_8f9cdbbd01014lxj.html

arch/x86/vdso/Makefile
 19 quiet_cmd_syscall = SYSCALL $@
 20       cmd_syscall = $(CC) -m elf_x86_64 -nostdlib $(SYSCFLAGS_$(@F)) \
 21                   -Wl,-T,$(filter-out FORCE,$^) -o $@


-m elf_x86_64 换成 -m64

-----------------------------------------------
错误2:
/tmp/cct0Bawg.s: Assembler messages:
/tmp/cct0Bawg.s: Error: .size expression for copy_user_generic_c does not evaluate to a constant
make[2]: *** [arch/x86/lib/copy_user_64.o] Error 1
make[1]: *** [arch/x86/lib] Error 2
make: *** [sub-make] Error 2


参考
http://*.com/questions/23194840/linux-2-6-24-kernel-compilation-error-size-expression-for-copy-user-generic-c-d

arch/x86/lib/copy_user_64.S
347 END(copy_user_generic_c)
348 
349     .section __ex_table,"a"
350     .quad 1b,3b
351     .quad 2b,5b
换成
347 END(copy_user_generic_c)
348 
349     .section __ex_table,"a"
350     .quad 1b,3b
351     .quad 2b,5b


-----------------------------
错误3:

kernel/built-in.o: In function `mutex_lock':
/home/haoning/rtclinux/websocket/web/jslinux/tmp/linux-2.6.24/kernel/mutex.c:92: undefined reference to `__mutex_lock_slowpath'
kernel/built-in.o: In function `mutex_unlock':
/home/haoning/rtclinux/websocket/web/jslinux/tmp/linux-2.6.24/kernel/mutex.c:118: undefined reference to `__mutex_unlock_slowpath'
make[1]: *** [.tmp_vmlinux1] Error 1
make: *** [sub-make] Error 2


kernel/mutex.c
这个好使,其他的都是扯淡,什么该config参数,什么加__used都不行,需要把static去掉,加锁和解锁的
https://github.com/socketpair/jslinux_reversed/blob/master/contrib/patches/2.6.20_common_fixes.patch
__mutex_lock_slowpath的两个方法的static去掉
__mutex_unlock_slowpath的两个方法的static去掉

-----------------------------------------
错误4:
/scripts/unifdef.c:70:0:
/usr/include/stdio.h:678:20: note: previous declaration of ‘getline’ was here


解决:
scripts/unifdef.c
207 static int              findsym(const char *);
208 static void             flushline(bool);
209 //static Linetype         getline(void);
210 static Linetype         mygetline(void);
211 static Linetype         ifeval(const char **);
212 static void             ignoreoff(void);

511     Linetype lineval;
512 
513     for (;;) {
514         linenum++;
515         //lineval = getline();
516         lineval = mygetline();
517         trans_table[ifstate[depth]][lineval]();
518         debug("process %s -> %s depth %d",
519             linetype_name[lineval],
520             ifstate_name[ifstate[depth]], depth);
521     }
522 }
523 
524 /*
525  * Parse a line and determine its type. We keep the preprocessor line
526  * parser state between calls in the global variable linestate, with
527  * help from skipcomment().
528  */
529 static Linetype
530 //getline(void)
531 mygetline(void)
532 {   
533     const char *cp;
534     int cursym;
535     int kwlen;
相关标签: linux 内核