]> git.saurik.com Git - apple/ld64.git/blob - doc/man/man1/ld.1
ld64-77.1.tar.gz
[apple/ld64.git] / doc / man / man1 / ld.1
1 .Dd December 8, 2006
2 .Dt ld 1
3 .Os Darwin
4 .Sh NAME
5 .Nm ld
6 .Nd "linker"
7 .Sh SYNOPSIS
8 .Nm
9 files...
10 .Op options
11 .Op Fl o Ar outputfile
12 .Sh DESCRIPTION
13 The
14 .Nm ld
15 command combines several object files and libraries, resolves references, and
16 produces an ouput file.
17 .Nm ld
18 can produce a final linked image (executable, dylib, or bundle), or with the -r
19 option, produce another object file. If the -o option is not used, the output
20 file produced is named "a.out".
21 .Ss Universal
22 The linker accepts universal (multiple-architecture) input files, but
23 always creates a "thin" (single-architecture), standard Mach-O output file.
24 The architecture for the output file is specified using the -arch option.
25 If this option is not used,
26 .Nm ld
27 attempts to determine the output architecture by examining the object
28 files in command line order. The first "thin"
29 architecture determines that of the output file. If no input
30 object file is a "thin" file, the native 32-bit architecture for the host is used.
31 .Pp
32 Usually,
33 .Nm ld
34 is not used directly. Instead the
35 .Xr gcc(1)
36 compiler driver invokes
37 .Nm ld.
38 The compiler driver can be passed multiple -arch options and it will create a
39 universal final linked image by invoking
40 .Nm ld
41 multiple times and then running
42 .Xr lipo(1)
43 merge the outputs into a universal file.
44 .Ss Layout
45 The object files are loaded in the order in which they are specified on the
46 command line. The segments and the sections in those segments will appear in
47 the output file in the order they are encountered in the object files being linked.
48 All zero fill sections will appear after all non-zero fill sections in their segments.
49 Sections created from files with the -sectcreate option will be laid out at after
50 sections from .o files. The use of the -order_file option will alter the layout
51 rules above, and move the symbols specified to start of their section.
52 .Ss Libraries
53 A static library (aka static archive) is a collection of .o files with a table of contents
54 that lists the global symbols in the .o files.
55 .Nm ld
56 will only pull .o files out of a static library if needed to resolve some symbol reference.
57 Unlike traditional linkers,
58 .Nm ld
59 will continually search a static library while linking. There is no need to specify a static
60 library multiple times on the command line.
61 .Pp
62 A dynamic library (aka dylib or framework) is a final linked image. Putting a dynamic
63 library on the command line causes two things: 1) The generated final linked image
64 will have encoded that it depends on that dynamic library. 2) Exported symbols from the
65 dynamic library are used to resolve references.
66 .Pp
67 Both dynamic and static libraries are searched as they appear on the command line.
68 .Ss Search paths
69 .Nm ld
70 maintains a list of directories to search for a library or framework to use. The default
71 library search path is /usr/lib then /usr/local/lib. The -L option will add a new library search
72 path. The default framework search path is /Library/Frameworks then /System/Library/Frameworks.
73 The -F option will a new framework search path. The -Z option will remove
74 the standard search paths. The -syslibroot option will prepend a prefix to all search
75 paths.
76 .Ss Two-level namespace
77 By default all references resolved to a dynamic library record the library to which
78 they were resolved. At runtime, dyld uses that information to directly resolve
79 symobls. The alternative is to use the -flat_namespace option. With flat namespace,
80 the library is not recorded. At runtime, dyld will search each dynamic library in load
81 order when resolving symbols. This is slower, but more like how other operating systems
82 resolve symbols.
83 .Ss Indirect dynamic libraries
84 If the command line specifies to link against dylib A, and when dylib A was built it linked
85 against dylib B, then B is considered an indirect dylib.
86 When linking for two-level namespace, ld does not look at indirect dylibs, except when
87 re-exported by a direct dylibs. On the other hand when linking for flat namespace,
88 ld does load all indirect dylibs and uses them to resolve references.
89 Even though indirect dylibs are specified via a full path,
90 .Nm ld
91 first uses the specified search paths to locate each indirect dylib. If one cannot
92 be found using the search paths, the full path is used.
93 .Ss Dynamic libraries undefines
94 When linking for two-level namespace,
95 .Nm ld
96 does not verify that undefines in dylibs actually
97 exist. But when linking for flat namespace,
98 .Nm ld
99 does check that all undefines from all loaded dylibs have a matching definition.
100 This is sometimes used to force selected functions to be loaded from a static library.
101 .Sh OPTIONS
102 .Ss Options that control the kind of output
103 .Bl -tag
104 .It Fl execute
105 The default. Produce a mach-o main executable that has file type MH_EXECUTE.
106 .It Fl dylib
107 Produce a mach-o shared library that has file type MH_DYLIB.
108 .It Fl bundle
109 Produce a mach-o bundle that has file type MH_BUNDLE.
110 .It Fl r
111 Merges object files to produce another mach-o object file with file type MH_OBJECT.
112 .It Fl dylinker
113 Produce a mach-o dylinker that has file type MH_DYLINKER. Only used when building dyld.
114 .It Fl dynamic
115 The default. Implied by -dynamiclib, -bundle, or -execute
116 .It Fl static
117 Produces a mach-o file that does not use the dyld. Only used building the kernel.
118 .It Fl arch Ar arch_name
119 Specifies which architecture (e.g. ppc, ppc64, i386, x86_64) the output file should be.
120 .It Fl o Ar path
121 Specifies the name and location of the output file. If not specified, `a.out' is used.
122 .El
123 .Ss Options that control libraries
124 .Bl -tag
125 .It Fl l Ns x
126 This option tells the linker to search for libx.dylib or libx.a in the library search path.
127 If string x is of the form y.o, then that file is searched for in the same places, but without
128 prepending `lib' or appending `.a' or `.dylib' to the filename.
129 .It Fl weak-l Ns Ar x
130 This is the same as the -lx but forces the library and all references to it to be marked as weak imports.
131 That is, the library is allowed to be missing at runtime.
132 .It Fl weak_library Ar path_to_library
133 This is the same as listing a file name path to a library on the link line except that it forces the
134 library and all references to it to be marked as weak imports.
135 .It Fl reexport-l Ns Ar x
136 This is the same as the -lx but specifies that the all symbols in library x should be available to
137 clients linking to the library being created. This was previously done with a separate -sub_library option.
138 .It Fl reexport_library Ar path_to_library
139 This is the same as listing a file name path to a library on the link line and it specifies that the
140 all symbols in library path should be available to clients linking to the library being created.
141 This was previously done with a separate -sub_library option.
142 .It Fl L Ns dir
143 Add
144 .Ar dir
145 to the list of directories in which to search for libraries.
146 Directories specified with -L are searched in the order they appear on the command line
147 and before the default search path.
148 .It Fl Z
149 Do not search the standard directories when searching for libraries and frameworks.
150 .It Fl syslibroot Ar rootdir
151 Prepend
152 .Ar rootdir
153 to all search paths when searching for libraries or frameworks.
154 .It Fl search_paths_first
155 By default the -lx and -weak-lx options first search for a file of the form `libx.dylib' in each directory
156 in the library search path, then a file of the form `libx.a' is searched for in the library search paths.
157 This option changes it so that in each path `libx.dylib' is searched for then `libx.a' before the
158 next path in the library search path is searched.
159 .It Fl framework Ar name[,suffix]
160 This option tells the linker to search for `name.framework/name' the framework search path.
161 If the optional suffix is specified the framework is first searched for the name with the suffix and then without
162 (e.g. look for `name.framework/name_suffix' first).
163 .It Fl weak_framework Ar name[,suffix]
164 This is the same as the -framework name[,suffix] but forces the framework and all
165 references to it to be marked as weak imports.
166 .It Fl reexport_framework Ar name[,suffix]
167 This is the same as the -framework name[,suffix] but also specifies that the
168 all symbols in that framework should be available to clients linking to the library being created.
169 This was previously done with a separate -sub_umbrella option.
170 .It Fl F Ns dir
171 Add
172 .Ar dir
173 to the list of directories in which to search for frameworks.
174 Directories specified with -F are searched in the order they appear on the command line
175 and before the default search path.
176 .It Fl all_load
177 Loads all members of static archive libraries.
178 .It Fl ObjC
179 Loads all members of static archive libraries that implement an Objective-C class or category.
180 .El
181 .Ss Options that control additional content
182 .Bl -tag
183 .It Fl sectcreate Ar segname sectname file
184 The section
185 .Ar sectname
186 in the segment
187 .Ar segname
188 is created from the contents of file
189 .Ar file.
190 The combination of segname and sectname must be unique Ð there cannot already be a section (segname,sectname)
191 from any other input.
192 .It Fl filelist Ar file[,dirname]
193 Specifies that the linker should link the files listed in
194 .Ar file .
195 This is an alternative to listing the files on the command line.
196 The file names are listed one per line separated only by newlines. (Spaces and tabs are assumed to be part of the file name.)
197 If the optional directory name,
198 .Ar dirname
199 is specified, it is prepended to each name in the list file.
200 .It Fl dtrace Ar file
201 Enables dtrace static probes when producing a final linked image. The file
202 .Ar file
203 must be a DTrace script which declares the static probes.
204 .El
205 .Ss Options that control optimizations
206 .Bl -tag
207 .It Fl dead_strip
208 Remove functions and data that are unreachable by the entry point or exported symbols.
209 .It Fl dead_strip_dylibs
210 Remove dylibs that are unreachable by the entry point or exported symbols. That is,
211 suppresses the generation of load command commands for dylibs which supplied no
212 symbols during the link. This option should not be used when linking against a dylib which
213 is required at runtime for some indirect reason such as the dylib has an important initializer.
214 .It Fl order_file Ar file
215 Alters the order in which functions and data are laid out. For each section in the output file,
216 any symbol in that section that are specified in the order file
217 .Ar file
218 is moved to the start of its section and laid out in the same order as in the order file
219 .Ar file .
220 Order files are text files with one symbol name per line. Lines starting with a # are comments.
221 A symbol name may be optionally preceded with its object file leafname and a colon (e.g. foo.o:_foo).
222 This is useful for static functions/data that occur in multiple files.
223 A symbol name may also be optionally preceded with the architecture (e.g. ppc:_foo or ppc:foo.o:_foo).
224 This enables you to have one order file that works for multiple architectures.
225 Literal c-strings may be ordered by by quoting the string (e.g. "Hello, world\\n") in the order file.
226 .It Fl macosx_version_min Ar version
227 This is set to indicate the oldest Mac OS X version that that the output is to be used on. Specifying
228 a later version enables the linker to assumes features of that OS in the output file. The format of
229 .Ar version
230 is a Mac OS X version number such as 10.4 or 10.5
231 .It Fl image_base Ar address
232 Specifies the perferred load address for a dylib or bundle. The argument
233 .Ar address
234 is a hexadecimal number with an optional leading 0x. By choosing non-overlapping address for all
235 dylibs and bundles that a program loads, launch time can be improved because dyld will not need to
236 "rebase" the image (that is, adjust pointers within the image to work at the loaded address).
237 It is often easier to not use this option, but instead use the rebase(1) tool, and give it a list of dylibs.
238 It will then choose non-overlapping addresses for the list and rebase them all.
239 This option is also called -seg1addr for compatibility.
240 .El
241 .Ss Options when creating a dynamic library (dylib)
242 .Bl -tag
243 .It Fl install_name Ar name
244 Sets an internal "install path" (LC_ID_DYLIB) in a dynamic library. Any clients linked against the library
245 will record that path as the way dyld should locate this library. If this option is not specified, then
246 the -o path will be used. This option is also called -dylib_install_name for compatibility.
247 .It Fl compatibility_version Ar number
248 Specifies the compatibility version number of the library. When a library is loaded by dyld, the
249 compatibility version is checked and if the program's version is greater that the library's version, it is an error.
250 The format of
251 .Ar number
252 is X[.Y[.Z]] where X must be a positive non-zero number less than or equal to 65535,
253 and .Y and .Z are optional and if present must be non-negative numbers less than or equal to 255.
254 If the compatibility version number is not specified, it has a value of 0 and no checking is done when the library is used.
255 This option is also called -dylib_compatibility_version for compatibility.
256 .It Fl current_version Ar number
257 Specifies the current version number of the library. The current version of the library can be obtained
258 programmatically by the user of the library so it can determine exactly which version of the library it is using.
259 The format of
260 .Ar number
261 is X[.Y[.Z]] where X must be a positive non-zero number less than or equal to 65535,
262 and .Y and .Z are optional and if present must be non-negative numbers less than or equal to 255.
263 If the version number is not specified, it has a value of 0.
264 This option is also called -dylib_current_version for compatibility.
265 .El
266 .Ss Options when creating a main executable
267 .Bl -tag
268 .It Fl pie
269 This makes a special kind of main executable that is position independent (PIE). On Mac OS X 10.5, the OS
270 will load a PIE at a random address each time it is executed. You cannot create a PIE from .o files compiled
271 with -mdynamic-no-pic. That means the codegen is less optimal, but the address randomization adds some
272 security.
273 .It Fl pagezero_size Ar size
274 By default the linker creates an unreadable segment starting at address zero named __PAGEZERO. Its existence
275 will cause a bus error if a NULL pointer is dereferenced. The argument
276 .Ar size
277 is a hexadecimal number with an optional leading 0x. If
278 .Ar size
279 is zero, the linker will not generate a page zero segment. By default on 32-bit architectures the page zero size
280 is 4KB. On 64-bit architectures, the default size if 4GB. The ppc64 architecture has some special cases. Since Mac
281 OS X 10.4 did not support 4GB page zero programs, the default page zero size for ppc64 will be 4KB unless
282 -macosx_version_min is 10.5 or later. Also, the -mdynamic-no-pic codegen model for ppc64 will only work if the
283 code is placed in the lower 2GB of the address space, so the if the linker detects any such code, the page zero
284 size is set to 4KB and then a new unredable trailing segment is created after the code, filling up the lower 4GB.
285 .It Fl stack_size Ar size
286 Specifies the maximum stack size for the main thread in a program. Without this option a program has a 8MB stack.
287 The argument
288 .Ar size
289 is a hexadecimal number with an optional leading 0x. The
290 .Ar size
291 should be an even multiple of 4KB, that is the last three hexadecimal digits should be zero.
292 .It Fl allow_stack_execute
293 Marks executable so that all stacks in the task will be given stack execution privilege. This includes pthread stacks.
294 .El
295 .Ss Options when creating a bundle
296 .Bl -tag
297 .It Fl bundle_loader Ar executable
298 This specifies the
299 .Ar executable
300 that will be loading the bundle output file being linked.
301 Undefined symbols from the bundle are checked against the specified
302 .Ar executable
303 like it was one of the
304 dynamic libraries the bundle was linked with.
305 .El
306 .Ss Options when creating an object file
307 .Bl -tag
308 .It Fl keep_private_externs
309 Don't turn private external (aka visibility=hidden) symbols into static symbols,
310 but rather leave them as private external in the resulting object file.
311 .It Fl d
312 Force definition of common symbols. That is, transform tentative defintions into real definitions.
313 .El
314 .Ss Options that control symbol resolution
315 .Bl -tag
316 .It Fl exported_symbols_list Ar filename
317 The specified
318 .Ar filename
319 contains a list of global symbol names that will remain as global symbols in the output file.
320 All other global symbols will be treated as if they were marked as __private_extern__ (aka visibility=hidden)
321 and will not be global in the output file. The symbol names listed in filename must be one per line.
322 Leading and trailing white space are not part of the symbol name.
323 Lines starting with # are ignored, as are lines with only white space.
324 Some wildcards (similar to shell file matching) are supported. The * matches zero or more characters.
325 The ? matches one character. [abc] matches one character which must be an 'a', 'b', or 'c'. [a-z] matches
326 any single lower case letter from 'a' to 'z'.
327 .It Fl exported_symbol Ar symbol
328 The specified
329 .Ar symbol
330 is added to the list of global symbols names that will remain as global symbols in the output file. This
331 option can be used multiple times. For short lists, this can be more convenient than creating a file and using
332 -exported_symbols_list.
333 .It Fl unexported_symbols_list Ar file
334 The specified
335 .Ar filename
336 contains a list of global symbol names that will not remain as global symbols in the output file.
337 The symbols will be treated as if they were marked as __private_extern__ (aka visibility=hidden) and will not be global
338 in the output file. The symbol names listed in filename must be one per line.
339 Leading and trailing white space are not part of the symbol name.
340 Lines starting with # are ignored, as are lines with only white space.
341 Some wildcards (similar to shell file matching) are supported. The * matches zero or more characters.
342 The ? matches one character. [abc] matches one character which must be an 'a', 'b', or 'c'. [a-z] matches
343 any single lower case letter from 'a' to 'z'.
344 .It Fl unexported_symbol Ar symbol
345 The specified
346 .Ar symbol
347 is added to the list of global symbols names that will not remain as global symbols in the output file. This
348 option can be used multiple times. For short lists, this can be more convenient than creating a file and using
349 -unexported_symbols_list.
350 .It Fl alias Ar symbol_name Ar alternate_symbol_name
351 Create an alias named
352 .Ar alternate_symbol_name
353 for the symbol
354 .Ar symbol_name .
355 By default the alias symbol has global visibility. This option was previous the -idef:indir option.
356 .It Fl alias_list Ar filename
357 The specified
358 .Ar filename
359 contains a list of aliases. The symbol name and its alias are on one line, separated by whitespace.
360 Lines starting with # are ignored.
361 .It Fl flat_namespace
362 Alters how symbols are resolved at build time and runtime. With -two_levelnamespace (the default), the linker
363 only searches dylibs on the command line for symbols, and records in which dylib they were found. With -flat_namespace,
364 the linker searches all dylibs on the command line and all dylibs those original dylibs depend on. The linker
365 does not record which dylib an external symbol came from, so at runtime dyld again searches all images and uses
366 the first definition it finds. In addition, any undefines in loaded flat_namespace dylibs must be resolvable
367 at build time.
368 .It Fl u Ar symbol_name
369 Specified that symbol
370 .Ar symbol_name
371 must be defined for the link to succeed. This is useful to force selected functions to be loaded
372 from a static library.
373 .It Fl U Ar symbol_name
374 Specified that it is ok for
375 .Ar symbol_name
376 to have no definition. With -two_levelnamespace, the resulting symbol will be marked dynamic_lookup which
377 means dyld will search all loaded images.
378 .It Fl undefined Ar treatment
379 Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The
380 default is error.
381 .It Fl rpath Ar path
382 Add
383 .Ar path
384 to the runpath search path list for image being created. At runtime, dyld uses the runpath when searching
385 for dylibs whose load path begins with @rpath/.
386 .El
387 .Ss Options for introspecting the linker
388 .Bl -tag
389 .It Fl why_load
390 Log why each object file in a static library is loaded. That is, what symbol was needed. Also called -whyload
391 for compatibility.
392 .It Fl why_live Ar symbol_name
393 Logs a chain of references to
394 .Ar symbol_name .
395 Only applicable with -dead_strip .
396 It can help debug why something that you think should be dead strip removed is not removed.
397 .It Fl print_statistics
398 Logs information about the amount of memory and time the linker used.
399 .It Fl t
400 Logs each file (object, archive, or dylib) the linker loads. Useful for debugging problems with search paths where the wrong library is loaded.
401 .It Fl whatsloaded
402 Logs just object files the linker loads.
403 .It Fl order_file_statistics
404 Logs information about the processing of a -order_file.
405 .It Fl map Ar map_file_path
406 Writes a map file to the specified path which details all symbols and their addresses in the output image.
407 .El
408 .Ss Options for controling symbol table optimizations
409 .Bl -tag
410 .It Fl S
411 Do not put debug information (STABS or DWARF) in the output file.
412 .It Fl x
413 Do not put non-global symbols in the output file's symbol table. Non-global symbols are useful when debugging and
414 getting symbol names in back traces, but are not used at runtime.
415 .It Fl non_global_symbols_strip_list Ar filename
416 The specified
417 .Ar filename
418 contains a list of non-global symbol names that should be removed from the output file's symbol table. All other
419 non-global symbol names will remain in the output files symbol table. See -exported_symbols_list for syntax and use
420 of wildcards.
421 .It Fl non_global_symbols_no_strip_list Ar filename
422 The specified
423 .Ar filename
424 contains a list of non-global symbol names that should be remain in the output file's symbol table. All other
425 symbol names will be removed from the output file's symbol table. See -exported_symbols_list for syntax and use
426 of wildcards.
427 .El
428 .Ss Rarely used Options
429 .Bl -tag
430 .It Fl v
431 Prints the version of the linker.
432 .It Fl no_uuid
433 Do not generate an LC_UUID load command in the output file.
434 .It Fl root_safe
435 Sets the MH_ROOT_SAFE bit in the mach header of the output file.
436 .It Fl setuid_safe
437 Sets the MH_SETUID_SAFE bit in the mach header of the output file.
438 .It Fl interposable
439 Indirects access to all to exported symbols when creating a dynamic library.
440 .It Fl init Ar symbol_name
441 The specified symbol_name will be run as the first initializer. Only used when creating a dynamic library.
442 .It Fl sub_library Ar library_name
443 The specified dylib will be re-exported. For example the library_name for /usr/lib/libobjc_profile.A.dylib would be libobjc.
444 Only used when creating a dynamic library.
445 .It Fl sub_umbrella Ar framework_name
446 The specified framework will be re-exported. Only used when creating a dynamic library.
447 .It Fl allowable_client Ar name
448 Restricts what can link against the dynamic library being created.
449 .It Fl client_name Ar name
450 Enables a bundle to link against a dylib that was built with -allowable_client.
451 The name specified must match one of the -allowable_client names specified when the dylib was created.
452 .It Fl umbrella Ar framework_name
453 Specifies that the dylib being linked is re-exported through an umbrella framework of the specified name.
454 .It Fl headerpad Ar size
455 Specifies the minimum space for future expansion of the load commands. Only useful if intend to run
456 install_name_tool to alter the load commands later. Size is a hexadecimal number.
457 .It Fl headerpad_max_install_names
458 Automatically adds space for future expansion of load commands such that all paths could expand to MAXPATHLEN.
459 Only useful if intend to run install_name_tool to alter the load commands later. Size is a hexadecimal number.
460 .It Fl bind_at_load
461 Sets a bit in the mach header of the resulting binary which tells dyld to bind all symbols when the binary is loaded, rather than lazily.
462 .It Fl force_flat_namespace
463 Sets a bit in the mach header of the resulting binary which tells dyld to not only use flat namespace for the binary,
464 but force flat namespace binding on all dylibs and bundles loaded in the process. Can only be used when linking main executables.
465 .It Fl sectalign Ar segname Ar sectname Ar value
466 The section named sectname in the segment segname will have its alignment set to value, where value is a hexadecimal
467 number that must be an integral power of 2.
468 .It Fl stack_addr Ar address
469 Specifies the initial address of the stack pointer value, where value is a hexadecimal number rounded to a page boundary.
470 .It Fl segprot Ar segname Ar max_prot Ar init_prot
471 Specifies the maximum and initial virtual memory protection of the named segment, name, to be max and init ,respectively.
472 The values for max and init are any combination of the characters `r' (for read), `w' (for write), `x' (for execute) and `-' (no access).
473 .It Fl seg_addr_table Ar filename
474 Specifies a file containing base addresses for dynamic libraries. Each line of the file is a hexadecimal base address
475 followed by whitespace then the install name of the corresponding dylib. The # character denotes a comment.
476 .It Fl segs_read_write_addr Ar address
477 Allows a dynamic library to be built where the read-only and read-write segments are not contiguous. The address
478 specified is a hexadecimal number that indicates the base address for the read-write segments.
479 .It Fl segs_read_only_addr Ar address
480 Allows a dynamic library to be built where the read-only and read-write segments are not contiguous. The address
481 specified is a hexadecimal number that indicates the base address for the read-only segments.
482 .It Fl segaddr Ar name Ar address
483 Specifies the starting address of the segment named name to be address. The address must be a hexadecimal number
484 that is a multiple of 4K page size.
485 .It Fl dylib_file Ar install_name:file_name
486 Specifies that a dynamic shared library is in a different location than its standard location. Use this option
487 when you link with a library that is dependent on a dynamic library, and the dynamic library is in a location other
488 than its default location. install_name specifies the path where the library normally resides. file_name specifies
489 the path of the library you want to use instead. For example, if you link to a library that depends upon the dynamic
490 library libsys and you have libsys installed in a nondefault location, you would use this option:
491 -dylib_file /lib/libsys_s.A.dylib:/me/lib/libsys_s.A.dylib.
492 .It Fl prebind
493 The created output file will be in the prebound format. This was used in Mac OS X 10.3 and earlier to improve launch performance.
494 .It Fl weak_reference_mismatches Ar treatment
495 Specifies what to do if a symbol is weak-imported in one object file but not weak-imported in another. The valid
496 treatments are: error, weak, or non-weak. The default is non-weak.
497 .It Fl read_only_relocs Ar treatment
498 Enables the use of relocations which will cause dyld to modify (copy-on-write) read-only pages. The compiler will
499 normally never generate such code.
500 .It Fl force_cpusubtype_ALL
501 The is only applicable with -arch ppc. It tells the linker to ignore the PowerPC cpu requirements (e.g. G3, G4 or G5) encoded
502 in the object files and mark the resulting binary as runnable on any PowerPC cpu.
503 .It Fl dylinker_install_name Ar path
504 Only used when building dyld.
505 .It Fl no_arch_warnings
506 Suppresses warning messages about files that have the wrong architecture for the -arch flag
507 .It Fl arch_errors_fatal
508 Turns into errors, warnings about files that have the wrong architecture for the -arch flag.
509 .It Fl e Ar symbol_name
510 Specifies the entry point of a main executable. By default the entry name is "start" which is found in crt1.o which contains
511 the glue code need to set up and call main().
512 .It Fl w
513 Suppress all warning messages
514 .It Fl final_output Ar name
515 Specifies the install name of a dylib if -install_name is not used. This option is used by gcc driver when it is invoked
516 with multiple -arch arguments.
517 .It Fl arch_multiple
518 Specifes that the linker should augment error and warning messages with the architecture name. This option is used by gcc
519 driver when it is invoked with multiple -arch arguments.
520 .It Fl twolevel_namespace_hints
521 Specifies that hints should be added to the resulting binary that can help speed up runtime binding by dyld as long as the
522 libraries being linked against have not changed.
523 .It Fl dot Ar path
524 Create a file a file at the specified path containing a graph of symbol dependencies. The .dot file can be viewed in GraphViz.
525 .It Fl keep_relocs
526 Add section based relocation records to a final linked image. These relocations are ignored at runtime by dyld.
527 .It Fl warn_stabs
528 Print a warning when the linker cannot do a BINCL/EINCL optimzation because the compiler put a bad stab symbol inside
529 a BINCL/EINCL range.
530 .El
531 .Ss Obsolete Options
532 .Bl -tag
533 .It Fl segalign Ar value
534 All segments must be page aligned. This option is obsolete.
535 .It Fl seglinkedit
536 Object files (MH_OBJECT) with a LINKEDIT segment are no longer supported. This option is obsolete.
537 .It Fl noseglinkedit
538 This is the default. This option is obsolete.
539 .It Fl fvmlib
540 Fixed VM shared libraries (MH_FVMLIB) are no longer supported. This option is obsolete.
541 .It Fl preload
542 Preload executables (MH_PRELOAD) are no longer supported. This option is obsolete.
543 .It Fl sectobjectsymbols Ar segname Ar sectname
544 Adding a local label at a section start is no longer supported. This option is obsolete.
545 .It Fl nofixprebinding
546 The MH_NOFIXPREBINDING bit of mach_headers has been ignored since Mac OS X 10.3.9. This option is obsolete.
547 .It Fl noprebind_all_twolevel_modules
548 Multi-modules in dynamic libraries have been ignored at runtime since Mac OS X 10.4.0. This option is obsolete.
549 .It Fl prebind_all_twolevel_modules
550 Multi-modules in dynamic libraries have been ignored at runtime since Mac OS X 10.4.0. This option is obsolete.
551 .It Fl prebind_allow_overlap
552 When using -prebind, the linker allows overlapping by default, so this option is obsolete.
553 .It Fl noprebind
554 LD_PREBIND is no longer supported as a way to force on prebinding, so there no longer needs to
555 be a command line way to override LD_PREBIND. This option is obsolete.
556 .It Fl sect_diff_relocs Ar treatment
557 This option was an attempt to warn about linking .o files compiled without -mdynamic-no-pic into
558 a main executable, but the false positive rate generated too much noise to make the option useful.
559 This option is obsolete.
560 .It Fl run_init_lazily
561 This option was removed in Mac OS X 10.2.
562 .It Fl single_module
563 This is now the default so does not need to be specified.
564 .It Fl multi_module
565 Multi-modules in dynamic libraries have been ignored at runtime since Mac OS X 10.4.0. This option is obsolete.
566 .It Fl no_dead_strip_inits_and_terms
567 The linker never dead strips initialzation and termination routines. They are considered "roots" of the dead strip graph.
568 .It Fl A Ar basefile
569 Obsolete incremental load format. This option is obsolete.
570 .It Fl b
571 Used with -A option to strip base file's symbols. This option is obsolete.
572 ..It Fl M
573 Obsolete option to produce a load map. Use -map option instead.
574 .It Fl Sn
575 Don't strip any symbols. This is the default. This option is obsolete.
576 .It Fl Si
577 Optimize stabs debug symbols to remove duplicates. This is the default. This option is obsolete.
578 .It Fl Sp
579 Write minimal stabs which causes the debugger to open and read the original .o file for full stabs.
580 This style of debugging is obsolete in Mac OS X 10.5. This option is obsolete.
581 .It Fl X
582 Strip local symbols that being the 'L'. This is the default. This option is obsolete.
583 .It Fl s
584 Completely strip the output, including removing the symbol table. This file format variant is no longer supported.
585 This option is obsolete.
586 .It Fl m
587 Don't treat multiple definitions as an error. This is no longer supported. This option is obsolete.
588 .It Fl y Ns symbol
589 Display each file in which
590 .Ar symbol
591 is used. This was previously used to debug where an undefined symbol was used, but the linker now
592 automatically prints out all usages. The -why_live option can also be used to display what kept
593 a symbol from being dead striped. This option is obsolete.
594 .It Fl Y Ar number
595 Used to control how many occurances of each symbol specifed with -y would be shown. This option is obsolete.
596 .It Fl nomultidefs
597 Only used when linking an umbrella framework. Sets the MH_NOMULTIDEFS bit in the mach_header. The MH_NOMULTIDEFS
598 bit has been obsolete since Mac OS X 10.4. This option is obsolete.
599 .It Fl multiply_defined_unused Ar treatment
600 Previously provided a way to warn or error if any of the symbol definitions in the output file matched any
601 definitions in dynamic library being linked. This option is obsolete.
602 .It Fl multiply_defined Ar treatment
603 Previously provided a way to warn or error if any of the symbols used from a dynamic library were also
604 available in another linked dynamic library. This option is obsolete.
605 .It Fl private_bundle
606 Previously prevented errors when -flat_namespace, -bundle, and -bundle_loader were used and the bundle
607 contained a definition that conflicted with a symbol in the main executable. The linker no longer
608 errors on such conflicts. This option is obsolete.
609 .It Fl noall_load
610 This is the default. This option is obsolete.
611 .It Fl seg_addr_table_filename Ar path
612 Use
613 .Ar path
614 instead of the install name of the library for matching an entry in the seg_addr_table. This option is obsolete.
615 .It Fl sectorder Ar segname sectname orderfile
616 Replaced by more general -order_file option.
617 .It Fl sectorder_detail
618 Produced extra logging about which entries from a sectorder entries were used. Replaced by -order_file_statistics.
619 This option is obsolete.
620 .El
621 .Sh SEE ALSO
622 as(1), ar(1), cc(1), nm(1), otool(1) lipo(1),
623 arch(3), dyld(3), Mach-O(5), strip(1), rebase(1)