|
|
1.1 root 1: .TH LD 1
2: .CT 1 lib_obj
3: .SH NAME
4: ld \(mi link editor or loader
5: .SH SYNOPSIS
6: .B ld
7: [
8: .I option ...
9: ]
10: .I file ...
11: .SH DESCRIPTION
12: .I Ld
13: combines several
14: object programs into one, resolves external
15: references, and searches libraries.
16: In the simplest case several object
17: .I files
18: are given, and
19: .I ld
20: combines them, producing
21: an object module which can be either executed or
22: become the input for a further
23: .I ld
24: run.
25: (In the latter case, the
26: .B -r
27: option must be given
28: to preserve the relocation bits.)
29: The output of
30: .I ld
31: is left on
32: .FR a.out .
33: This file is made executable
34: only if no errors occurred during the load.
35: .PP
36: The argument routines are concatenated in the order
37: specified. The entry point of the output is the
38: beginning of the first routine (unless the
39: .B -e
40: option is specified).
41: .PP
42: If any argument is a library, it is searched exactly once
43: at the point it is encountered in the argument list.
44: Only those routines defining an unresolved external
45: reference are loaded.
46: If a routine from a library
47: references another routine in the library,
48: and the library has not been processed by
49: .I ranlib
50: (see
51: .IR ar (1)),
52: the referenced routine must appear after the
53: referencing routine in the library.
54: Thus the order of programs within libraries
55: may be important; see
56: .IR lorder (1).
57: The first member of a library
58: should be a file named
59: .BR _\^_.SYMDEF ,
60: which is understood to be a dictionary for the library as produced by
61: .IR ranlib ;
62: the dictionary is searched iteratively to satisfy as many references as
63: possible.
64: .PP
65: The symbols
66: .LR \_etext ,
67: .LR \_edata ,
68: and
69: .L \_end
70: .RL ( etext ,
71: .LR edata ,
72: and
73: .L end
74: in C) are reserved, and if referred to,
75: are set to the first location above the program,
76: the first location above initialized data,
77: and the first location above all data, respectively.
78: It is erroneous to define these symbols.
79: .PP
80: .I Ld
81: understands several options.
82: Except for
83: .BR -l
84: and
85: .BR -o ,
86: they should appear before the file names.
87: .TP
88: .B -A
89: Load incrementally, so that the resulting object code
90: may be read into an already executing program.
91: The next argument names an object file whose symbol table will be
92: added to.
93: Only newly linked material will be entered into the text and
94: data portions of
95: .FR a.out ,
96: but the new symbol table will reflect
97: every symbol defined before and after the incremental load.
98: .B -A
99: must not follow any object file names.
100: .TP
101: .B -D
102: Take the next argument as a hexadecimal number and pad the data segment
103: with zeros to the indicated length.
104: .TP
105: .B -d
106: Force definition of common storage
107: even if the
108: .B -r
109: flag is present.
110: .TP
111: .B -e
112: The following argument is taken to be the
113: name of the entry point of the loaded
114: program; location 0 is the default.
115: .TP
116: .BI -l x
117: This
118: option is an abbreviation for the library name
119: .BI /lib/lib x .a ,
120: where
121: .I x
122: is a string.
123: If that does not exist,
124: .I ld
125: tries
126: .BI /usr/lib/lib x .a
127: A library is searched when its name is encountered,
128: so the placement of the option
129: is significant.
130: .TP
131: .B -M
132: produce a primitive load map, listing the names of the files
133: which will be loaded.
134: .TP
135: .B -N
136: Do not make the text portion read-only or sharable. (Use `magic number' 0407.)
137: .TP
138: .B -n
139: Arrange that
140: when the output file is executed,
141: the text portion will be read-only and shared
142: among all users executing the file.
143: (Use magic number 0410 and
144: move the data segment to a
145: 1024 byte boundary.)
146: .TP
147: .B -o
148: The
149: .I name
150: argument after
151: .B -o
152: is used as the name of the
153: .I ld
154: output file, instead of
155: .FR a.out .
156: .TP
157: .B -r
158: Generate relocation bits in the output file
159: so that it can be the subject of another
160: .I ld
161: run.
162: This flag also prevents final fixing
163: of `common' symbols (uninitialized C variables or
164: Fortran common variables),
165: and suppresses `undefined symbol' diagnostics.
166: .TP
167: .B -s
168: Strip the output, that is, remove the symbol table
169: and relocation bits to save space (but impair the
170: usefulness of the debuggers).
171: This information can also be removed by
172: .IR strip (1).
173: .TP
174: .B -S
175: Partially strip; remove all symbols that were not in the source.
176: .TP
177: .B -T
178: The next argument is a hexadecimal number which sets the text segment origin.
179: With option
180: .B -A
181: this origin must be a multiple of 1024.
182: The default is 0, or
183: .B _end
184: with
185: .BR -A .
186: .TP
187: .B -t
188: (trace) Print the name of each file as it is processed.
189: .TP
190: .B -u
191: Take the following argument as a symbol and enter
192: it as undefined in the symbol table. This is useful
193: for loading wholly from a library, since initially the symbol
194: table is empty and an unresolved reference is needed
195: to force the loading of the first routine.
196: .TP
197: .B -X
198: Save local symbols
199: except for those whose names begin with
200: .LR L .
201: This option is used by
202: .IR cc (1)
203: to discard internally-generated labels while
204: retaining symbols local to routines.
205: .TP
206: .B -x
207: Do not preserve local
208: symbols in the output symbol table; only enter
209: external symbols.
210: This option saves some space in the output file.
211: .TP
212: .BI -y sym
213: Indicate each file in which
214: .I sym
215: appears, its type and whether the file defines or references it.
216: Many such options may be given to trace many symbols.
217: (It is usually necessary to begin
218: .I sym
219: with an underscore
220: .LR _ ,
221: as external C, Fortran, and Pascal variables begin
222: with underscores.)
223: .TP
224: .B -z
225: Arrange for the process to be loaded on
226: demand from the resulting executable file (magic number 413)
227: rather than preloaded.
228: This (default) output format
229: has a 1024-byte header followed by
230: a text and data segment each of which have size a multiple of 1024 bytes
231: (being padded out with zeros if necessary).
232: The first few BSS segment symbols may appear in the data segment
233: to avoid wasting space at the end of that segment.
234: .SH FILES
235: .TF /usr/local/lib/lib*.a
236: .TP
237: .F /lib/lib*.a
238: libraries
239: .TP
240: .F /usr/lib/lib*.a
241: more libraries
242: .TP
243: .F a.out
244: output file
245: .SH "SEE ALSO"
246: .IR as (1),
247: .IR ar (1),
248: .IR cc (1),
249: .IR f77 (1),
250: .IR size (1),
251: .IR nm (1),
252: .IR lorder (1),
253: .IR a.out (5)
254: .SH BUGS
255: There is no way to force data to be page aligned.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.