linux0.12 compilation process

Source: Internet
Author: User
Tags unsupported

Thanks for the http://www.cnblogs.com/strugglesometimes/p/4231359.html of this article

Compilation is a very painful thing, I want to put linux0.12 on the Bochs run up and then you can learn the modules, did not think of various problems.

Question 1:

1 gas-c-o boot/head.o boot/head.s2 make:gas:Command not found 

Gas is obsolete and will all makfile gas-

Specific Solutions

1 msed gas as

MSEd is a simple shell function, specifically defined in the portal below.

Portal: http://www.cnblogs.com/strugglesometimes/p/4231348.html

Question 2:

1 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 suffixFor ' push‘6 boot/Head.s:137:error:invalid instruction suffixFor ' push‘7 boot/Head.s:138:error:invalid instruction suffixFor ' push‘8 boot/Head.s:139:error:invalid instruction suffixFor ' push‘9 boot/Head.s:140:error:invalid instruction suffixFor ' push‘Ten boot/Head.s:151:error:invalid instruction suffixFor ' push‘boot/Head.s:152:error:invalid instruction suffixFor ' push‘boot/Head.s:153:error:invalid instruction suffixFor ' push‘boot/Head.s:154:error:operand Type mismatchFor ' push‘boot/Head.s:155:error:operand Type mismatchFor ' push‘boot/Head.s:161:error:invalid instruction suffixFor ' push‘boot/Head.s:163:error:invalid instruction suffixFor ' pop‘boot/Head.s:165:error:operand Type mismatchFor ' pop‘boot/Head.s:166:error:operand Type mismatchFor ' pop‘boot/Head.s:167:error:invalid instruction suffixFor ' pop‘boot/Head.s:168:error:invalid instruction suffixfor ' Pop 21 Boot/head.s:169:error:invalid instruction suffix for "pop< Span style= "color: #800000;" > '  ' 23 boot/head.s:215:error:unsupported instruction ' Mov "24 boot/head.s:217:error:unsupported instruction " Mov '  

This is due to the compiler on the 64-bit machine, we need to tell the compiler that we are going to compile the 32-bit code, add--32,cflags in the-m32 after all makefile as

Specific Solutions

msed as$ as\--32
Msed-o-o\-m32

Question 3:

boot/heads:assembler messages:boot/Head.s:2 Make: * * * [boot/1     

Put align N-align 2^n

Specific Solutions

's/align 2/align 4/g' boot/head. s's/align 3/align 8/g' boot/head.s   

Question 4:

gcc:error:unrecognized command line option '-fcombine-regs 'gcc:error:unrecognized command line option '-mstr Ing-insns ' 

Remove the two, and now GCC doesn't support it.

Specific Solutions

msed-fcombine-

Question 5:

The amount .... In order to find the error more quickly, I turned off all the warning. That is, add-W in Cflags

Specific Solutions

Msed-wall-W

Question 6:

InchFile included from INIT/MAIN.C:8:0: init/main.c:23:29:error:static declaration of ' fork ' follows non-Static declaration static inline _syscall0 (Int, fork) ^Include/unistd.h:151:6:note:InchDefinition of macro ' _syscall0 ' type name (void) ^INIT/MAIN.C:24:29:error:static declaration of ' pause ' follows non-Static declaration static inline _syscall0 (Int, pause) ^Include/unistd.h:151:6:note:InchDefinition of macro ' _syscall0 ' type name (void) ^Include/unistd.h:241:5: note:previous declaration of ' pause ' is hereIntPause (void); ^INIT/MAIN.C:26:29:error:static declaration of ' sync ' follows Non-static declaration static inline _syscall0 (int,syncinclude/ Unistd.h:151:6:note:  In definition of macro ' _syscall0 ' type name (void) ^252:5:note:previous Declaration of " syncint sync (void);                

This is because Include/unistd.h declares a pause () sync () fork (), and in Main.c, the three functions are defined by a macro, but there is a static limit defined, which is different from the declaration, so an error occurs. So just remove the unistd.h from the statement.

Question 7:

INIT/MAIN.C:179:12:error:static declaration of ' printf ' follows non-char *fmt, ...)   

This problem has been troubling for a long time, the online solution is to remove the static, but to do so, there will be another error in the link after the undefined reference to ' _put '. The new problem is that GCC is optimized for printf, which optimizes the non-parametric printf to put, and the linux0.12 libc does not implement put to cause new problems. So now back to this question, speculation should also be due to the GCC itself on the function name of printf due to special care, so the printf slightly changed the name, printf-printw. The discovery sure did compile the pass.

Specific solutions:

's/printf/printw/g' init/main.c 

Question 8:

function ' main ': init/main.c:176:3: Error: ' asm ' operand has impossible constraints   __asm__ (" int $0x80"::"a"(__nr_pause):"ax");       

Similar problems occur in the subsequent compilation of many, C-embedded Assembly format __asm__ (assembly statement: Input Register: Output register: May be modified register), the latest GCC specified input or output register can not appear in the register may be modified, The current way to see the Internet is to delete all the possible modified registers for all similar problems .

Specific Solutions

's/:\ ' \w\{2\}\ "\ (, \" \w\{2\}\ "\) *)/:)/g' {} \; 

Question 9:

make[1]: Gld:command not found

With gas, put GLD---LD

Specific Solutions

Ld

Question 10:

ld -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.o
     
      ld:relocatable linking with relocations from format elf32-i386 (SCHED.O) to format elf64-x86-+
      (KERNEL.O) is not s upported  
     

With question 2, tell LD to 32-bit link, add-M elf_i386 after the LD command

Specific Solutions

ld\-m\ elf_i386

Question 11:

.. /include/asm/Segment.h:assembler messages:.. /include/asm/segment.h:27:error:bad register name '%sil'  

Go to segment.h the 27th line to find, did not find SIL related things, according to the method of the Internet, the =r or R to =q or Q, sure enough, this should be caused by the compiler, R for any register, in the compile time with the SIL this register, but why the invalid will be used to it. Q means using any one of the Eax,ebx,ecx,edx.

Specific Solutions

Sed-i s'/R "/q"/g' include/asm/segment.h  

Question 12:

function ' copy_strings ': exec.c:162: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] =      long *0;    

The above is the original code, the following is OK code

if ((!page[p/page_size]) &&                                                                                                          ! ( Page[p/page_size] =      long *) get_free_page ()))                                                                                           0Else pag = (char *) page[p/page_ SIZE];     

Question 13:

File included from floppy.c:0: blk.h: All:#elif    

Here's #else #elif, line 90th.

Question 14:

make[1]: Gar:command not found

Old question, Gar ar

Ar

Question 15:

function ' malloc ': malloc.c:156:Error:lvalue: Required as leftoperand of assignment   CP = get_ Free_page ();    

and problem 121 like

Bdesc->page = Bdesc->freeptr = (void *) CP = Get_free_page ();

The above is the original, the following is OK, the code is broken down just fine

CP = get_free_page (); bdesc->page = Bdesc->freeptr = (void *) CP; 

linux0.12 compilation process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.