📄 regen
字号:
.TLRegenerating System Software.AUCharles B. Haley.AUDennis. M. Ritchie.MH.SHIntroduction.PPThis document discusses how toassemble or compile various parts of the.UXsystem software.This may be necessary becausea command or library is accidentallydeleted or otherwisedestroyed;also, it may be desirable to install a modifiedversion of some command or library routine.A few commands dependto some degree on the current configurationof the system;thus in any new system modifications to some commandsare advisable.Most of the likely modificationsrelate to the standard disk devices containedin the system.For example, the df(1) (`disk free')command has built into it the names ofthe standardly present disk storage drives(e.g. `/dev/rf0', `/dev/rp0').Df(1) takes an argument to indicate whichdisk to examine, but it is convenientif its default argument is adjusted toreflect the ordinarily present devices.The companion document `Setting up UNIX'discusses which commands are likely to requirechanges..SHWhere Commands and Subroutines Live.PPThesource files for commands and subroutines residein several subdirectoriesof the directory /usr/src.These subdirectories, and a generaldescription of their contents, are.IP cmd 12Source files for commands..IP libc/stdio 12Source files making up the `standard i/o package'..IP libc/sys 12Source files for the C system call interfaces..IP libc/gen 12Source files for most of the remaining routines describedin section 3 of the manual..IP libc/crt 12Source files making up the C runtime support package, asin call save-return and long arithmetic..IP libc/csu 12Source for the C startup routines..IP games 12Source for (some of) the games.No great care has been taken to try to make it obvious howto compile these; treat it as a game..IP libF77 12Source for the Fortran 77 runtime library, exclusive of IO..IP libI77 12Source for the Fortran 77 IO runtime routines..IP libdbm 12Source for the `data-base manager' package.I dbm(3)..IP libfpsim 12Source for the floating-point simulator routine..IP libm 12Source for the mathematical library..IP libplot 12Source for plotting routines..SHCommands.PPThe regeneration of most commandsis straightforward.The `cmd' directory will contain either a source filefor the command or a subdirectory containing the setof files that make up the command.If it is a single file the command.DScd /usr/src/cmdcmake cmd_name.DEsuffices. (Cmd_name is the name of the command youare playing with.)The result of the cmake command will be an executable version.If you type.DScmake \-cp cmd_name.DEthe resultwill be copied to /bin(or perhaps /etc or other places if appropriate)..PPIf the source files are in a subdirectory there will be a `makefile'(see make(1)) to control the regeneration.After changing to the proper directory (cd(1)) you type one of the following:.IP "make all" 12The program is compiled and loaded; the executable isleft in the current directory..IP "make cp" 12The program is compiled and loaded, and the executable isinstalled.Everything is cleaned up afterwards;for example .o files are deleted..IP "make cmp" 12The program is compiled and loaded, and the executable is comparedagainst the one in /bin..PPSome of the makefiles have other options. Print (cat(1)) the ones youare interested in to find out..SHThe Assembler.PPThe assembler consists of two executable files:/bin/as and /lib/as2.The first is the 0-th pass:it reads the source program, converts it toan intermediate form in a temporary file `/tmp/atm0?',and estimates the final locationsof symbols.It also makes two or three other temporaryfiles which contain the ordinary symbol table,a table of temporary symbols (like 1:)and possibly an overflow intermediate file.The program /lib/as2acts as an ordinary multiple pass assemblerwith input taken from the files produced by /bin/as..PPThe source files for /bin/asare named `/usr/src/cmd/as/as1?.s'(there are 9 of them);/lib/as2 is producedfrom the source files`/usr/src/cmd/as/as2?.s';they likewise are 9 in number.Considerable care should be exercisedin replacing either component of theassembler.Remember that if the assembler is lost,the only recourse is to replace it from some backup storage;a broken assembler cannot assemble itself..SHThe C Compiler.PPThe C compiler consists ofseven routines:`/bin/cc',which calls the phases of the compiler proper,the compiler control line expander `/lib/cpp',the assembler (`as'), and the loader (`ld').The phases of the C compiler are`/lib/c0', which is the first phase of the compiler;`/lib/c1', which is the second phase of the compiler;and `/lib/c2', which is the optionalthird phase optimizer.The loss of the C compiler is as seriousas that of the assembler..PPThe source for /bin/ccresides in `/usr/src/cmd/cc.c'.Its loss alone (or that of c2) is not fatal.If needed,prog.c can be compiled by.DS/lib/cpp prog.c >temp0/lib/c0 temp0 temp1 temp2/lib/c1 temp1 temp2 temp3as \- temp3ld \-n /lib/crt0.o a.out \-lc.DE.PPThe source for the compiler proper is in thedirectory /usr/src/cmd/c.The first phase (/lib/c0)is generated from the files c00.c, ..., c05.c,which must be compiled by the C compiler.There is also c0.h, a header file.I includedby the C programs of the first phase.To make a new /lib/c0 use.DSmake c0.DEBefore installing the new c0, it is prudent to save the old one someplace..PPThe second phase of C (/lib/c1)is generated from the source files c10.c, ..., c13.c,the include-file c1.h, and a setof object-code tables combined into table.o.To generate a new second phase use.DSmake c1.DEIt is likewise prudent to save c1 beforeinstalling a new version.In fact in general it is wise to save theobject files for the C compiler so thatif disaster strikes C can be reconstitutedwithout a working version of the compiler..PPIn a similar manner,the third phase of the C compiler(/lib/c2)is made up from the filesc20.c and c21.c together with c2.h.Its loss is not critical since it is completely optional..PPThe set of tables mentioned aboveis generated from the filetable.s.This `.s' file is not in fact assembler source;it must be converted by use of the .I cvoptprogram, whose source and object arelocated in the C directory.Normally this is taken care of by make(1). Youmight want to look at the makefile to see what it does..SHUNIX.PPThe source and object programs for UNIX are kept infour subdirectories of.I /usr/sys.In the subdirectory .I hthere are several files ending in `.h';these are header files which arepicked up (via `#include ...')as required by each system module.The subdirectory.I devconsists mostly of the device driverstogether with a few other things.The subdirectory.I sysis the rest of the system.There are files of the form LIBx in the directoriessys and dev. These are archives (ar(1)) which contain theobject versions of the routines in the directory..PPSubdirectory.I confcontains the files which controldevice configuration of the system..I L.sspecifies thecontents of the interrupt vectors;.I c.ccontains the tables which relate device numbersto handler routines.A third file,.I mch.s ,contains all themachine-language code in the system.A fourth file,.I mch0.s ,is generated by mkconf(1) and containsflags indicating what sort of tape drive is availablefor taking crash dumps..PPThere are two ways to recreate the system. Use.DScd /usr/sys/conf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -