⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ldint.texinfo

📁 基于4个mips核的noc设计
💻 TEXINFO
📖 第 1 页 / 共 3 页
字号:
\input texinfo@setfilename ldint.info@c Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000@c Free Software Foundation, Inc.@ifinfo@formatSTART-INFO-DIR-ENTRY* Ld-Internals: (ldint).	The GNU linker internals.END-INFO-DIR-ENTRY@end format@end ifinfo@ifinfoThis file documents the internals of the GNU linker ld.Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000Free Software Foundation, Inc.Contributed by Cygnus Support.      Permission is granted to copy, distribute and/or modify this document      under the terms of the GNU Free Documentation License, Version 1.1      or any later version published by the Free Software Foundation;      with no Invariant Sections, with no Front-Cover Texts, and with no      Back-Cover Texts.  A copy of the license is included in the      section entitled "GNU Free Documentation License".@ignorePermission is granted to process this file through Tex and print theresults, provided the printed document carries copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignore@end ifinfo@iftex@finalout@setchapternewpage off@settitle GNU Linker Internals@titlepage@title{A guide to the internals of the GNU linker}@author Per Bothner, Steve Chamberlain, Ian Lance Taylor, DJ Delorie@author Cygnus Support@page@tex\def\$#1${{#1}}  % Kluge: collect RCS revision info without $...$\xdef\manvers{2.10.91}  % For use in headers, footers too{\parskip=0pt\hfill Cygnus Support\par\hfill \manvers\par\hfill \TeX{}info \texinfoversion\par}@end tex@vskip 0pt plus 1filllCopyright @copyright{} 1992, 93, 94, 95, 96, 97, 1998, 2000Free Software Foundation, Inc.      Permission is granted to copy, distribute and/or modify this document      under the terms of the GNU Free Documentation License, Version 1.1      or any later version published by the Free Software Foundation;      with no Invariant Sections, with no Front-Cover Texts, and with no      Back-Cover Texts.  A copy of the license is included in the      section entitled "GNU Free Documentation License".@end titlepage@end iftex@node Top@topThis file documents the internals of the GNU linker @code{ld}.  It is acollection of miscellaneous information with little form at this point.Mostly, it is a repository into which you can put information aboutGNU @code{ld} as you discover it (or as you design changes to @code{ld}).This document is distributed under the terms of the GNU FreeDocumentation License.  A copy of the license is included in thesection entitled "GNU Free Documentation License".@menu* README::			The README File* Emulations::			How linker emulations are generated* Emulation Walkthrough::	A Walkthrough of a Typical Emulation* GNU Free Documentation License::  GNU Free Documentation License@end menu@node README@chapter The @file{README} FileCheck the @file{README} file; it often has useful information that does notappear anywhere else in the directory.@node Emulations@chapter How linker emulations are generatedEach linker target has an @dfn{emulation}.  The emulation includes thedefault linker script, and certain emulations also modify certain typesof linker behaviour.Emulations are created during the build process by the shell script@file{genscripts.sh}.The @file{genscripts.sh} script starts by reading a file in the@file{emulparams} directory.  This is a shell script which sets variousshell variables used by @file{genscripts.sh} and the other shell scriptsit invokes.The @file{genscripts.sh} script will invoke a shell script in the@file{scripttempl} directory in order to create default linker scriptswritten in the linker command language.  The @file{scripttempl} scriptwill be invoked 5 (or, in some cases, 6) times, with differentassignments to shell variables, to create different default scripts.The choice of script is made based on the command line options.After creating the scripts, @file{genscripts.sh} will invoke yet anothershell script, this time in the @file{emultempl} directory.  That shellscript will create the emulation source file, which contains C code.This C code permits the linker emulation to override various linkerbehaviours.  Most targets use the generic emulation code, which is in@file{emultempl/generic.em}.To summarize, @file{genscripts.sh} reads three shell scripts: anemulation parameters script in the @file{emulparams} directory, a linkerscript generation script in the @file{scripttempl} directory, and anemulation source file generation script in the @file{emultempl}directory.For example, the Sun 4 linker sets up variables in@file{emulparams/sun4.sh}, creates linker scripts using@file{scripttempl/aout.sc}, and creates the emulation code using@file{emultempl/sunos.em}.Note that the linker can support several emulations simultaneously,depending upon how it is configured.  An emulation can be selected withthe @code{-m} option.  The @code{-V} option will list all supportedemulations.@menu* emulation parameters::        @file{emulparams} scripts* linker scripts::              @file{scripttempl} scripts* linker emulations::           @file{emultempl} scripts@end menu@node emulation parameters@section @file{emulparams} scriptsEach target selects a particular file in the @file{emulparams} directoryby setting the shell variable @code{targ_emul} in @file{configure.tgt}.This shell variable is used by the @file{configure} script to controlbuilding an emulation source file.Certain conventions are enforced.  Suppose the @code{targ_emul} variableis set to @var{emul} in @file{configure.tgt}.  The name of the emulationshell script will be @file{emulparams/@var{emul}.sh}.  The@file{Makefile} must have a target named @file{e@var{emul}.c}; thistarget must depend upon @file{emulparams/@var{emul}.sh}, as well as theappropriate scripts in the @file{scripttempl} and @file{emultempl}directories.  The @file{Makefile} target must invoke @code{GENSCRIPTS}with two arguments: @var{emul}, and the value of the make variable@code{tdir_@var{emul}}.  The value of the latter variable will be set bythe @file{configure} script, and is used to set the default targetdirectory to search.By convention, the @file{emulparams/@var{emul}.sh} shell script shouldonly set shell variables.  It may set shell variables which are to beinterpreted by the @file{scripttempl} and the @file{emultempl} scripts.Certain shell variables are interpreted directly by the@file{genscripts.sh} script.Here is a list of shell variables interpreted by @file{genscripts.sh},as well as some conventional shell variables interpreted by the@file{scripttempl} and @file{emultempl} scripts.@table @code@item SCRIPT_NAMEThis is the name of the @file{scripttempl} script to use.  If@code{SCRIPT_NAME} is set to @var{script}, @file{genscripts.sh} will usethe script @file{scriptteml/@var{script}.sc}.@item TEMPLATE_NAMEThis is the name of the @file{emultemlp} script to use.  If@code{TEMPLATE_NAME} is set to @var{template}, @file{genscripts.sh} willuse the script @file{emultempl/@var{template}.em}.  If this variable isnot set, the default value is @samp{generic}.@item GENERATE_SHLIB_SCRIPTIf this is set to a nonempty string, @file{genscripts.sh} will invokethe @file{scripttempl} script an extra time to create a shared libraryscript.  @ref{linker scripts}.@item OUTPUT_FORMATThis is normally set to indicate the BFD output format use (e.g.,@samp{"a.out-sunos-big"}.  The @file{scripttempl} script will normallyuse it in an @code{OUTPUT_FORMAT} expression in the linker script.@item ARCHThis is normally set to indicate the architecture to use (e.g.,@samp{sparc}).  The @file{scripttempl} script will normally use it in an@code{OUTPUT_ARCH} expression in the linker script.@item ENTRYSome @file{scripttempl} scripts use this to set the entry address, in an@code{ENTRY} expression in the linker script.@item TEXT_START_ADDRSome @file{scripttempl} scripts use this to set the start address of the@samp{.text} section.@item NONPAGED_TEXT_START_ADDRIf this is defined, the @file{genscripts.sh} script sets@code{TEXT_START_ADDR} to its value before running the@file{scripttempl} script for the @code{-n} and @code{-N} options(@pxref{linker scripts}).@item SEGMENT_SIZEThe @file{genscripts.sh} script uses this to set the default value of@code{DATA_ALIGNMENT} when running the @file{scripttempl} script.@item TARGET_PAGE_SIZEIf @code{SEGMENT_SIZE} is not defined, the @file{genscripts.sh} scriptuses this to define it.@item ALIGNMENTSome @file{scripttempl} scripts set this to a number to pass to@code{ALIGN} to set the required alignment for the @code{end} symbol.@end table@node linker scripts@section @file{scripttempl} scriptsEach linker target uses a @file{scripttempl} script to generate thedefault linker scripts.  The name of the @file{scripttempl} script isset by the @code{SCRIPT_NAME} variable in the @file{emulparams} script.If @code{SCRIPT_NAME} is set to @var{script}, @code{genscripts.sh} willinvoke @file{scripttempl/@var{script}.sc}.The @file{genscripts.sh} script will invoke the @file{scripttempl}script 5 or 6 times.  Each time it will set the shell variable@code{LD_FLAG} to a different value.  When the linker is run, theoptions used will direct it to select a particular script.  (Scriptselection is controlled by the @code{get_script} emulation entry point;this describes the conventional behaviour).The @file{scripttempl} script should just write a linker script, writtenin the linker command language, to standard output.  If the emulationname--the name of the @file{emulparams} file without the @file{.sc}extension--is @var{emul}, then the output will be directed to@file{ldscripts/@var{emul}.@var{extension}} in the build directory,where @var{extension} changes each time the @file{scripttempl} script isinvoked.Here is the list of values assigned to @code{LD_FLAG}.@table @code@item (empty)The script generated is used by default (when none of the followingcases apply).  The output has an extension of @file{.x}.@item nThe script generated is used when the linker is invoked with the@code{-n} option.  The output has an extension of @file{.xn}.@item NThe script generated is used when the linker is invoked with the@code{-N} option.  The output has an extension of @file{.xbn}.@item rThe script generated is used when the linker is invoked with the@code{-r} option.  The output has an extension of @file{.xr}.@item uThe script generated is used when the linker is invoked with the@code{-Ur} option.  The output has an extension of @file{.xu}.@item sharedThe @file{scripttempl} script is only invoked with @code{LD_FLAG} set tothis value if @code{GENERATE_SHLIB_SCRIPT} is defined in the@file{emulparams} file.  The @file{emultempl} script must arrange to usethis script at the appropriate time, normally when the linker is invokedwith the @code{-shared} option.  The output has an extension of@file{.xs}.@end tableBesides the shell variables set by the @file{emulparams} script, and the@code{LD_FLAG} variable, the @file{genscripts.sh} script will setcertain variables for each run of the @file{scripttempl} script.@table @code@item RELOCATINGThis will be set to a non-empty string when the linker is doing a finalrelocation (e.g., all scripts other than @code{-r} and @code{-Ur}).@item CONSTRUCTINGThis will be set to a non-empty string when the linker is buildingglobal constructor and destructor tables (e.g., all scripts other than@code{-r}).@item DATA_ALIGNMENTThis will be set to an @code{ALIGN} expression when the output should bepage aligned, or to @samp{.} when generating the @code{-N} script.@item CREATE_SHLIBThis will be set to a non-empty string when generating a @code{-shared}script.@end tableThe conventional way to write a @file{scripttempl} script is to firstset a few shell variables, and then write out a linker script using@code{cat} with a here document.  The linker script will use variablesubstitutions, based on the above variables and those set in the@file{emulparams} script, to control its behaviour.When there are parts of the @file{scripttempl} script which should onlybe run when doing a final relocation, they should be enclosed within avariable substitution based on @code{RELOCATING}.  For example, on many

⌨️ 快捷键说明

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