Professional Documents
Culture Documents
c. Ci t Cross-compiler i. Yu cu: ci t gcc-3.x trn h iu hnh Linux ii. Cc bc thc hin Gi s ang lm vic ti th mc /root To th mc lu bi tp h iu hnh % mkdir hdh Copy cc tp tin sau vo th mc hdh (c th dng WinSCP) binutils-2.11.2.tar.gz gcc-2.95.3.tar.gz Vo th mc hdh, gii nn cc tp tin ny % cd hdh % tar -xzvf binutils-2.11.2.tar.gz % tar xzvf gcc-2.95.3.tar.gz To th mc cha Cross-compiler s c ci t % mkdir cross-compiler Bin dch binutils trc % cd binutils-2.11.2/ % ./configure --host=i686-pc-linux-gnu --target=decstationultrix --prefix=/root/hdh/cross-compiler % make % make install Ci t binutils thnh cng s to cc file sau trong th mc /root/hdh/cross-compiler/decstation-ultrix/bin/: ar as ld nm ranlib strip Lu , khng nn bin dch gcc ngay trong th mc cha m ngun (gcc-2.95.3). Do , trc khi tin hnh bin dch gcc, cn to th mc cha kt qu bin dch (th mc ny nn t cng cp vi th mc cross-compiler to trn).: % cd .. % mkdir gcc-obj V to th mc gi system-include % mkdir cross-compiler/decstation-ultrix/sys-include Vo th mc gcc-obj, thc hin cu hnh gcc % cd gcc-obj Khoa CNTT H Khoa Hc T Nhin
2 To Cross-compiler cho kin trc my MIPS
% ../gcc-2.95.3/configure --host=i686-pc-linux-gnu -target=decstation-ultrix --prefix=/root/hdh/cross-compiler --with-gnu-as --with-gnu-ld --with-as=/root/hdh/crosscompiler/decstation-ultrix/bin/as --with-ld=/root/hdh/crosscompiler/decstation-ultrix/bin/ld --enable-languages=c --disablemultilib --disable-libgcj Bin dch gcc % make Nu qu trnh bin dch c li to libgcc2.a th c thc hin tip ci t
(v Nachos khng ph thuc vo bt k th vin no)
% make -k install Ci t gcc thnh cng s to thm file gcc trong th mc /root/hdh/cross-compiler/decstation-ultrix/bin/ 3. Bin dch v ci t Nachos a. Yu cu ci t gcc-2.x hoc gcc-3.x trn Linux ci t thnh cng Cross-compiler b. Cc bc thc hin: Copy tp tin sau vo th mc hdh (c th dng WinSCP) nachos-3.4.tar.gz Gi s ang lm vic ti th mc /root Vo th mc hdh, gii nn cc tp tin ny % cd hdh % tar -xzvf nachos-3.4.tar.gz Trc khi bin dch Nachos, cn sa li trong file ~/nachos/code/test/Makefile ng dn ca Cross-compiler (GCCDIR) ti th mc cha Cross-compiler ci t thnh cng bc trn (/root/hdh/cross-compiler/decstation-ultrix/bin/). Hon ton c th copy th mc cross-compiler/decstation-ultrix/ v th mc cha m ngun Nachos nachos-3.4 ti my khc bin dch Nachos m khng cn bin dch li Cross-compiler. Thng 2 th mc ny cng cp vi nhau nn khi chnh ng dn ti Crosscompiler c th ng dn tng i nh sau: # if you are cross-compiling, you need to point to the right # executables and change the flags to ld and the build Khoa CNTT H Khoa Hc T Nhin
3
GCCDIR = ../../../cross-compiler/decstation-ultrix/bin/ LDFLAGS = -T script -N ASFLAGS = -mips2 CPPFLAGS = $(INCDIR) # if you aren't cross-compiling: # GCCDIR = # LDFLAGS = -N -T 0 # ASFLAGS = # CPPFLAGS = -P $(INCDIR) PATH = $(GCCDIR):/lib:/usr/bin:/bin CC = $(GCCDIR)gcc -B../../../cross-compiler/ AS = $(GCCDIR)as LD = $(GCCDIR)ld CPP = gcc -E INCDIR =-I../userprog -I../threads CFLAGS = -G 0 -c $(INCDIR) Bin dch Nachos % cd nachos-3.4/code % gmake all 4. Chy th chng trnh trn Nachos % ./userprog/nachos rs 1023 x ./test/halt Kt qu nhn c: Machine halting! Ticks: total 42 idle 0, system 30, user 12 Disk I/O: reads 0, writes 0 Console I/O: reads 0, writes 0 Paging: faults 0 Network I/O: packets received 0, sent 0 Cleaning up Nu chy ra kt qu nh trn, ngha l thnh cng qu trnh ci t Nachos trn Linux
....Nhim v tip theo: Tm hiu hoat ng ca Nachos c th thm cc system call vo h iu hnh Nachos Tm hiu cc thnh phn c bn ca h iu hnh Nachos c xy dng xy dng cc thnh phn phc tp hn