ld.1

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 1 代码 · 共 301 行

1
301
字号
.\" SCCSID: @(#)ld.1	3.1	11/23/87.TH ld 1 VAX.SH Nameld \- link editor.SH Syntax.B ld[\|\fIoption...\fR\|] \fIfile...\fR.SH Description.NXR "ld command".NXR "object file" "combining".NXS "link editor (general)" "ld command".NXAM "ld command" "ar file".NXAM "ld command" "a.out file".NXA "ld command" "strip command".NXA "ld command" "ranlib command".NXA "cc compiler" "ld command"The.PN ldcommand combines severalobject programs into one, resolves externalreferences, and searches libraries.In the simplest case, several object.I filesare given, and.PN ldcombines them, producingan object module which can either be executed orcan become the input for a further.PN ldrun.(In the latter case, the.B \-roption must be givento preserve the relocation bits.)The output of.PN ldis left on a.out.This file is only made executableif no errors occurred during the load..PPThe argument routines are linked together in the orderspecified.  The entry point of the output is thebeginning of the first routine, unless the \fB\-e\fP option is specified..PPIf the argument is a library, it is searched only onceat the point it is encountered in the argument list.Only those routines defining an unresolved externalreference are loaded.If a routine from a libraryreferences another routine in the library,and the library has not been processed by.MS ranlib 1 ,the referenced routine must appear after thereferencing routine in the library.Thus, the order of programs within librariesis important.The first member of a libraryshould be a file named __.SYMDEF,which is a dictionary for the library that is produced by.MS ranlib 1 .The dictionary is searched repeatedly to satisfy as many references as possible..PPThe symbols _etext, _edata and _end(etext, edata and end in C)are reserved and, if referred to,are set to the first location above the program,the first location above initialized data,and the first location above all data, in that order.It is an error to define these symbols..SH Options.NXR "ld command" "options"The .PN ldcommand has several options.Except for the.BR \-l option,they should appear before the file names..TP 10.B \-ASpecifies incremental loading.  Linking is done so that the resulting objectmay be read into an already executing program.The next argument is the name of a file whose symbol table isused to define additional symbols.Only newly linked material is entered into the text anddata portions of a.out,but the new symbol table reflectsevery symbol defined before and after the incremental load.This argument must appear before any other object file in the argument list..IPThe.B \-Toption may be used as well, and is taken to mean that thenewly linked segment commences at the corresponding address(which must be a multiple of 1024).The default value is the old value of _end..TP.B \-DTakes the next argument as a hexadecimal number and pads the data segmentwith zero bytes to the indicated length..TP .B  \-dForces definition of common storageeven if the.B \-rflag is present..TP.B \-eTakes the next argument as thename of the entry point of the loadedprogram; location 0 is the default..TP.BI \-L dirAdds.I dirto the list of directories that are searched for libraries.Directories specified with .B \-Lare searched before the standard directories..TP .BI \-l xAbbreviates the library name.RI lib x \&.a,where.I xis a string.The.PN ldcommand searches for libraries first in any directoriesspecified with.B \-Loptions, then in the standard directories /lib, /usr/lib, and/usr/local/lib.A library is searched when its name is encountered,so the placement of a.B \-lis significant..TP.B \-HTakes the next argument as a decimal integer, adds it to the endof text, and causes the data section to start at a higheraddress..TP.B \-MProduces a primitive load map, listing the names of the filesthat are loaded..TP.B \-NIndicates a portion of text to not make read-only or sharable.(Use magic number 0407.).TP .B  \-nArranges (by giving the output file a 0410 magic number) that the text portion is read-only and sharedamong all users executing the file when the output file isexecuted.  This involves moving the data areas up to the firstpossible 1024 byte boundary following theend of the text..TP .B  \-oTakes the .I nameargument after.B \-oas the name of the.PN ldoutput file, instead of a.out..TP .B \-rGenerates relocation bits in the output fileso that it can be the subject of another.PN ldrun.This flag also prevents final definitions from beinggiven to common symbolsand suppresses the undefined symbol diagnostics..TP.B \-SStrips the output by removing all symbols except locals and globals..TP .B  \-sRemoves the symbol tableand relocation bits to save space (this impairs theusefulness of the debuggers).This information can also be removed by.MS strip 1 ..TP.B \-TTakes the next argument as a hexadecimalnumber which sets the text segment origin.The default origin is 0..TP.BR \-t (trace)Prints the name of each file as it is processed..TP .B  \-uTakes the next argument as a symbol and entersit as undefined in the symbol table.  This is usefulfor loading from a library, since initially the symboltable is empty and an unresolved reference is neededto force the loading of the first routine..TP .B  \-XSaves local symbolsexcept for those whose names begin with a capital L.This option is used by .MS cc 1 to discard internally-generated labels whileretaining symbols local to routines..TP .B  \-xDiscards local(non-global) symbols in the output symbol table; only entersexternal symbols.This option saves some space in the output file..TP.BI \-Y environmentAdjusts the magic number in the output file so that the program runs in the specified.I environment .The parameter can be.B POSIX,.B SYSTEM_FIVE, or.B BSD .The parameter sets the program's execution environment to conform withone of the three standards.  If it is present, this parameteroverrides the PROG_ENV environment variable.  If no.I environmentis given,.B SYSTEM_FIVEis assumed.  If neither this parameter nor the PROG_ENV variable ispresent,.B \-YBSDis assumed..TP\fB\-y\fIsym\fRIndicates each file in which.I symappears, its type, and whether the file defines or references it.Many such options may be given to trace many symbols.It is usually necessary to begin.I symwith an underscore (_), because external C, FORTRAN andPascal variables begin with underscores..TP.B \-zArranges for the process to be loaded ondemand from the resulting executable file (413 format)rather than preloaded.  This is the default.It results in a 1024 byte header on the output file followed bya text and data segment whose size is a multiple of 1024 bytes(being padded out with nulls in the file if necessary).With this format the first few BSS segment symbols may,from the output of .MS size 1 ,appear to reside in the data segment.This avoids wasting the space which results from the roundup of the data segment size..SH Restrictions.NXR "ld command" "restricted"There is no way to force data to be page aligned.The.PN ldcommand pads the images which are to be demand loaded fromthe file system to the nextpage boundary.  .PPWhen linking code contains GFLOAT instructions,the GFLOAT versions of .I libcand/or the math library must be used rather than the normal DFLOAT versions.  Link to these by using.I \-lcgand/or.I \-lmg. .PPThe compiler and the linker .MS ld 1cannot detect the use of mixed double floating point types, and your program may produce erroneous results. 				.SH Files.TP 20/lib/lib*.a	libraries..TP/usr/lib/lib*.a libraries.TP/usr/local/lib/lib*.a  libraries.TPa.out	output file.SH See Alsoar(1), as(1), cc(1), ranlib(1)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?