ld.texinfo

来自「基于4个mips核的noc设计」· TEXINFO 代码 · 共 1,654 行 · 第 1/5 页

TEXINFO
1,654
字号
@end smallexample@itemMerging a common symbol with a previous larger common symbol.@smallexample@var{file}(@var{section}): warning: common of `@var{symbol}'   overridden by larger common@var{file}(@var{section}): warning: larger common is here@end smallexample@itemMerging a common symbol with a previous smaller common symbol.  This isthe same as the previous case, except that the symbols areencountered in a different order.@smallexample@var{file}(@var{section}): warning: common of `@var{symbol}'   overriding smaller common@var{file}(@var{section}): warning: smaller common is here@end smallexample@end enumerate@kindex --warn-constructors@item --warn-constructorsWarn if any global constructors are used.  This is only useful for a fewobject file formats.  For formats like COFF or ELF, the linker can notdetect the use of global constructors.@kindex --warn-multiple-gp@item --warn-multiple-gpWarn if multiple global pointer values are required in the output file.This is only meaningful for certain processors, such as the Alpha.Specifically, some processors put large-valued constants in a specialsection.  A special register (the global pointer) points into the middleof this section, so that constants can be loaded efficiently via abase-register relative addressing mode.  Since the offset inbase-register relative mode is fixed and relatively small (e.g., 16bits), this limits the maximum size of the constant pool.  Thus, inlarge programs, it is often necessary to use multiple global pointervalues in order to be able to address all possible constants.  Thisoption causes a warning to be issued whenever this case occurs.@kindex --warn-once@cindex warnings, on undefined symbols@cindex undefined symbols, warnings on@item --warn-onceOnly warn once for each undefined symbol, rather than once per modulewhich refers to it.@kindex --warn-section-align@cindex warnings, on section alignment@cindex section alignment, warnings on@item --warn-section-alignWarn if the address of an output section is changed because ofalignment.  Typically, the alignment will be set by an input section.The address will only be changed if it not explicitly specified; thatis, if the @code{SECTIONS} command does not specify a start address forthe section (@pxref{SECTIONS}).@kindex --whole-archive@cindex including an entire archive@item --whole-archiveFor each archive mentioned on the command line after the@code{--whole-archive} option, include every object file in the archivein the link, rather than searching the archive for the required objectfiles.  This is normally used to turn an archive file into a sharedlibrary, forcing every object to be included in the resulting sharedlibrary.  This option may be used more than once.Two notes when using this option from gcc: First, gcc doesn't knowabout this option, so you have to use @code{-Wl,-whole-archive}.Second, don't forget to use @code{-Wl,-no-whole-archive} after yourlist of archives, because gcc will add its own list of archives toyour link and you may not want this flag to affect those as well.@kindex --wrap@item --wrap @var{symbol}Use a wrapper function for @var{symbol}.  Any undefined reference to@var{symbol} will be resolved to @code{__wrap_@var{symbol}}.  Anyundefined reference to @code{__real_@var{symbol}} will be resolved to@var{symbol}.This can be used to provide a wrapper for a system function.  Thewrapper function should be called @code{__wrap_@var{symbol}}.  If itwishes to call the system function, it should call@code{__real_@var{symbol}}.Here is a trivial example:@smallexamplevoid *__wrap_malloc (int c)@{  printf ("malloc called with %ld\n", c);  return __real_malloc (c);@}@end smallexampleIf you link other code with this file using @code{--wrap malloc}, thenall calls to @code{malloc} will call the function @code{__wrap_malloc}instead.  The call to @code{__real_malloc} in @code{__wrap_malloc} willcall the real @code{malloc} function.You may wish to provide a @code{__real_malloc} function as well, so thatlinks without the @code{--wrap} option will succeed.  If you do this,you should not put the definition of @code{__real_malloc} in the samefile as @code{__wrap_malloc}; if you do, the assembler may resolve thecall before the linker has a chance to wrap it to @code{malloc}.@kindex --enable-new-dtags@kindex --disable-new-dtags@item --enable-new-dtags@itemx --disable-new-dtagsThis linker can create the new dynamic tags in ELF. But the older ELFsystems may not understand them. If you specify@code{--enable-new-dtags}, the dynamic tags will be created as needed.If you specify @code{--disable-new-dtags}, no new dynamic tags will becreated. By default, the new dynamic tags are not created. Note thatthose options are only available for ELF systems.@end table@subsection Options specific to i386 PE targetsThe i386 PE linker supports the @code{-shared} option, which causesthe output to be a dynamically linked library (DLL) instead of anormal executable.  You should name the output @code{*.dll} when youuse this option.  In addition, the linker fully supports the standard@code{*.def} files, which may be specified on the linker command linelike an object file (in fact, it should precede archives it exportssymbols from, to ensure that they get linked in, just like a normalobject file).In addition to the options common to all targets, the i386 PE linkersupport additional command line options that are specific to the i386PE target.  Options that take values may be separated from theirvalues by either a space or an equals sign.@table @code@kindex --add-stdcall-alias@item --add-stdcall-aliasIf given, symbols with a stdcall suffix (@@@var{nn}) will be exportedas-is and also with the suffix stripped.@kindex --base-file@item --base-file @var{file}Use @var{file} as the name of a file in which to save the baseaddresses of all the relocations needed for generating DLLs with@file{dlltool}.@kindex --dll@item --dllCreate a DLL instead of a regular executable.  You may also use@code{-shared} or specify a @code{LIBRARY} in a given @code{.def}file.@kindex --enable-stdcall-fixup@kindex --disable-stdcall-fixup@item --enable-stdcall-fixup@itemx --disable-stdcall-fixupIf the link finds a symbol that it cannot resolve, it will attempt todo "fuzzy linking" by looking for another defined symbol that differsonly in the format of the symbol name (cdecl vs stdcall) and willresolve that symbol by linking to the match.  For example, theundefined symbol @code{_foo} might be linked to the function@code{_foo@@12}, or the undefined symbol @code{_bar@@16} might be linkedto the function @code{_bar}.  When the linker does this, it prints awarning, since it normally should have failed to link, but sometimesimport libraries generated from third-party dlls may need this featureto be usable.  If you specify @code{--enable-stdcall-fixup}, thisfeature is fully enabled and warnings are not printed.  If you specify@code{--disable-stdcall-fixup}, this feature is disabled and suchmismatches are considered to be errors.@cindex DLLs, creating@kindex --export-all-symbols@item --export-all-symbolsIf given, all global symbols in the objects used to build a DLL willbe exported by the DLL.  Note that this is the default if thereotherwise wouldn't be any exported symbols.  When symbols areexplicitly exported via DEF files or implicitly exported via functionattributes, the default is to not export anything else unless thisoption is given.  Note that the symbols @code{DllMain@@12},@code{DllEntryPoint@@0}, and @code{impure_ptr} will not be automaticallyexported.@kindex --exclude-symbols@item --exclude-symbols @var{symbol},@var{symbol},...Specifies a list of symbols which should not be automaticallyexported.  The symbol names may be delimited by commas or colons.@kindex --file-alignment@item --file-alignmentSpecify the file alignment.  Sections in the file will always begin atfile offsets which are multiples of this number.  This defaults to512.@cindex heap size@kindex --heap@item --heap @var{reserve}@itemx --heap @var{reserve},@var{commit}Specify the amount of memory to reserve (and optionally commit) to beused as heap for this program.  The default is 1Mb reserved, 4Kcommitted.@cindex image base@kindex --image-base@item --image-base @var{value}Use @var{value} as the base address of your program or dll.  This isthe lowest memory location that will be used when your program or dllis loaded.  To reduce the need to relocate and improve performance ofyour dlls, each should have a unique base address and not overlap anyother dlls.  The default is 0x400000 for executables, and 0x10000000for dlls.@kindex --kill-at@item --kill-atIf given, the stdcall suffixes (@@@var{nn}) will be stripped fromsymbols before they are exported.@kindex --major-image-version@item --major-image-version @var{value}Sets the major number of the "image version".  Defaults to 1.@kindex --major-os-version@item --major-os-version @var{value}Sets the major number of the "os version".  Defaults to 4.@kindex --major-subsystem-version@item --major-subsystem-version @var{value}Sets the major number of the "subsystem version".  Defaults to 4.@kindex --minor-image-version@item --minor-image-version @var{value}Sets the minor number of the "image version".  Defaults to 0.@kindex --minor-os-version@item --minor-os-version @var{value}Sets the minor number of the "os version".  Defaults to 0.@kindex --minor-subsystem-version@item --minor-subsystem-version @var{value}Sets the minor number of the "subsystem version".  Defaults to 0.@cindex DEF files, creating@cindex DLLs, creating@kindex --output-def@item --output-def @var{file}The linker will create the file @var{file} which will contain a DEFfile corresponding to the DLL the linker is generating.  This DEF file(which should be called @code{*.def}) may be used to create an importlibrary with @code{dlltool} or may be used as a reference toautomatically or implicitly exported symbols.@kindex --section-alignment@item --section-alignmentSets the section alignment.  Sections in memory will always begin ataddresses which are a multiple of this number.  Defaults to 0x1000.@cindex stack size@kindex --stack@item --stack @var{reserve}@itemx --stack @var{reserve},@var{commit}Specify the amount of memory to reserve (and optionally commit) to beused as stack for this program.  The default is 32Mb reserved, 4Kcommitted.@kindex --subsystem@item --subsystem @var{which}@itemx --subsystem @var{which}:@var{major}@itemx --subsystem @var{which}:@var{major}.@var{minor}Specifies the subsystem under which your program will execute.  Thelegal values for @var{which} are @code{native}, @code{windows},@code{console}, and @code{posix}.  You may optionally set thesubsystem version also.@end table@ifset UsesEnvVars@node Environment@section Environment VariablesYou can change the behavior of @code{ld} with the environment variables@code{GNUTARGET}, @code{LDEMULATION}, and @code{COLLECT_NO_DEMANGLE}.@kindex GNUTARGET@cindex default input format@code{GNUTARGET} determines the input-file object format if you don'tuse @samp{-b} (or its synonym @samp{--format}).  Its value should be oneof the BFD names for an input format (@pxref{BFD}).  If there is no@code{GNUTARGET} in the environment, @code{ld} uses the natural formatof the target. If @code{GNUTARGET} is set to @code{default} then BFDattempts to discover the input format by examining binary input files;this method often succeeds, but there are potential ambiguities, sincethere is no method of ensuring that the magic number used to specifyobject-file formats is unique.  However, the configuration procedure forBFD on each system places the conventional format for that system firstin the search-list, so ambiguities are resolved in favor of convention.@kindex LDEMULATION@cindex default emulation@cindex emulation, default@code{LDEMULATION} determines the default emulation if you don't use the@samp{-m} option.  The emulation can affect various aspects of linkerbehaviour, particularly the default linker script.  You can list theavailable emulations with the @samp{--verbose} or @samp{-V} options.  Ifthe @samp{-m} option is not used, and the @code{LDEMULATION} environmentvariable is not defined, the default emulation depends upon how thelinker was configured.@end ifset@kindex COLLECT_NO_DEMANGLE@cindex demangling, defaultNormally, the linker will default to demangling symbols.  However, if@code{COLLECT_NO_DEMANGLE} is set in the environment, then it willdefault to not demangling symbols.  This environment variable is used ina similar fashion by the @code{gcc} linker wrapper program.  The defaultmay be overridden by the @samp{--demangle} and @samp{--no-demangle}options.@node Scripts@chapter Linker Scripts@cindex scripts@cindex linker scripts@cindex command filesEvery link is controlled by a @dfn{linker script}.  This script iswritten in the linker command language.The main purpose of th

⌨️ 快捷键说明

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