win2012服务器做网站,a站网址是什么,分类目录网站做谷歌联盟,网站快速优化感谢这篇文章的作者#xff1a; http://www.cnblogs.com/strugglesometimes/p/4231359.html编译是个很蛋疼的事情#xff0c;本想把linux0.12在bochs上跑起来然后就可以各模块的学习#xff0c;没想各种问题。问题1#xff1a;1 gas -c -o boot/head.o boot/head.s2 mak…感谢这篇文章的作者 http://www.cnblogs.com/strugglesometimes/p/4231359.html编译是个很蛋疼的事情本想把linux0.12在bochs上跑起来然后就可以各模块的学习没想各种问题。问题11 gas -c -o boot/head.o boot/head.s2 make: gas: Command not foundgas已过时将所有Makfile里gas - as具体解决方法msed 是个简单的shell 函数具体定义见下面的传送门。问题21 boot/head.s:43: Error: unsupported instruction mov‘2 boot/head.s:47: Error: unsupported instruction mov‘3 boot/head.s:59: Error: unsupported instruction mov‘4 boot/head.s:61: Error: unsupported instruction mov‘5 boot/head.s:136: Error: invalid instruction suffix for push‘6 boot/head.s:137: Error: invalid instruction suffix for push‘7 boot/head.s:138: Error: invalid instruction suffix for push‘8 boot/head.s:139: Error: invalid instruction suffix for push‘9 boot/head.s:140: Error: invalid instruction suffix for push‘10 boot/head.s:151: Error: invalid instruction suffix for push‘11 boot/head.s:152: Error: invalid instruction suffix for push‘12 boot/head.s:153: Error: invalid instruction suffix for push‘13 boot/head.s:154: Error: operand type mismatch for push‘14 boot/head.s:155: Error: operand type mismatch for push‘15 boot/head.s:161: Error: invalid instruction suffix for push‘16 boot/head.s:163: Error: invalid instruction suffix for pop‘17 boot/head.s:165: Error: operand type mismatch for pop‘18 boot/head.s:166: Error: operand type mismatch for pop‘19 boot/head.s:167: Error: invalid instruction suffix for pop‘20 boot/head.s:168: Error: invalid instruction suffix for pop‘21 boot/head.s:169: Error: invalid instruction suffix for pop‘22 boot/head.s:214: Error: unsupported instruction mov‘23 boot/head.s:215: Error: unsupported instruction mov‘24 boot/head.s:217: Error: unsupported instruction mov‘这是由于在64位机器上编译的原因需要告诉编译器我们要编译32位的code在所有Makefile的AS后面添加 --32CFLAGS中加-m32具体解决方法msed as$ as\ --32msed -O -O\ -m32问题3boot/head.s: Assembler messages:boot/head.s:231: Error: alignment not a power of 2make: *** [boot/head.o] Error 1把align n - align 2^n具体解决方法sed -i ‘s/align 2/align 4/g‘ boot/head.ssed -i ‘s/align 3/align 8/g‘ boot/head.s问题4gcc: error: unrecognized command line option ‘-fcombine-regs’gcc: error: unrecognized command line option ‘-mstring-insns’把这两个删掉即可现在GCC已经不支持了具体解决方法msed -fcombine-regs \msed -mstring-insns \问题5额。。。。为了更快的找到Error的地方我把所有的warning 都关掉了即在CFLAGS 中加-w具体解决方法msed -Wall -w问题6In file included from init/main.c:8:0:init/main.c:23:29: error: static declaration of ‘fork’ follows non-static declarationstatic inline _syscall0(int,fork)^include/unistd.h:151:6: note: indefinition of macro ‘_syscall0’type name(void) ^init/main.c:24:29: error: static declaration of ‘pause’ follows non-static declarationstatic inline _syscall0(int,pause)^include/unistd.h:151:6: note: indefinition of macro ‘_syscall0’type name(void) ^include/unistd.h:241:5: note: previous declaration of ‘pause’ was hereintpause(void);^init/main.c:26:29: error: static declaration of ‘sync’ follows non-static declarationstatic inline _syscall0(int,sync)^include/unistd.h:151:6: note: indefinition of macro ‘_syscall0’type name(void) ^include/unistd.h:252:5: note: previous declaration of ‘sync’ was hereint sync(void);这里是由于include/unistd.h 中声明了一次pause() sync() fork(), 而在main.c 中通过宏又定义了这三个函数但定义时多了static 限定与声明不同所以出错。所以直接把unistd.h中的声明去掉。问题7init/main.c:179:12: error: static declaration of ‘printf’ follows non-static declarationstatic int printf(const char *fmt, ...)这个问题困扰了好久网上的解决方案都是把static去掉但是这样做后面在链接的时候会出现另一个错误undefined reference to ‘_put‘. 新的问题是由于GCC会对printf进行优化把无参的printf优化成put而linux0.12的libc中又没有实现put才会导致新的问题。那么现在回到这个问题上猜测应该也是由于GCC本身对printf这个函数名有特别的关照所致所以把printf稍微改下名printf - printw。发现果然就编译通过了。具体解决方案sed -i ‘s/ printf/ printw/g‘ init/main.c问题8init/main.c: In function‘main’:init/main.c:176:3: error: ‘asm’ operand has impossible constraints__asm__(int $0x80::a (__NR_pause):ax);类似的问题在后面编译中出现好多C内嵌汇编的格式__asm__(汇编语句输入寄存器输出寄存器可能被修改的寄存器)最新的GCC规定输入或输出寄存器不能出现在可能被修改的寄存器中目前看到网上的方法是把所有类似问题的可能被修改的寄存器全部删掉。具体解决方法find -type f -exec sed -i ‘s/:\\w\{2\}\\(,\\w\{2\}\\)*)/:) /g‘ {} \;问题9make[1]: gld: Command not found同gas, 把gld - ld具体解决方法msed gld ld问题10ld -r -o kernel.o sched.o sys_call.o traps.o asm.o fork.o panic.o printk.o vsprintf.o sys.o exit.o signal.o mktime.old: Relocatable linking with relocations from format elf32-i386 (sched.o) to format elf64-x86-64 (kernel.o) is not supported同问题2告诉ld以32位链接在ld命令后面加 -m elf_i386具体解决方法msed ld$ ld\ -m\ elf_i386问题11../include/asm/segment.h: Assembler messages:../include/asm/segment.h:27: Error: bad register name %sil‘去segment.h 的第27行找没找到sil相关的东西根据网上的方法把r或r 改成q或q果然就好了这里应该是编译器造成的r表示任意寄存器在编译的时候就用了sil这个寄存器可为什么无效还会被用到呢。q表示使用eax,ebx,ecx,edx中任意一个。具体解决方法sed -i s‘/r/q/g‘ include/asm/segment.h问题12exec.c: In function‘copy_strings’:exec.c:162:44: error: lvalue required as left operand of assignment!(pag (char *) page[p/PAGE_SIZE] if (!(pag (char *) page[p/PAGE_SIZE]) !(pag (char *) page[p/PAGE_SIZE] (unsigned long *) get_free_page()))return 0;以上是原始code以下是OK的codeif ((!page[p/PAGE_SIZE]) !(page[p/PAGE_SIZE] (unsigned long *) get_free_page()))return 0;elsepag (char *) page[p/PAGE_SIZE];问题13In file included from floppy.c:42:0:blk.h:90:6: error: #elif with no expression#elif这里把第90行的#elif - #else问题14make[1]: gar: Command not found老问题了gar - armsed gar ar问题15malloc.c: In function‘malloc’:malloc.c:156:46: error: lvalue required as left operand of assignmentbdesc-page bdesc-freeptr (void *) cp get_free_page();和问题12一样bdesc-page bdesc-freeptr (void *) cp get_free_page();上面是原始的下面是OK的把代码拆分下就好cp get_free_page();bdesc-page bdesc-freeptr (void *) cp;原文http://www.cnblogs.com/welhzh/p/4521196.html