Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the GNU linker LD
  4. (GNU Arm Embedded Toolchain 10-2020-q4-major)
  5. version 2.35.1.
  6. Copyright (C) 1991-2020 Free Software Foundation, Inc.
  7. Permission is granted to copy, distribute and/or modify this document
  8. under the terms of the GNU Free Documentation License, Version 1.3
  9. or any later version published by the Free Software Foundation;
  10. with no Invariant Sections, with no Front-Cover Texts, and with no
  11. Back-Cover Texts. A copy of the license is included in the
  12. section entitled "GNU Free Documentation License". -->
  13. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Options (LD)</title>
  17. <meta name="description" content="Options (LD)">
  18. <meta name="keywords" content="Options (LD)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="LD-Index.html#LD-Index" rel="index" title="LD Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Invocation.html#Invocation" rel="up" title="Invocation">
  26. <link href="Environment.html#Environment" rel="next" title="Environment">
  27. <link href="Invocation.html#Invocation" rel="prev" title="Invocation">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style: oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Options"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Environment.html#Environment" accesskey="n" rel="next">Environment</a>, Up: <a href="Invocation.html#Invocation" accesskey="u" rel="up">Invocation</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Command_002dline-Options"></a>
  64. <h3 class="section">2.1 Command-line Options</h3>
  65. <a name="index-command-line"></a>
  66. <a name="index-options"></a>
  67. <p>The linker supports a plethora of command-line options, but in actual
  68. practice few of them are used in any particular context.
  69. <a name="index-standard-Unix-system"></a>
  70. For instance, a frequent use of <code>ld</code> is to link standard Unix
  71. object files on a standard, supported Unix system. On such a system, to
  72. link a file <code>hello.o</code>:
  73. </p>
  74. <div class="smallexample">
  75. <pre class="smallexample">ld -o <var>output</var> /lib/crt0.o hello.o -lc
  76. </pre></div>
  77. <p>This tells <code>ld</code> to produce a file called <var>output</var> as the
  78. result of linking the file <code>/lib/crt0.o</code> with <code>hello.o</code> and
  79. the library <code>libc.a</code>, which will come from the standard search
  80. directories. (See the discussion of the &lsquo;<samp>-l</samp>&rsquo; option below.)
  81. </p>
  82. <p>Some of the command-line options to <code>ld</code> may be specified at any
  83. point in the command line. However, options which refer to files, such
  84. as &lsquo;<samp>-l</samp>&rsquo; or &lsquo;<samp>-T</samp>&rsquo;, cause the file to be read at the point at
  85. which the option appears in the command line, relative to the object
  86. files and other file options. Repeating non-file options with a
  87. different argument will either have no further effect, or override prior
  88. occurrences (those further to the left on the command line) of that
  89. option. Options which may be meaningfully specified more than once are
  90. noted in the descriptions below.
  91. </p>
  92. <a name="index-object-files"></a>
  93. <p>Non-option arguments are object files or archives which are to be linked
  94. together. They may follow, precede, or be mixed in with command-line
  95. options, except that an object file argument may not be placed between
  96. an option and its argument.
  97. </p>
  98. <p>Usually the linker is invoked with at least one object file, but you can
  99. specify other forms of binary input files using &lsquo;<samp>-l</samp>&rsquo;, &lsquo;<samp>-R</samp>&rsquo;,
  100. and the script command language. If <em>no</em> binary input files at all
  101. are specified, the linker does not produce any output, and issues the
  102. message &lsquo;<samp>No input files</samp>&rsquo;.
  103. </p>
  104. <p>If the linker cannot recognize the format of an object file, it will
  105. assume that it is a linker script. A script specified in this way
  106. augments the main linker script used for the link (either the default
  107. linker script or the one specified by using &lsquo;<samp>-T</samp>&rsquo;). This feature
  108. permits the linker to link against a file which appears to be an object
  109. or an archive, but actually merely defines some symbol values, or uses
  110. <code>INPUT</code> or <code>GROUP</code> to load other objects. Specifying a
  111. script in this way merely augments the main linker script, with the
  112. extra commands placed after the main script; use the &lsquo;<samp>-T</samp>&rsquo; option
  113. to replace the default linker script entirely, but note the effect of
  114. the <code>INSERT</code> command. See <a href="Scripts.html#Scripts">Scripts</a>.
  115. </p>
  116. <p>For options whose names are a single letter,
  117. option arguments must either follow the option letter without intervening
  118. whitespace, or be given as separate arguments immediately following the
  119. option that requires them.
  120. </p>
  121. <p>For options whose names are multiple letters, either one dash or two can
  122. precede the option name; for example, &lsquo;<samp>-trace-symbol</samp>&rsquo; and
  123. &lsquo;<samp>--trace-symbol</samp>&rsquo; are equivalent. Note&mdash;there is one exception to
  124. this rule. Multiple letter options that start with a lower case &rsquo;o&rsquo; can
  125. only be preceded by two dashes. This is to reduce confusion with the
  126. &lsquo;<samp>-o</samp>&rsquo; option. So for example &lsquo;<samp>-omagic</samp>&rsquo; sets the output file
  127. name to &lsquo;<samp>magic</samp>&rsquo; whereas &lsquo;<samp>--omagic</samp>&rsquo; sets the NMAGIC flag on the
  128. output.
  129. </p>
  130. <p>Arguments to multiple-letter options must either be separated from the
  131. option name by an equals sign, or be given as separate arguments
  132. immediately following the option that requires them. For example,
  133. &lsquo;<samp>--trace-symbol foo</samp>&rsquo; and &lsquo;<samp>--trace-symbol=foo</samp>&rsquo; are equivalent.
  134. Unique abbreviations of the names of multiple-letter options are
  135. accepted.
  136. </p>
  137. <p>Note&mdash;if the linker is being invoked indirectly, via a compiler driver
  138. (e.g. &lsquo;<samp>gcc</samp>&rsquo;) then all the linker command-line options should be
  139. prefixed by &lsquo;<samp>-Wl,</samp>&rsquo; (or whatever is appropriate for the particular
  140. compiler driver) like this:
  141. </p>
  142. <div class="smallexample">
  143. <pre class="smallexample"> gcc -Wl,--start-group foo.o bar.o -Wl,--end-group
  144. </pre></div>
  145. <p>This is important, because otherwise the compiler driver program may
  146. silently drop the linker options, resulting in a bad link. Confusion
  147. may also arise when passing options that require values through a
  148. driver, as the use of a space between option and argument acts as
  149. a separator, and causes the driver to pass only the option to the linker
  150. and the argument to the compiler. In this case, it is simplest to use
  151. the joined forms of both single- and multiple-letter options, such as:
  152. </p>
  153. <div class="smallexample">
  154. <pre class="smallexample"> gcc foo.o bar.o -Wl,-eENTRY -Wl,-Map=a.map
  155. </pre></div>
  156. <p>Here is a table of the generic command-line switches accepted by the GNU
  157. linker:
  158. </p>
  159. <dl compact="compact">
  160. <dt><code>@<var>file</var></code></dt>
  161. <dd><p>Read command-line options from <var>file</var>. The options read are
  162. inserted in place of the original @<var>file</var> option. If <var>file</var>
  163. does not exist, or cannot be read, then the option will be treated
  164. literally, and not removed.
  165. </p>
  166. <p>Options in <var>file</var> are separated by whitespace. A whitespace
  167. character may be included in an option by surrounding the entire
  168. option in either single or double quotes. Any character (including a
  169. backslash) may be included by prefixing the character to be included
  170. with a backslash. The <var>file</var> may itself contain additional
  171. @<var>file</var> options; any such options will be processed recursively.
  172. </p>
  173. <a name="index-_002da-keyword"></a>
  174. </dd>
  175. <dt><code>-a <var>keyword</var></code></dt>
  176. <dd><p>This option is supported for HP/UX compatibility. The <var>keyword</var>
  177. argument must be one of the strings &lsquo;<samp>archive</samp>&rsquo;, &lsquo;<samp>shared</samp>&rsquo;, or
  178. &lsquo;<samp>default</samp>&rsquo;. &lsquo;<samp>-aarchive</samp>&rsquo; is functionally equivalent to
  179. &lsquo;<samp>-Bstatic</samp>&rsquo;, and the other two keywords are functionally equivalent
  180. to &lsquo;<samp>-Bdynamic</samp>&rsquo;. This option may be used any number of times.
  181. </p>
  182. <a name="index-_002d_002daudit-AUDITLIB"></a>
  183. </dd>
  184. <dt><code>--audit <var>AUDITLIB</var></code></dt>
  185. <dd><p>Adds <var>AUDITLIB</var> to the <code>DT_AUDIT</code> entry of the dynamic section.
  186. <var>AUDITLIB</var> is not checked for existence, nor will it use the DT_SONAME
  187. specified in the library. If specified multiple times <code>DT_AUDIT</code>
  188. will contain a colon separated list of audit interfaces to use. If the linker
  189. finds an object with an audit entry while searching for shared libraries,
  190. it will add a corresponding <code>DT_DEPAUDIT</code> entry in the output file.
  191. This option is only meaningful on ELF platforms supporting the rtld-audit
  192. interface.
  193. </p>
  194. <a name="index-binary-input-format"></a>
  195. <a name="index-_002db-format"></a>
  196. <a name="index-_002d_002dformat_003dformat"></a>
  197. <a name="index-input-format"></a>
  198. <a name="index-input-format-1"></a>
  199. </dd>
  200. <dt><code>-b <var>input-format</var></code></dt>
  201. <dt><code>--format=<var>input-format</var></code></dt>
  202. <dd><p><code>ld</code> may be configured to support more than one kind of object
  203. file. If your <code>ld</code> is configured this way, you can use the
  204. &lsquo;<samp>-b</samp>&rsquo; option to specify the binary format for input object files
  205. that follow this option on the command line. Even when <code>ld</code> is
  206. configured to support alternative object formats, you don&rsquo;t usually need
  207. to specify this, as <code>ld</code> should be configured to expect as a
  208. default input format the most usual format on each machine.
  209. <var>input-format</var> is a text string, the name of a particular format
  210. supported by the BFD libraries. (You can list the available binary
  211. formats with &lsquo;<samp>objdump -i</samp>&rsquo;.)
  212. See <a href="BFD.html#BFD">BFD</a>.
  213. </p>
  214. <p>You may want to use this option if you are linking files with an unusual
  215. binary format. You can also use &lsquo;<samp>-b</samp>&rsquo; to switch formats explicitly (when
  216. linking object files of different formats), by including
  217. &lsquo;<samp>-b <var>input-format</var></samp>&rsquo; before each group of object files in a
  218. particular format.
  219. </p>
  220. <p>The default format is taken from the environment variable
  221. <code>GNUTARGET</code>.
  222. See <a href="Environment.html#Environment">Environment</a>.
  223. You can also define the input format from a script, using the command
  224. <code>TARGET</code>;
  225. see <a href="Format-Commands.html#Format-Commands">Format Commands</a>.
  226. </p>
  227. <a name="index-_002dc-MRI_002dcmdfile"></a>
  228. <a name="index-_002d_002dmri_002dscript_003dMRI_002dcmdfile"></a>
  229. <a name="index-compatibility_002c-MRI"></a>
  230. </dd>
  231. <dt><code>-c <var>MRI-commandfile</var></code></dt>
  232. <dt><code>--mri-script=<var>MRI-commandfile</var></code></dt>
  233. <dd><p>For compatibility with linkers produced by MRI, <code>ld</code> accepts script
  234. files written in an alternate, restricted command language, described in
  235. <a href="MRI.html#MRI">MRI Compatible Script Files</a>.
  236. Introduce MRI script files with
  237. the option &lsquo;<samp>-c</samp>&rsquo;; use the &lsquo;<samp>-T</samp>&rsquo; option to run linker
  238. scripts written in the general-purpose <code>ld</code> scripting language.
  239. If <var>MRI-cmdfile</var> does not exist, <code>ld</code> looks for it in the directories
  240. specified by any &lsquo;<samp>-L</samp>&rsquo; options.
  241. </p>
  242. <a name="index-common-allocation"></a>
  243. <a name="index-_002dd"></a>
  244. <a name="index-_002ddc"></a>
  245. <a name="index-_002ddp"></a>
  246. </dd>
  247. <dt><code>-d</code></dt>
  248. <dt><code>-dc</code></dt>
  249. <dt><code>-dp</code></dt>
  250. <dd><p>These three options are equivalent; multiple forms are supported for
  251. compatibility with other linkers. They assign space to common symbols
  252. even if a relocatable output file is specified (with &lsquo;<samp>-r</samp>&rsquo;). The
  253. script command <code>FORCE_COMMON_ALLOCATION</code> has the same effect.
  254. See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>.
  255. </p>
  256. <a name="index-_002d_002ddepaudit-AUDITLIB"></a>
  257. <a name="index-_002dP-AUDITLIB"></a>
  258. </dd>
  259. <dt><code>--depaudit <var>AUDITLIB</var></code></dt>
  260. <dt><code>-P <var>AUDITLIB</var></code></dt>
  261. <dd><p>Adds <var>AUDITLIB</var> to the <code>DT_DEPAUDIT</code> entry of the dynamic section.
  262. <var>AUDITLIB</var> is not checked for existence, nor will it use the DT_SONAME
  263. specified in the library. If specified multiple times <code>DT_DEPAUDIT</code>
  264. will contain a colon separated list of audit interfaces to use. This
  265. option is only meaningful on ELF platforms supporting the rtld-audit interface.
  266. The -P option is provided for Solaris compatibility.
  267. </p>
  268. <a name="index-_002d_002denable_002dnon_002dcontiguous_002dregions"></a>
  269. </dd>
  270. <dt><code>--enable-non-contiguous-regions</code></dt>
  271. <dd><p>This option avoids generating an error if an input section does not
  272. fit a matching output section. The linker tries to allocate the input
  273. section to subseque nt matching output sections, and generates an
  274. error only if no output section is large enough. This is useful when
  275. several non-contiguous memory regions are available and the input
  276. section does not require a particular one. The order in which input
  277. sections are evaluated does not change, for instance:
  278. </p>
  279. <div class="smallexample">
  280. <pre class="smallexample"> MEMORY {
  281. MEM1 (rwx) : ORIGIN : 0x1000, LENGTH = 0x14
  282. MEM2 (rwx) : ORIGIN : 0x1000, LENGTH = 0x40
  283. MEM3 (rwx) : ORIGIN : 0x2000, LENGTH = 0x40
  284. }
  285. SECTIONS {
  286. mem1 : { *(.data.*); } &gt; MEM1
  287. mem2 : { *(.data.*); } &gt; MEM2
  288. mem3 : { *(.data.*); } &gt; MEM2
  289. }
  290. with input sections:
  291. .data.1: size 8
  292. .data.2: size 0x10
  293. .data.3: size 4
  294. results in .data.1 affected to mem1, and .data.2 and .data.3
  295. affected to mem2, even though .data.3 would fit in mem3.
  296. </pre></div>
  297. <p>This option is incompatible with INSERT statements because it changes
  298. the way input sections are mapped to output sections.
  299. </p>
  300. <a name="index-_002d_002denable_002dnon_002dcontiguous_002dregions_002dwarnings"></a>
  301. </dd>
  302. <dt><code>--enable-non-contiguous-regions-warnings</code></dt>
  303. <dd><p>This option enables warnings when
  304. <code>--enable-non-contiguous-regions</code> allows possibly unexpected
  305. matches in sections mapping, potentially leading to silently
  306. discarding a section instead of failing because it does not fit any
  307. output region.
  308. </p>
  309. <a name="index-entry-point_002c-from-command-line"></a>
  310. <a name="index-_002de-entry"></a>
  311. <a name="index-_002d_002dentry_003dentry"></a>
  312. </dd>
  313. <dt><code>-e <var>entry</var></code></dt>
  314. <dt><code>--entry=<var>entry</var></code></dt>
  315. <dd><p>Use <var>entry</var> as the explicit symbol for beginning execution of your
  316. program, rather than the default entry point. If there is no symbol
  317. named <var>entry</var>, the linker will try to parse <var>entry</var> as a number,
  318. and use that as the entry address (the number will be interpreted in
  319. base 10; you may use a leading &lsquo;<samp>0x</samp>&rsquo; for base 16, or a leading
  320. &lsquo;<samp>0</samp>&rsquo; for base 8). See <a href="Entry-Point.html#Entry-Point">Entry Point</a>, for a discussion of defaults
  321. and other ways of specifying the entry point.
  322. </p>
  323. <a name="index-_002d_002dexclude_002dlibs"></a>
  324. </dd>
  325. <dt><code>--exclude-libs <var>lib</var>,<var>lib</var>,...</code></dt>
  326. <dd><p>Specifies a list of archive libraries from which symbols should not be automatically
  327. exported. The library names may be delimited by commas or colons. Specifying
  328. <code>--exclude-libs ALL</code> excludes symbols in all archive libraries from
  329. automatic export. This option is available only for the i386 PE targeted
  330. port of the linker and for ELF targeted ports. For i386 PE, symbols
  331. explicitly listed in a .def file are still exported, regardless of this
  332. option. For ELF targeted ports, symbols affected by this option will
  333. be treated as hidden.
  334. </p>
  335. <a name="index-_002d_002dexclude_002dmodules_002dfor_002dimplib"></a>
  336. </dd>
  337. <dt><code>--exclude-modules-for-implib <var>module</var>,<var>module</var>,...</code></dt>
  338. <dd><p>Specifies a list of object files or archive members, from which symbols
  339. should not be automatically exported, but which should be copied wholesale
  340. into the import library being generated during the link. The module names
  341. may be delimited by commas or colons, and must match exactly the filenames
  342. used by <code>ld</code> to open the files; for archive members, this is simply
  343. the member name, but for object files the name listed must include and
  344. match precisely any path used to specify the input file on the linker&rsquo;s
  345. command-line. This option is available only for the i386 PE targeted port
  346. of the linker. Symbols explicitly listed in a .def file are still exported,
  347. regardless of this option.
  348. </p>
  349. <a name="index-dynamic-symbol-table"></a>
  350. <a name="index-_002dE"></a>
  351. <a name="index-_002d_002dexport_002ddynamic"></a>
  352. <a name="index-_002d_002dno_002dexport_002ddynamic"></a>
  353. </dd>
  354. <dt><code>-E</code></dt>
  355. <dt><code>--export-dynamic</code></dt>
  356. <dt><code>--no-export-dynamic</code></dt>
  357. <dd><p>When creating a dynamically linked executable, using the <samp>-E</samp>
  358. option or the <samp>--export-dynamic</samp> option causes the linker to add
  359. all symbols to the dynamic symbol table. The dynamic symbol table is the
  360. set of symbols which are visible from dynamic objects at run time.
  361. </p>
  362. <p>If you do not use either of these options (or use the
  363. <samp>--no-export-dynamic</samp> option to restore the default behavior), the
  364. dynamic symbol table will normally contain only those symbols which are
  365. referenced by some dynamic object mentioned in the link.
  366. </p>
  367. <p>If you use <code>dlopen</code> to load a dynamic object which needs to refer
  368. back to the symbols defined by the program, rather than some other
  369. dynamic object, then you will probably need to use this option when
  370. linking the program itself.
  371. </p>
  372. <p>You can also use the dynamic list to control what symbols should
  373. be added to the dynamic symbol table if the output format supports it.
  374. See the description of &lsquo;<samp>--dynamic-list</samp>&rsquo;.
  375. </p>
  376. <p>Note that this option is specific to ELF targeted ports. PE targets
  377. support a similar function to export all symbols from a DLL or EXE; see
  378. the description of &lsquo;<samp>--export-all-symbols</samp>&rsquo; below.
  379. </p>
  380. <a name="index-_002d_002dexport_002ddynamic_002dsymbol_003dglob"></a>
  381. <a name="index-export-dynamic-symbol"></a>
  382. </dd>
  383. <dt><code>--export-dynamic-symbol=<var>glob</var></code></dt>
  384. <dd><p>When creating a dynamically linked executable, symbols matching
  385. <var>glob</var> will be added to the dynamic symbol table. When creating a
  386. shared library, references to symbols matching <var>glob</var> will not be
  387. bound to the definitions within the shared library. This option is a
  388. no-op when creating a shared library and &lsquo;<samp>-Bsymbolic</samp>&rsquo; or
  389. &lsquo;<samp>--dynamic-list</samp>&rsquo; are not specified. This option is only meaningful
  390. on ELF platforms which support shared libraries.
  391. </p>
  392. <a name="index-_002d_002dexport_002ddynamic_002dsymbol_002dlist_003dfile"></a>
  393. <a name="index-export-dynamic-symbol-list"></a>
  394. </dd>
  395. <dt><code>--export-dynamic-symbol-list=<var>file</var></code></dt>
  396. <dd><p>Specify a &lsquo;<samp>--export-dynamic-symbol</samp>&rsquo; for each pattern in the file.
  397. The format of the file is the same as the version node without
  398. scope and node name. See <a href="VERSION.html#VERSION">VERSION</a> for more information.
  399. </p>
  400. <a name="index-big_002dendian-objects"></a>
  401. <a name="index-endianness"></a>
  402. <a name="index-_002dEB"></a>
  403. </dd>
  404. <dt><code>-EB</code></dt>
  405. <dd><p>Link big-endian objects. This affects the default output format.
  406. </p>
  407. <a name="index-little_002dendian-objects"></a>
  408. <a name="index-_002dEL"></a>
  409. </dd>
  410. <dt><code>-EL</code></dt>
  411. <dd><p>Link little-endian objects. This affects the default output format.
  412. </p>
  413. <a name="index-_002df-name"></a>
  414. <a name="index-_002d_002dauxiliary_003dname"></a>
  415. </dd>
  416. <dt><code>-f <var>name</var></code></dt>
  417. <dt><code>--auxiliary=<var>name</var></code></dt>
  418. <dd><p>When creating an ELF shared object, set the internal DT_AUXILIARY field
  419. to the specified name. This tells the dynamic linker that the symbol
  420. table of the shared object should be used as an auxiliary filter on the
  421. symbol table of the shared object <var>name</var>.
  422. </p>
  423. <p>If you later link a program against this filter object, then, when you
  424. run the program, the dynamic linker will see the DT_AUXILIARY field. If
  425. the dynamic linker resolves any symbols from the filter object, it will
  426. first check whether there is a definition in the shared object
  427. <var>name</var>. If there is one, it will be used instead of the definition
  428. in the filter object. The shared object <var>name</var> need not exist.
  429. Thus the shared object <var>name</var> may be used to provide an alternative
  430. implementation of certain functions, perhaps for debugging or for
  431. machine-specific performance.
  432. </p>
  433. <p>This option may be specified more than once. The DT_AUXILIARY entries
  434. will be created in the order in which they appear on the command line.
  435. </p>
  436. <a name="index-_002dF-name"></a>
  437. <a name="index-_002d_002dfilter_003dname"></a>
  438. </dd>
  439. <dt><code>-F <var>name</var></code></dt>
  440. <dt><code>--filter=<var>name</var></code></dt>
  441. <dd><p>When creating an ELF shared object, set the internal DT_FILTER field to
  442. the specified name. This tells the dynamic linker that the symbol table
  443. of the shared object which is being created should be used as a filter
  444. on the symbol table of the shared object <var>name</var>.
  445. </p>
  446. <p>If you later link a program against this filter object, then, when you
  447. run the program, the dynamic linker will see the DT_FILTER field. The
  448. dynamic linker will resolve symbols according to the symbol table of the
  449. filter object as usual, but it will actually link to the definitions
  450. found in the shared object <var>name</var>. Thus the filter object can be
  451. used to select a subset of the symbols provided by the object
  452. <var>name</var>.
  453. </p>
  454. <p>Some older linkers used the <samp>-F</samp> option throughout a compilation
  455. toolchain for specifying object-file format for both input and output
  456. object files.
  457. The <small>GNU</small> linker uses other mechanisms for this purpose: the
  458. <samp>-b</samp>, <samp>--format</samp>, <samp>--oformat</samp> options, the
  459. <code>TARGET</code> command in linker scripts, and the <code>GNUTARGET</code>
  460. environment variable.
  461. The <small>GNU</small> linker will ignore the <samp>-F</samp> option when not
  462. creating an ELF shared object.
  463. </p>
  464. <a name="index-finalization-function"></a>
  465. <a name="index-_002dfini_003dname"></a>
  466. </dd>
  467. <dt><code>-fini=<var>name</var></code></dt>
  468. <dd><p>When creating an ELF executable or shared object, call NAME when the
  469. executable or shared object is unloaded, by setting DT_FINI to the
  470. address of the function. By default, the linker uses <code>_fini</code> as
  471. the function to call.
  472. </p>
  473. <a name="index-_002dg"></a>
  474. </dd>
  475. <dt><code>-g</code></dt>
  476. <dd><p>Ignored. Provided for compatibility with other tools.
  477. </p>
  478. <a name="index-_002dG-value"></a>
  479. <a name="index-_002d_002dgpsize_003dvalue"></a>
  480. <a name="index-object-size"></a>
  481. </dd>
  482. <dt><code>-G <var>value</var></code></dt>
  483. <dt><code>--gpsize=<var>value</var></code></dt>
  484. <dd><p>Set the maximum size of objects to be optimized using the GP register to
  485. <var>size</var>. This is only meaningful for object file formats such as
  486. MIPS ELF that support putting large and small objects into different
  487. sections. This is ignored for other object file formats.
  488. </p>
  489. <a name="index-runtime-library-name"></a>
  490. <a name="index-_002dh-name"></a>
  491. <a name="index-_002dsoname_003dname"></a>
  492. </dd>
  493. <dt><code>-h <var>name</var></code></dt>
  494. <dt><code>-soname=<var>name</var></code></dt>
  495. <dd><p>When creating an ELF shared object, set the internal DT_SONAME field to
  496. the specified name. When an executable is linked with a shared object
  497. which has a DT_SONAME field, then when the executable is run the dynamic
  498. linker will attempt to load the shared object specified by the DT_SONAME
  499. field rather than the using the file name given to the linker.
  500. </p>
  501. <a name="index-_002di"></a>
  502. <a name="index-incremental-link"></a>
  503. </dd>
  504. <dt><code>-i</code></dt>
  505. <dd><p>Perform an incremental link (same as option &lsquo;<samp>-r</samp>&rsquo;).
  506. </p>
  507. <a name="index-initialization-function"></a>
  508. <a name="index-_002dinit_003dname"></a>
  509. </dd>
  510. <dt><code>-init=<var>name</var></code></dt>
  511. <dd><p>When creating an ELF executable or shared object, call NAME when the
  512. executable or shared object is loaded, by setting DT_INIT to the address
  513. of the function. By default, the linker uses <code>_init</code> as the
  514. function to call.
  515. </p>
  516. <a name="index-archive-files_002c-from-cmd-line"></a>
  517. <a name="index-_002dl-namespec"></a>
  518. <a name="index-_002d_002dlibrary_003dnamespec"></a>
  519. </dd>
  520. <dt><code>-l <var>namespec</var></code></dt>
  521. <dt><code>--library=<var>namespec</var></code></dt>
  522. <dd><p>Add the archive or object file specified by <var>namespec</var> to the
  523. list of files to link. This option may be used any number of times.
  524. If <var>namespec</var> is of the form <samp>:<var>filename</var></samp>, <code>ld</code>
  525. will search the library path for a file called <var>filename</var>, otherwise it
  526. will search the library path for a file called <samp>lib<var>namespec</var>.a</samp>.
  527. </p>
  528. <p>On systems which support shared libraries, <code>ld</code> may also search for
  529. files other than <samp>lib<var>namespec</var>.a</samp>. Specifically, on ELF
  530. and SunOS systems, <code>ld</code> will search a directory for a library
  531. called <samp>lib<var>namespec</var>.so</samp> before searching for one called
  532. <samp>lib<var>namespec</var>.a</samp>. (By convention, a <code>.so</code> extension
  533. indicates a shared library.) Note that this behavior does not apply
  534. to <samp>:<var>filename</var></samp>, which always specifies a file called
  535. <var>filename</var>.
  536. </p>
  537. <p>The linker will search an archive only once, at the location where it is
  538. specified on the command line. If the archive defines a symbol which
  539. was undefined in some object which appeared before the archive on the
  540. command line, the linker will include the appropriate file(s) from the
  541. archive. However, an undefined symbol in an object appearing later on
  542. the command line will not cause the linker to search the archive again.
  543. </p>
  544. <p>See the <samp>-(</samp> option for a way to force the linker to search
  545. archives multiple times.
  546. </p>
  547. <p>You may list the same archive multiple times on the command line.
  548. </p>
  549. <p>This type of archive searching is standard for Unix linkers. However,
  550. if you are using <code>ld</code> on AIX, note that it is different from the
  551. behaviour of the AIX linker.
  552. </p>
  553. <a name="index-search-directory_002c-from-cmd-line"></a>
  554. <a name="index-_002dL-dir"></a>
  555. <a name="index-_002d_002dlibrary_002dpath_003ddir"></a>
  556. </dd>
  557. <dt><code>-L <var>searchdir</var></code></dt>
  558. <dt><code>--library-path=<var>searchdir</var></code></dt>
  559. <dd><p>Add path <var>searchdir</var> to the list of paths that <code>ld</code> will search
  560. for archive libraries and <code>ld</code> control scripts. You may use this
  561. option any number of times. The directories are searched in the order
  562. in which they are specified on the command line. Directories specified
  563. on the command line are searched before the default directories. All
  564. <samp>-L</samp> options apply to all <samp>-l</samp> options, regardless of the
  565. order in which the options appear. <samp>-L</samp> options do not affect
  566. how <code>ld</code> searches for a linker script unless <samp>-T</samp>
  567. option is specified.
  568. </p>
  569. <p>If <var>searchdir</var> begins with <code>=</code> or <code>$SYSROOT</code>, then this
  570. prefix will be replaced by the <em>sysroot prefix</em>, controlled by the
  571. &lsquo;<samp>--sysroot</samp>&rsquo; option, or specified when the linker is configured.
  572. </p>
  573. <p>The default set of paths searched (without being specified with
  574. &lsquo;<samp>-L</samp>&rsquo;) depends on which emulation mode <code>ld</code> is using, and in
  575. some cases also on how it was configured. See <a href="Environment.html#Environment">Environment</a>.
  576. </p>
  577. <p>The paths can also be specified in a link script with the
  578. <code>SEARCH_DIR</code> command. Directories specified this way are searched
  579. at the point in which the linker script appears in the command line.
  580. </p>
  581. <a name="index-emulation"></a>
  582. <a name="index-_002dm-emulation"></a>
  583. </dd>
  584. <dt><code>-m <var>emulation</var></code></dt>
  585. <dd><p>Emulate the <var>emulation</var> linker. You can list the available
  586. emulations with the &lsquo;<samp>--verbose</samp>&rsquo; or &lsquo;<samp>-V</samp>&rsquo; options.
  587. </p>
  588. <p>If the &lsquo;<samp>-m</samp>&rsquo; option is not used, the emulation is taken from the
  589. <code>LDEMULATION</code> environment variable, if that is defined.
  590. </p>
  591. <p>Otherwise, the default emulation depends upon how the linker was
  592. configured.
  593. </p>
  594. <a name="index-link-map"></a>
  595. <a name="index-_002dM"></a>
  596. <a name="index-_002d_002dprint_002dmap"></a>
  597. </dd>
  598. <dt><code>-M</code></dt>
  599. <dt><code>--print-map</code></dt>
  600. <dd><p>Print a link map to the standard output. A link map provides
  601. information about the link, including the following:
  602. </p>
  603. <ul>
  604. <li> Where object files are mapped into memory.
  605. </li><li> How common symbols are allocated.
  606. </li><li> All archive members included in the link, with a mention of the symbol
  607. which caused the archive member to be brought in.
  608. </li><li> The values assigned to symbols.
  609. <p>Note - symbols whose values are computed by an expression which
  610. involves a reference to a previous value of the same symbol may not
  611. have correct result displayed in the link map. This is because the
  612. linker discards intermediate results and only retains the final value
  613. of an expression. Under such circumstances the linker will display
  614. the final value enclosed by square brackets. Thus for example a
  615. linker script containing:
  616. </p>
  617. <div class="smallexample">
  618. <pre class="smallexample"> foo = 1
  619. foo = foo * 4
  620. foo = foo + 8
  621. </pre></div>
  622. <p>will produce the following output in the link map if the <samp>-M</samp>
  623. option is used:
  624. </p>
  625. <div class="smallexample">
  626. <pre class="smallexample"> 0x00000001 foo = 0x1
  627. [0x0000000c] foo = (foo * 0x4)
  628. [0x0000000c] foo = (foo + 0x8)
  629. </pre></div>
  630. <p>See <a href="Expressions.html#Expressions">Expressions</a> for more information about expressions in linker
  631. scripts.
  632. </p>
  633. </li><li> How GNU properties are merged.
  634. <p>When the linker merges input .note.gnu.property sections into one output
  635. .note.gnu.property section, some properties are removed or updated.
  636. These actions are reported in the link map. For example:
  637. </p>
  638. <div class="smallexample">
  639. <pre class="smallexample">Removed property 0xc0000002 to merge foo.o (0x1) and bar.o (not found)
  640. </pre></div>
  641. <p>This indicates that property 0xc0000002 is removed from output when
  642. merging properties in <samp>foo.o</samp>, whose property 0xc0000002 value
  643. is 0x1, and <samp>bar.o</samp>, which doesn&rsquo;t have property 0xc0000002.
  644. </p>
  645. <div class="smallexample">
  646. <pre class="smallexample">Updated property 0xc0010001 (0x1) to merge foo.o (0x1) and bar.o (0x1)
  647. </pre></div>
  648. <p>This indicates that property 0xc0010001 value is updated to 0x1 in output
  649. when merging properties in <samp>foo.o</samp>, whose 0xc0010001 property value
  650. is 0x1, and <samp>bar.o</samp>, whose 0xc0010001 property value is 0x1.
  651. </p></li></ul>
  652. <a name="index-link-map-discarded"></a>
  653. <a name="index-_002d_002dprint_002dmap_002ddiscarded"></a>
  654. <a name="index-_002d_002dno_002dprint_002dmap_002ddiscarded"></a>
  655. </dd>
  656. <dt><code>--print-map-discarded</code></dt>
  657. <dt><code>--no-print-map-discarded</code></dt>
  658. <dd><p>Print (or do not print) the list of discarded and garbage collected sections
  659. in the link map. Enabled by default.
  660. </p>
  661. <a name="index-_002dn"></a>
  662. <a name="index-read_002donly-text"></a>
  663. <a name="index-NMAGIC"></a>
  664. <a name="index-_002d_002dnmagic"></a>
  665. </dd>
  666. <dt><code>-n</code></dt>
  667. <dt><code>--nmagic</code></dt>
  668. <dd><p>Turn off page alignment of sections, and disable linking against shared
  669. libraries. If the output format supports Unix style magic numbers,
  670. mark the output as <code>NMAGIC</code>.
  671. </p>
  672. <a name="index-_002dN"></a>
  673. <a name="index-_002d_002domagic"></a>
  674. <a name="index-read_002fwrite-from-cmd-line"></a>
  675. <a name="index-OMAGIC"></a>
  676. </dd>
  677. <dt><code>-N</code></dt>
  678. <dt><code>--omagic</code></dt>
  679. <dd><p>Set the text and data sections to be readable and writable. Also, do
  680. not page-align the data segment, and disable linking against shared
  681. libraries. If the output format supports Unix style magic numbers,
  682. mark the output as <code>OMAGIC</code>. Note: Although a writable text section
  683. is allowed for PE-COFF targets, it does not conform to the format
  684. specification published by Microsoft.
  685. </p>
  686. <a name="index-_002d_002dno_002domagic"></a>
  687. <a name="index-OMAGIC-1"></a>
  688. </dd>
  689. <dt><code>--no-omagic</code></dt>
  690. <dd><p>This option negates most of the effects of the <samp>-N</samp> option. It
  691. sets the text section to be read-only, and forces the data segment to
  692. be page-aligned. Note - this option does not enable linking against
  693. shared libraries. Use <samp>-Bdynamic</samp> for this.
  694. </p>
  695. <a name="index-_002do-output"></a>
  696. <a name="index-_002d_002doutput_003doutput"></a>
  697. <a name="index-naming-the-output-file"></a>
  698. </dd>
  699. <dt><code>-o <var>output</var></code></dt>
  700. <dt><code>--output=<var>output</var></code></dt>
  701. <dd><p>Use <var>output</var> as the name for the program produced by <code>ld</code>; if this
  702. option is not specified, the name <samp>a.out</samp> is used by default. The
  703. script command <code>OUTPUT</code> can also specify the output file name.
  704. </p>
  705. <a name="index-_002d_002ddependency_002dfile_003ddepfile"></a>
  706. <a name="index-dependency-file"></a>
  707. </dd>
  708. <dt><code>--dependency-file=<var>depfile</var></code></dt>
  709. <dd><p>Write a <em>dependency file</em> to <var>depfile</var>. This file contains a rule
  710. suitable for <code>make</code> describing the output file and all the input files
  711. that were read to produce it. The output is similar to the compiler&rsquo;s
  712. output with &lsquo;<samp>-M -MP</samp>&rsquo; (see <a href="http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options">Options
  713. Controlling the Preprocessor</a> in <cite>Using the GNU Compiler
  714. Collection</cite>). Note that there is no option like the compiler&rsquo;s &lsquo;<samp>-MM</samp>&rsquo;,
  715. to exclude &ldquo;system files&rdquo; (which is not a well-specified concept in the
  716. linker, unlike &ldquo;system headers&rdquo; in the compiler). So the output from
  717. &lsquo;<samp>--dependency-file</samp>&rsquo; is always specific to the exact state of the
  718. installation where it was produced, and should not be copied into
  719. distributed makefiles without careful editing.
  720. </p>
  721. <a name="index-_002dO-level"></a>
  722. <a name="index-generating-optimized-output"></a>
  723. </dd>
  724. <dt><code>-O <var>level</var></code></dt>
  725. <dd><p>If <var>level</var> is a numeric values greater than zero <code>ld</code> optimizes
  726. the output. This might take significantly longer and therefore probably
  727. should only be enabled for the final binary. At the moment this
  728. option only affects ELF shared library generation. Future releases of
  729. the linker may make more use of this option. Also currently there is
  730. no difference in the linker&rsquo;s behaviour for different non-zero values
  731. of this option. Again this may change with future releases.
  732. </p>
  733. <a name="index-_002dplugin-name"></a>
  734. </dd>
  735. <dt><code>-plugin <var>name</var></code></dt>
  736. <dd><p>Involve a plugin in the linking process. The <var>name</var> parameter is
  737. the absolute filename of the plugin. Usually this parameter is
  738. automatically added by the complier, when using link time
  739. optimization, but users can also add their own plugins if they so
  740. wish.
  741. </p>
  742. <p>Note that the location of the compiler originated plugins is different
  743. from the place where the <code>ar</code>, <code>nm</code> and
  744. <code>ranlib</code> programs search for their plugins. In order for
  745. those commands to make use of a compiler based plugin it must first be
  746. copied into the <samp>${libdir}/bfd-plugins</samp> directory. All gcc
  747. based linker plugins are backward compatible, so it is sufficient to
  748. just copy in the newest one.
  749. </p>
  750. <a name="index-_002d_002dpush_002dstate"></a>
  751. <a name="index-push-state-governing-input-file-handling"></a>
  752. </dd>
  753. <dt><code>--push-state</code></dt>
  754. <dd><p>The <samp>--push-state</samp> allows to preserve the current state of the
  755. flags which govern the input file handling so that they can all be
  756. restored with one corresponding <samp>--pop-state</samp> option.
  757. </p>
  758. <p>The option which are covered are: <samp>-Bdynamic</samp>, <samp>-Bstatic</samp>,
  759. <samp>-dn</samp>, <samp>-dy</samp>, <samp>-call_shared</samp>, <samp>-non_shared</samp>,
  760. <samp>-static</samp>, <samp>-N</samp>, <samp>-n</samp>, <samp>--whole-archive</samp>,
  761. <samp>--no-whole-archive</samp>, <samp>-r</samp>, <samp>-Ur</samp>,
  762. <samp>--copy-dt-needed-entries</samp>, <samp>--no-copy-dt-needed-entries</samp>,
  763. <samp>--as-needed</samp>, <samp>--no-as-needed</samp>, and <samp>-a</samp>.
  764. </p>
  765. <p>One target for this option are specifications for <samp>pkg-config</samp>. When
  766. used with the <samp>--libs</samp> option all possibly needed libraries are
  767. listed and then possibly linked with all the time. It is better to return
  768. something as follows:
  769. </p>
  770. <div class="smallexample">
  771. <pre class="smallexample">-Wl,--push-state,--as-needed -libone -libtwo -Wl,--pop-state
  772. </pre></div>
  773. <a name="index-_002d_002dpop_002dstate"></a>
  774. <a name="index-pop-state-governing-input-file-handling"></a>
  775. </dd>
  776. <dt><code>--pop-state</code></dt>
  777. <dd><p>Undoes the effect of &ndash;push-state, restores the previous values of the
  778. flags governing input file handling.
  779. </p>
  780. <a name="index-_002dq"></a>
  781. <a name="index-_002d_002demit_002drelocs"></a>
  782. <a name="index-retain-relocations-in-final-executable"></a>
  783. </dd>
  784. <dt><code>-q</code></dt>
  785. <dt><code>--emit-relocs</code></dt>
  786. <dd><p>Leave relocation sections and contents in fully linked executables.
  787. Post link analysis and optimization tools may need this information in
  788. order to perform correct modifications of executables. This results
  789. in larger executables.
  790. </p>
  791. <p>This option is currently only supported on ELF platforms.
  792. </p>
  793. <a name="index-_002d_002dforce_002ddynamic"></a>
  794. <a name="index-forcing-the-creation-of-dynamic-sections"></a>
  795. </dd>
  796. <dt><code>--force-dynamic</code></dt>
  797. <dd><p>Force the output file to have dynamic sections. This option is specific
  798. to VxWorks targets.
  799. </p>
  800. <a name="index-partial-link"></a>
  801. <a name="index-relocatable-output"></a>
  802. <a name="index-_002dr"></a>
  803. <a name="index-_002d_002drelocatable"></a>
  804. </dd>
  805. <dt><code>-r</code></dt>
  806. <dt><code>--relocatable</code></dt>
  807. <dd><p>Generate relocatable output&mdash;i.e., generate an output file that can in
  808. turn serve as input to <code>ld</code>. This is often called <em>partial
  809. linking</em>. As a side effect, in environments that support standard Unix
  810. magic numbers, this option also sets the output file&rsquo;s magic number to
  811. <code>OMAGIC</code>.
  812. If this option is not specified, an absolute file is produced. When
  813. linking C++ programs, this option <em>will not</em> resolve references to
  814. constructors; to do that, use &lsquo;<samp>-Ur</samp>&rsquo;.
  815. </p>
  816. <p>When an input file does not have the same format as the output file,
  817. partial linking is only supported if that input file does not contain any
  818. relocations. Different output formats can have further restrictions; for
  819. example some <code>a.out</code>-based formats do not support partial linking
  820. with input files in other formats at all.
  821. </p>
  822. <p>This option does the same thing as &lsquo;<samp>-i</samp>&rsquo;.
  823. </p>
  824. <a name="index-_002dR-file"></a>
  825. <a name="index-_002d_002djust_002dsymbols_003dfile"></a>
  826. <a name="index-symbol_002donly-input"></a>
  827. </dd>
  828. <dt><code>-R <var>filename</var></code></dt>
  829. <dt><code>--just-symbols=<var>filename</var></code></dt>
  830. <dd><p>Read symbol names and their addresses from <var>filename</var>, but do not
  831. relocate it or include it in the output. This allows your output file
  832. to refer symbolically to absolute locations of memory defined in other
  833. programs. You may use this option more than once.
  834. </p>
  835. <p>For compatibility with other ELF linkers, if the <samp>-R</samp> option is
  836. followed by a directory name, rather than a file name, it is treated as
  837. the <samp>-rpath</samp> option.
  838. </p>
  839. <a name="index-_002ds"></a>
  840. <a name="index-_002d_002dstrip_002dall"></a>
  841. <a name="index-strip-all-symbols"></a>
  842. </dd>
  843. <dt><code>-s</code></dt>
  844. <dt><code>--strip-all</code></dt>
  845. <dd><p>Omit all symbol information from the output file.
  846. </p>
  847. <a name="index-_002dS"></a>
  848. <a name="index-_002d_002dstrip_002ddebug"></a>
  849. <a name="index-strip-debugger-symbols"></a>
  850. </dd>
  851. <dt><code>-S</code></dt>
  852. <dt><code>--strip-debug</code></dt>
  853. <dd><p>Omit debugger symbol information (but not all symbols) from the output file.
  854. </p>
  855. <a name="index-_002d_002dstrip_002ddiscarded"></a>
  856. <a name="index-_002d_002dno_002dstrip_002ddiscarded"></a>
  857. </dd>
  858. <dt><code>--strip-discarded</code></dt>
  859. <dt><code>--no-strip-discarded</code></dt>
  860. <dd><p>Omit (or do not omit) global symbols defined in discarded sections.
  861. Enabled by default.
  862. </p>
  863. <a name="index-_002dt"></a>
  864. <a name="index-_002d_002dtrace"></a>
  865. <a name="index-input-files_002c-displaying"></a>
  866. </dd>
  867. <dt><code>-t</code></dt>
  868. <dt><code>--trace</code></dt>
  869. <dd><p>Print the names of the input files as <code>ld</code> processes them. If
  870. &lsquo;<samp>-t</samp>&rsquo; is given twice then members within archives are also printed.
  871. &lsquo;<samp>-t</samp>&rsquo; output is useful to generate a list of all the object files
  872. and scripts involved in linking, for example, when packaging files for
  873. a linker bug report.
  874. </p>
  875. <a name="index-_002dT-script"></a>
  876. <a name="index-_002d_002dscript_003dscript"></a>
  877. <a name="index-script-files"></a>
  878. </dd>
  879. <dt><code>-T <var>scriptfile</var></code></dt>
  880. <dt><code>--script=<var>scriptfile</var></code></dt>
  881. <dd><p>Use <var>scriptfile</var> as the linker script. This script replaces
  882. <code>ld</code>&rsquo;s default linker script (rather than adding to it), so
  883. <var>commandfile</var> must specify everything necessary to describe the
  884. output file. See <a href="Scripts.html#Scripts">Scripts</a>. If <var>scriptfile</var> does not exist in
  885. the current directory, <code>ld</code> looks for it in the directories
  886. specified by any preceding &lsquo;<samp>-L</samp>&rsquo; options. Multiple &lsquo;<samp>-T</samp>&rsquo;
  887. options accumulate.
  888. </p>
  889. <a name="index-_002ddT-script"></a>
  890. <a name="index-_002d_002ddefault_002dscript_003dscript"></a>
  891. <a name="index-script-files-1"></a>
  892. </dd>
  893. <dt><code>-dT <var>scriptfile</var></code></dt>
  894. <dt><code>--default-script=<var>scriptfile</var></code></dt>
  895. <dd><p>Use <var>scriptfile</var> as the default linker script. See <a href="Scripts.html#Scripts">Scripts</a>.
  896. </p>
  897. <p>This option is similar to the <samp>--script</samp> option except that
  898. processing of the script is delayed until after the rest of the
  899. command line has been processed. This allows options placed after the
  900. <samp>--default-script</samp> option on the command line to affect the
  901. behaviour of the linker script, which can be important when the linker
  902. command line cannot be directly controlled by the user. (eg because
  903. the command line is being constructed by another tool, such as
  904. &lsquo;<samp>gcc</samp>&rsquo;).
  905. </p>
  906. <a name="index-_002du-symbol"></a>
  907. <a name="index-_002d_002dundefined_003dsymbol"></a>
  908. <a name="index-undefined-symbol"></a>
  909. </dd>
  910. <dt><code>-u <var>symbol</var></code></dt>
  911. <dt><code>--undefined=<var>symbol</var></code></dt>
  912. <dd><p>Force <var>symbol</var> to be entered in the output file as an undefined
  913. symbol. Doing this may, for example, trigger linking of additional
  914. modules from standard libraries. &lsquo;<samp>-u</samp>&rsquo; may be repeated with
  915. different option arguments to enter additional undefined symbols. This
  916. option is equivalent to the <code>EXTERN</code> linker script command.
  917. </p>
  918. <p>If this option is being used to force additional modules to be pulled
  919. into the link, and if it is an error for the symbol to remain
  920. undefined, then the option <samp>--require-defined</samp> should be used
  921. instead.
  922. </p>
  923. <a name="index-_002d_002drequire_002ddefined_003dsymbol"></a>
  924. <a name="index-symbols_002c-require-defined"></a>
  925. <a name="index-defined-symbol"></a>
  926. </dd>
  927. <dt><code>--require-defined=<var>symbol</var></code></dt>
  928. <dd><p>Require that <var>symbol</var> is defined in the output file. This option
  929. is the same as option <samp>--undefined</samp> except that if <var>symbol</var>
  930. is not defined in the output file then the linker will issue an error
  931. and exit. The same effect can be achieved in a linker script by using
  932. <code>EXTERN</code>, <code>ASSERT</code> and <code>DEFINED</code> together. This option
  933. can be used multiple times to require additional symbols.
  934. </p>
  935. <a name="index-_002dUr"></a>
  936. <a name="index-constructors"></a>
  937. </dd>
  938. <dt><code>-Ur</code></dt>
  939. <dd><p>For anything other than C++ programs, this option is equivalent to
  940. &lsquo;<samp>-r</samp>&rsquo;: it generates relocatable output&mdash;i.e., an output file that can in
  941. turn serve as input to <code>ld</code>. When linking C++ programs, &lsquo;<samp>-Ur</samp>&rsquo;
  942. <em>does</em> resolve references to constructors, unlike &lsquo;<samp>-r</samp>&rsquo;.
  943. It does not work to use &lsquo;<samp>-Ur</samp>&rsquo; on files that were themselves linked
  944. with &lsquo;<samp>-Ur</samp>&rsquo;; once the constructor table has been built, it cannot
  945. be added to. Use &lsquo;<samp>-Ur</samp>&rsquo; only for the last partial link, and
  946. &lsquo;<samp>-r</samp>&rsquo; for the others.
  947. </p>
  948. <a name="index-_002d_002dorphan_002dhandling_003dMODE"></a>
  949. <a name="index-orphan-sections"></a>
  950. <a name="index-sections_002c-orphan"></a>
  951. </dd>
  952. <dt><code>--orphan-handling=<var>MODE</var></code></dt>
  953. <dd><p>Control how orphan sections are handled. An orphan section is one not
  954. specifically mentioned in a linker script. See <a href="Orphan-Sections.html#Orphan-Sections">Orphan Sections</a>.
  955. </p>
  956. <p><var>MODE</var> can have any of the following values:
  957. </p>
  958. <dl compact="compact">
  959. <dt><code>place</code></dt>
  960. <dd><p>Orphan sections are placed into a suitable output section following
  961. the strategy described in <a href="Orphan-Sections.html#Orphan-Sections">Orphan Sections</a>. The option
  962. &lsquo;<samp>--unique</samp>&rsquo; also affects how sections are placed.
  963. </p>
  964. </dd>
  965. <dt><code>discard</code></dt>
  966. <dd><p>All orphan sections are discarded, by placing them in the
  967. &lsquo;<samp>/DISCARD/</samp>&rsquo; section (see <a href="Output-Section-Discarding.html#Output-Section-Discarding">Output Section Discarding</a>).
  968. </p>
  969. </dd>
  970. <dt><code>warn</code></dt>
  971. <dd><p>The linker will place the orphan section as for <code>place</code> and also
  972. issue a warning.
  973. </p>
  974. </dd>
  975. <dt><code>error</code></dt>
  976. <dd><p>The linker will exit with an error if any orphan section is found.
  977. </p></dd>
  978. </dl>
  979. <p>The default if &lsquo;<samp>--orphan-handling</samp>&rsquo; is not given is <code>place</code>.
  980. </p>
  981. <a name="index-_002d_002dunique_005b_003dSECTION_005d"></a>
  982. </dd>
  983. <dt><code>--unique[=<var>SECTION</var>]</code></dt>
  984. <dd><p>Creates a separate output section for every input section matching
  985. <var>SECTION</var>, or if the optional wildcard <var>SECTION</var> argument is
  986. missing, for every orphan input section. An orphan section is one not
  987. specifically mentioned in a linker script. You may use this option
  988. multiple times on the command line; It prevents the normal merging of
  989. input sections with the same name, overriding output section assignments
  990. in a linker script.
  991. </p>
  992. <a name="index-_002dv"></a>
  993. <a name="index-_002dV"></a>
  994. <a name="index-_002d_002dversion"></a>
  995. <a name="index-version"></a>
  996. </dd>
  997. <dt><code>-v</code></dt>
  998. <dt><code>--version</code></dt>
  999. <dt><code>-V</code></dt>
  1000. <dd><p>Display the version number for <code>ld</code>. The <samp>-V</samp> option also
  1001. lists the supported emulations.
  1002. </p>
  1003. <a name="index-_002dx"></a>
  1004. <a name="index-_002d_002ddiscard_002dall"></a>
  1005. <a name="index-deleting-local-symbols"></a>
  1006. </dd>
  1007. <dt><code>-x</code></dt>
  1008. <dt><code>--discard-all</code></dt>
  1009. <dd><p>Delete all local symbols.
  1010. </p>
  1011. <a name="index-_002dX"></a>
  1012. <a name="index-_002d_002ddiscard_002dlocals"></a>
  1013. <a name="index-local-symbols_002c-deleting"></a>
  1014. </dd>
  1015. <dt><code>-X</code></dt>
  1016. <dt><code>--discard-locals</code></dt>
  1017. <dd><p>Delete all temporary local symbols. (These symbols start with
  1018. system-specific local label prefixes, typically &lsquo;<samp>.L</samp>&rsquo; for ELF systems
  1019. or &lsquo;<samp>L</samp>&rsquo; for traditional a.out systems.)
  1020. </p>
  1021. <a name="index-_002dy-symbol"></a>
  1022. <a name="index-_002d_002dtrace_002dsymbol_003dsymbol"></a>
  1023. <a name="index-symbol-tracing"></a>
  1024. </dd>
  1025. <dt><code>-y <var>symbol</var></code></dt>
  1026. <dt><code>--trace-symbol=<var>symbol</var></code></dt>
  1027. <dd><p>Print the name of each linked file in which <var>symbol</var> appears. This
  1028. option may be given any number of times. On many systems it is necessary
  1029. to prepend an underscore.
  1030. </p>
  1031. <p>This option is useful when you have an undefined symbol in your link but
  1032. don&rsquo;t know where the reference is coming from.
  1033. </p>
  1034. <a name="index-_002dY-path"></a>
  1035. </dd>
  1036. <dt><code>-Y <var>path</var></code></dt>
  1037. <dd><p>Add <var>path</var> to the default library search path. This option exists
  1038. for Solaris compatibility.
  1039. </p>
  1040. <a name="index-_002dz-keyword"></a>
  1041. </dd>
  1042. <dt><code>-z <var>keyword</var></code></dt>
  1043. <dd><p>The recognized keywords are:
  1044. </p><dl compact="compact">
  1045. <dt>&lsquo;<samp>bndplt</samp>&rsquo;</dt>
  1046. <dd><p>Always generate BND prefix in PLT entries. Supported for Linux/x86_64.
  1047. </p>
  1048. </dd>
  1049. <dt>&lsquo;<samp>call-nop=prefix-addr</samp>&rsquo;</dt>
  1050. <dt>&lsquo;<samp>call-nop=suffix-nop</samp>&rsquo;</dt>
  1051. <dt>&lsquo;<samp>call-nop=prefix-<var>byte</var></samp>&rsquo;</dt>
  1052. <dt>&lsquo;<samp>call-nop=suffix-<var>byte</var></samp>&rsquo;</dt>
  1053. <dd><p>Specify the 1-byte <code>NOP</code> padding when transforming indirect call
  1054. to a locally defined function, foo, via its GOT slot.
  1055. <samp>call-nop=prefix-addr</samp> generates <code>0x67 call foo</code>.
  1056. <samp>call-nop=suffix-nop</samp> generates <code>call foo 0x90</code>.
  1057. <samp>call-nop=prefix-<var>byte</var></samp> generates <code><var>byte</var> call foo</code>.
  1058. <samp>call-nop=suffix-<var>byte</var></samp> generates <code>call foo <var>byte</var></code>.
  1059. Supported for i386 and x86_64.
  1060. </p>
  1061. </dd>
  1062. <dt>&lsquo;<samp>cet-report=none</samp>&rsquo;</dt>
  1063. <dt>&lsquo;<samp>cet-report=warning</samp>&rsquo;</dt>
  1064. <dt>&lsquo;<samp>cet-report=error</samp>&rsquo;</dt>
  1065. <dd><p>Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT and
  1066. GNU_PROPERTY_X86_FEATURE_1_SHSTK properties in input .note.gnu.property
  1067. section. <samp>cet-report=none</samp>, which is the default, will make the
  1068. linker not report missing properties in input files.
  1069. <samp>cet-report=warning</samp> will make the linker issue a warning for
  1070. missing properties in input files. <samp>cet-report=error</samp> will make
  1071. the linker issue an error for missing properties in input files.
  1072. Note that <samp>ibt</samp> will turn off the missing
  1073. GNU_PROPERTY_X86_FEATURE_1_IBT property report and <samp>shstk</samp> will
  1074. turn off the missing GNU_PROPERTY_X86_FEATURE_1_SHSTK property report.
  1075. Supported for Linux/i386 and Linux/x86_64.
  1076. </p>
  1077. </dd>
  1078. <dt>&lsquo;<samp>combreloc</samp>&rsquo;</dt>
  1079. <dt>&lsquo;<samp>nocombreloc</samp>&rsquo;</dt>
  1080. <dd><p>Combine multiple dynamic relocation sections and sort to improve
  1081. dynamic symbol lookup caching. Do not do this if &lsquo;<samp>nocombreloc</samp>&rsquo;.
  1082. </p>
  1083. </dd>
  1084. <dt>&lsquo;<samp>common</samp>&rsquo;</dt>
  1085. <dt>&lsquo;<samp>nocommon</samp>&rsquo;</dt>
  1086. <dd><p>Generate common symbols with STT_COMMON type during a relocatable
  1087. link. Use STT_OBJECT type if &lsquo;<samp>nocommon</samp>&rsquo;.
  1088. </p>
  1089. </dd>
  1090. <dt>&lsquo;<samp>common-page-size=<var>value</var></samp>&rsquo;</dt>
  1091. <dd><p>Set the page size most commonly used to <var>value</var>. Memory image
  1092. layout will be optimized to minimize memory pages if the system is
  1093. using pages of this size.
  1094. </p>
  1095. </dd>
  1096. <dt>&lsquo;<samp>defs</samp>&rsquo;</dt>
  1097. <dd><p>Report unresolved symbol references from regular object files. This
  1098. is done even if the linker is creating a non-symbolic shared library.
  1099. This option is the inverse of &lsquo;<samp>-z undefs</samp>&rsquo;.
  1100. </p>
  1101. </dd>
  1102. <dt>&lsquo;<samp>dynamic-undefined-weak</samp>&rsquo;</dt>
  1103. <dt>&lsquo;<samp>nodynamic-undefined-weak</samp>&rsquo;</dt>
  1104. <dd><p>Make undefined weak symbols dynamic when building a dynamic object,
  1105. if they are referenced from a regular object file and not forced local
  1106. by symbol visibility or versioning. Do not make them dynamic if
  1107. &lsquo;<samp>nodynamic-undefined-weak</samp>&rsquo;. If neither option is given, a target
  1108. may default to either option being in force, or make some other
  1109. selection of undefined weak symbols dynamic. Not all targets support
  1110. these options.
  1111. </p>
  1112. </dd>
  1113. <dt>&lsquo;<samp>execstack</samp>&rsquo;</dt>
  1114. <dd><p>Marks the object as requiring executable stack.
  1115. </p>
  1116. </dd>
  1117. <dt>&lsquo;<samp>global</samp>&rsquo;</dt>
  1118. <dd><p>This option is only meaningful when building a shared object. It makes
  1119. the symbols defined by this shared object available for symbol resolution
  1120. of subsequently loaded libraries.
  1121. </p>
  1122. </dd>
  1123. <dt>&lsquo;<samp>globalaudit</samp>&rsquo;</dt>
  1124. <dd><p>This option is only meaningful when building a dynamic executable.
  1125. This option marks the executable as requiring global auditing by
  1126. setting the <code>DF_1_GLOBAUDIT</code> bit in the <code>DT_FLAGS_1</code> dynamic
  1127. tag. Global auditing requires that any auditing library defined via
  1128. the <samp>--depaudit</samp> or <samp>-P</samp> command-line options be run for
  1129. all dynamic objects loaded by the application.
  1130. </p>
  1131. </dd>
  1132. <dt>&lsquo;<samp>ibtplt</samp>&rsquo;</dt>
  1133. <dd><p>Generate Intel Indirect Branch Tracking (IBT) enabled PLT entries.
  1134. Supported for Linux/i386 and Linux/x86_64.
  1135. </p>
  1136. </dd>
  1137. <dt>&lsquo;<samp>ibt</samp>&rsquo;</dt>
  1138. <dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_IBT in .note.gnu.property section
  1139. to indicate compatibility with IBT. This also implies <samp>ibtplt</samp>.
  1140. Supported for Linux/i386 and Linux/x86_64.
  1141. </p>
  1142. </dd>
  1143. <dt>&lsquo;<samp>initfirst</samp>&rsquo;</dt>
  1144. <dd><p>This option is only meaningful when building a shared object.
  1145. It marks the object so that its runtime initialization will occur
  1146. before the runtime initialization of any other objects brought into
  1147. the process at the same time. Similarly the runtime finalization of
  1148. the object will occur after the runtime finalization of any other
  1149. objects.
  1150. </p>
  1151. </dd>
  1152. <dt>&lsquo;<samp>interpose</samp>&rsquo;</dt>
  1153. <dd><p>Specify that the dynamic loader should modify its symbol search order
  1154. so that symbols in this shared library interpose all other shared
  1155. libraries not so marked.
  1156. </p>
  1157. </dd>
  1158. <dt>&lsquo;<samp>lazy</samp>&rsquo;</dt>
  1159. <dd><p>When generating an executable or shared library, mark it to tell the
  1160. dynamic linker to defer function call resolution to the point when
  1161. the function is called (lazy binding), rather than at load time.
  1162. Lazy binding is the default.
  1163. </p>
  1164. </dd>
  1165. <dt>&lsquo;<samp>loadfltr</samp>&rsquo;</dt>
  1166. <dd><p>Specify that the object&rsquo;s filters be processed immediately at runtime.
  1167. </p>
  1168. </dd>
  1169. <dt>&lsquo;<samp>max-page-size=<var>value</var></samp>&rsquo;</dt>
  1170. <dd><p>Set the maximum memory page size supported to <var>value</var>.
  1171. </p>
  1172. </dd>
  1173. <dt>&lsquo;<samp>muldefs</samp>&rsquo;</dt>
  1174. <dd><p>Allow multiple definitions.
  1175. </p>
  1176. </dd>
  1177. <dt>&lsquo;<samp>nocopyreloc</samp>&rsquo;</dt>
  1178. <dd><p>Disable linker generated .dynbss variables used in place of variables
  1179. defined in shared libraries. May result in dynamic text relocations.
  1180. </p>
  1181. </dd>
  1182. <dt>&lsquo;<samp>nodefaultlib</samp>&rsquo;</dt>
  1183. <dd><p>Specify that the dynamic loader search for dependencies of this object
  1184. should ignore any default library search paths.
  1185. </p>
  1186. </dd>
  1187. <dt>&lsquo;<samp>nodelete</samp>&rsquo;</dt>
  1188. <dd><p>Specify that the object shouldn&rsquo;t be unloaded at runtime.
  1189. </p>
  1190. </dd>
  1191. <dt>&lsquo;<samp>nodlopen</samp>&rsquo;</dt>
  1192. <dd><p>Specify that the object is not available to <code>dlopen</code>.
  1193. </p>
  1194. </dd>
  1195. <dt>&lsquo;<samp>nodump</samp>&rsquo;</dt>
  1196. <dd><p>Specify that the object can not be dumped by <code>dldump</code>.
  1197. </p>
  1198. </dd>
  1199. <dt>&lsquo;<samp>noexecstack</samp>&rsquo;</dt>
  1200. <dd><p>Marks the object as not requiring executable stack.
  1201. </p>
  1202. </dd>
  1203. <dt>&lsquo;<samp>noextern-protected-data</samp>&rsquo;</dt>
  1204. <dd><p>Don&rsquo;t treat protected data symbols as external when building a shared
  1205. library. This option overrides the linker backend default. It can be
  1206. used to work around incorrect relocations against protected data symbols
  1207. generated by compiler. Updates on protected data symbols by another
  1208. module aren&rsquo;t visible to the resulting shared library. Supported for
  1209. i386 and x86-64.
  1210. </p>
  1211. </dd>
  1212. <dt>&lsquo;<samp>noreloc-overflow</samp>&rsquo;</dt>
  1213. <dd><p>Disable relocation overflow check. This can be used to disable
  1214. relocation overflow check if there will be no dynamic relocation
  1215. overflow at run-time. Supported for x86_64.
  1216. </p>
  1217. </dd>
  1218. <dt>&lsquo;<samp>now</samp>&rsquo;</dt>
  1219. <dd><p>When generating an executable or shared library, mark it to tell the
  1220. dynamic linker to resolve all symbols when the program is started, or
  1221. when the shared library is loaded by dlopen, instead of deferring
  1222. function call resolution to the point when the function is first
  1223. called.
  1224. </p>
  1225. </dd>
  1226. <dt>&lsquo;<samp>origin</samp>&rsquo;</dt>
  1227. <dd><p>Specify that the object requires &lsquo;<samp>$ORIGIN</samp>&rsquo; handling in paths.
  1228. </p>
  1229. </dd>
  1230. <dt>&lsquo;<samp>relro</samp>&rsquo;</dt>
  1231. <dt>&lsquo;<samp>norelro</samp>&rsquo;</dt>
  1232. <dd><p>Create an ELF <code>PT_GNU_RELRO</code> segment header in the object. This
  1233. specifies a memory segment that should be made read-only after
  1234. relocation, if supported. Specifying &lsquo;<samp>common-page-size</samp>&rsquo; smaller
  1235. than the system page size will render this protection ineffective.
  1236. Don&rsquo;t create an ELF <code>PT_GNU_RELRO</code> segment if &lsquo;<samp>norelro</samp>&rsquo;.
  1237. </p>
  1238. </dd>
  1239. <dt>&lsquo;<samp>separate-code</samp>&rsquo;</dt>
  1240. <dt>&lsquo;<samp>noseparate-code</samp>&rsquo;</dt>
  1241. <dd><p>Create separate code <code>PT_LOAD</code> segment header in the object. This
  1242. specifies a memory segment that should contain only instructions and must
  1243. be in wholly disjoint pages from any other data. Don&rsquo;t create separate
  1244. code <code>PT_LOAD</code> segment if &lsquo;<samp>noseparate-code</samp>&rsquo; is used.
  1245. </p>
  1246. </dd>
  1247. <dt>&lsquo;<samp>shstk</samp>&rsquo;</dt>
  1248. <dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK in .note.gnu.property section
  1249. to indicate compatibility with Intel Shadow Stack. Supported for
  1250. Linux/i386 and Linux/x86_64.
  1251. </p>
  1252. </dd>
  1253. <dt>&lsquo;<samp>stack-size=<var>value</var></samp>&rsquo;</dt>
  1254. <dd><p>Specify a stack size for an ELF <code>PT_GNU_STACK</code> segment.
  1255. Specifying zero will override any default non-zero sized
  1256. <code>PT_GNU_STACK</code> segment creation.
  1257. </p>
  1258. </dd>
  1259. <dt>&lsquo;<samp>start-stop-visibility=<var>value</var></samp>&rsquo;</dt>
  1260. <dd><a name="index-visibility"></a>
  1261. <a name="index-ELF-symbol-visibility"></a>
  1262. <p>Specify the ELF symbol visibility for synthesized
  1263. <code>__start_SECNAME</code> and <code>__stop_SECNAME</code> symbols (see <a href="Input-Section-Example.html#Input-Section-Example">Input Section Example</a>). <var>value</var> must be exactly &lsquo;<samp>default</samp>&rsquo;,
  1264. &lsquo;<samp>internal</samp>&rsquo;, &lsquo;<samp>hidden</samp>&rsquo;, or &lsquo;<samp>protected</samp>&rsquo;. If no &lsquo;<samp>-z
  1265. start-stop-visibility</samp>&rsquo; option is given, &lsquo;<samp>protected</samp>&rsquo; is used for
  1266. compatibility with historical practice. However, it&rsquo;s highly
  1267. recommended to use &lsquo;<samp>-z start-stop-visibility=hidden</samp>&rsquo; in new
  1268. programs and shared libraries so that these symbols are not exported
  1269. between shared objects, which is not usually what&rsquo;s intended.
  1270. </p>
  1271. </dd>
  1272. <dt>&lsquo;<samp>text</samp>&rsquo;</dt>
  1273. <dt>&lsquo;<samp>notext</samp>&rsquo;</dt>
  1274. <dt>&lsquo;<samp>textoff</samp>&rsquo;</dt>
  1275. <dd><p>Report an error if DT_TEXTREL is set, i.e., if the position-independent
  1276. or shared object has dynamic relocations in read-only sections. Don&rsquo;t
  1277. report an error if &lsquo;<samp>notext</samp>&rsquo; or &lsquo;<samp>textoff</samp>&rsquo;.
  1278. </p>
  1279. </dd>
  1280. <dt>&lsquo;<samp>undefs</samp>&rsquo;</dt>
  1281. <dd><p>Do not report unresolved symbol references from regular object files,
  1282. either when creating an executable, or when creating a shared library.
  1283. This option is the inverse of &lsquo;<samp>-z defs</samp>&rsquo;.
  1284. </p>
  1285. </dd>
  1286. </dl>
  1287. <p>Other keywords are ignored for Solaris compatibility.
  1288. </p>
  1289. <a name="index-_002d_0028"></a>
  1290. <a name="index-groups-of-archives"></a>
  1291. </dd>
  1292. <dt><code>-( <var>archives</var> -)</code></dt>
  1293. <dt><code>--start-group <var>archives</var> --end-group</code></dt>
  1294. <dd><p>The <var>archives</var> should be a list of archive files. They may be
  1295. either explicit file names, or &lsquo;<samp>-l</samp>&rsquo; options.
  1296. </p>
  1297. <p>The specified archives are searched repeatedly until no new undefined
  1298. references are created. Normally, an archive is searched only once in
  1299. the order that it is specified on the command line. If a symbol in that
  1300. archive is needed to resolve an undefined symbol referred to by an
  1301. object in an archive that appears later on the command line, the linker
  1302. would not be able to resolve that reference. By grouping the archives,
  1303. they will all be searched repeatedly until all possible references are
  1304. resolved.
  1305. </p>
  1306. <p>Using this option has a significant performance cost. It is best to use
  1307. it only when there are unavoidable circular references between two or
  1308. more archives.
  1309. </p>
  1310. <a name="index-_002d_002daccept_002dunknown_002dinput_002darch"></a>
  1311. <a name="index-_002d_002dno_002daccept_002dunknown_002dinput_002darch"></a>
  1312. </dd>
  1313. <dt><code>--accept-unknown-input-arch</code></dt>
  1314. <dt><code>--no-accept-unknown-input-arch</code></dt>
  1315. <dd><p>Tells the linker to accept input files whose architecture cannot be
  1316. recognised. The assumption is that the user knows what they are doing
  1317. and deliberately wants to link in these unknown input files. This was
  1318. the default behaviour of the linker, before release 2.14. The default
  1319. behaviour from release 2.14 onwards is to reject such input files, and
  1320. so the &lsquo;<samp>--accept-unknown-input-arch</samp>&rsquo; option has been added to
  1321. restore the old behaviour.
  1322. </p>
  1323. <a name="index-_002d_002das_002dneeded"></a>
  1324. <a name="index-_002d_002dno_002das_002dneeded"></a>
  1325. </dd>
  1326. <dt><code>--as-needed</code></dt>
  1327. <dt><code>--no-as-needed</code></dt>
  1328. <dd><p>This option affects ELF DT_NEEDED tags for dynamic libraries mentioned
  1329. on the command line after the <samp>--as-needed</samp> option. Normally
  1330. the linker will add a DT_NEEDED tag for each dynamic library mentioned
  1331. on the command line, regardless of whether the library is actually
  1332. needed or not. <samp>--as-needed</samp> causes a DT_NEEDED tag to only be
  1333. emitted for a library that <em>at that point in the link</em> satisfies a
  1334. non-weak undefined symbol reference from a regular object file or, if
  1335. the library is not found in the DT_NEEDED lists of other needed libraries, a
  1336. non-weak undefined symbol reference from another needed dynamic library.
  1337. Object files or libraries appearing on the command line <em>after</em>
  1338. the library in question do not affect whether the library is seen as
  1339. needed. This is similar to the rules for extraction of object files
  1340. from archives. <samp>--no-as-needed</samp> restores the default behaviour.
  1341. </p>
  1342. <a name="index-_002d_002dadd_002dneeded"></a>
  1343. <a name="index-_002d_002dno_002dadd_002dneeded"></a>
  1344. </dd>
  1345. <dt><code>--add-needed</code></dt>
  1346. <dt><code>--no-add-needed</code></dt>
  1347. <dd><p>These two options have been deprecated because of the similarity of
  1348. their names to the <samp>--as-needed</samp> and <samp>--no-as-needed</samp>
  1349. options. They have been replaced by <samp>--copy-dt-needed-entries</samp>
  1350. and <samp>--no-copy-dt-needed-entries</samp>.
  1351. </p>
  1352. <a name="index-_002dassert-keyword"></a>
  1353. </dd>
  1354. <dt><code>-assert <var>keyword</var></code></dt>
  1355. <dd><p>This option is ignored for SunOS compatibility.
  1356. </p>
  1357. <a name="index-_002dBdynamic"></a>
  1358. <a name="index-_002ddy"></a>
  1359. <a name="index-_002dcall_005fshared"></a>
  1360. </dd>
  1361. <dt><code>-Bdynamic</code></dt>
  1362. <dt><code>-dy</code></dt>
  1363. <dt><code>-call_shared</code></dt>
  1364. <dd><p>Link against dynamic libraries. This is only meaningful on platforms
  1365. for which shared libraries are supported. This option is normally the
  1366. default on such platforms. The different variants of this option are
  1367. for compatibility with various systems. You may use this option
  1368. multiple times on the command line: it affects library searching for
  1369. <samp>-l</samp> options which follow it.
  1370. </p>
  1371. <a name="index-_002dBgroup"></a>
  1372. </dd>
  1373. <dt><code>-Bgroup</code></dt>
  1374. <dd><p>Set the <code>DF_1_GROUP</code> flag in the <code>DT_FLAGS_1</code> entry in the dynamic
  1375. section. This causes the runtime linker to handle lookups in this
  1376. object and its dependencies to be performed only inside the group.
  1377. <samp>--unresolved-symbols=report-all</samp> is implied. This option is
  1378. only meaningful on ELF platforms which support shared libraries.
  1379. </p>
  1380. <a name="index-_002dBstatic"></a>
  1381. <a name="index-_002ddn"></a>
  1382. <a name="index-_002dnon_005fshared"></a>
  1383. <a name="index-_002dstatic"></a>
  1384. </dd>
  1385. <dt><code>-Bstatic</code></dt>
  1386. <dt><code>-dn</code></dt>
  1387. <dt><code>-non_shared</code></dt>
  1388. <dt><code>-static</code></dt>
  1389. <dd><p>Do not link against shared libraries. This is only meaningful on
  1390. platforms for which shared libraries are supported. The different
  1391. variants of this option are for compatibility with various systems. You
  1392. may use this option multiple times on the command line: it affects
  1393. library searching for <samp>-l</samp> options which follow it. This
  1394. option also implies <samp>--unresolved-symbols=report-all</samp>. This
  1395. option can be used with <samp>-shared</samp>. Doing so means that a
  1396. shared library is being created but that all of the library&rsquo;s external
  1397. references must be resolved by pulling in entries from static
  1398. libraries.
  1399. </p>
  1400. <a name="index-_002dBsymbolic"></a>
  1401. </dd>
  1402. <dt><code>-Bsymbolic</code></dt>
  1403. <dd><p>When creating a shared library, bind references to global symbols to the
  1404. definition within the shared library, if any. Normally, it is possible
  1405. for a program linked against a shared library to override the definition
  1406. within the shared library. This option is only meaningful on ELF
  1407. platforms which support shared libraries.
  1408. </p>
  1409. <a name="index-_002dBsymbolic_002dfunctions"></a>
  1410. </dd>
  1411. <dt><code>-Bsymbolic-functions</code></dt>
  1412. <dd><p>When creating a shared library, bind references to global function
  1413. symbols to the definition within the shared library, if any.
  1414. This option is only meaningful on ELF platforms which support shared
  1415. libraries.
  1416. </p>
  1417. <a name="index-_002d_002ddynamic_002dlist_003ddynamic_002dlist_002dfile"></a>
  1418. </dd>
  1419. <dt><code>--dynamic-list=<var>dynamic-list-file</var></code></dt>
  1420. <dd><p>Specify the name of a dynamic list file to the linker. This is
  1421. typically used when creating shared libraries to specify a list of
  1422. global symbols whose references shouldn&rsquo;t be bound to the definition
  1423. within the shared library, or creating dynamically linked executables
  1424. to specify a list of symbols which should be added to the symbol table
  1425. in the executable. This option is only meaningful on ELF platforms
  1426. which support shared libraries.
  1427. </p>
  1428. <p>The format of the dynamic list is the same as the version node without
  1429. scope and node name. See <a href="VERSION.html#VERSION">VERSION</a> for more information.
  1430. </p>
  1431. <a name="index-_002d_002ddynamic_002dlist_002ddata"></a>
  1432. </dd>
  1433. <dt><code>--dynamic-list-data</code></dt>
  1434. <dd><p>Include all global data symbols to the dynamic list.
  1435. </p>
  1436. <a name="index-_002d_002ddynamic_002dlist_002dcpp_002dnew"></a>
  1437. </dd>
  1438. <dt><code>--dynamic-list-cpp-new</code></dt>
  1439. <dd><p>Provide the builtin dynamic list for C++ operator new and delete. It
  1440. is mainly useful for building shared libstdc++.
  1441. </p>
  1442. <a name="index-_002d_002ddynamic_002dlist_002dcpp_002dtypeinfo"></a>
  1443. </dd>
  1444. <dt><code>--dynamic-list-cpp-typeinfo</code></dt>
  1445. <dd><p>Provide the builtin dynamic list for C++ runtime type identification.
  1446. </p>
  1447. <a name="index-_002d_002dcheck_002dsections"></a>
  1448. <a name="index-_002d_002dno_002dcheck_002dsections"></a>
  1449. </dd>
  1450. <dt><code>--check-sections</code></dt>
  1451. <dt><code>--no-check-sections</code></dt>
  1452. <dd><p>Asks the linker <em>not</em> to check section addresses after they have
  1453. been assigned to see if there are any overlaps. Normally the linker will
  1454. perform this check, and if it finds any overlaps it will produce
  1455. suitable error messages. The linker does know about, and does make
  1456. allowances for sections in overlays. The default behaviour can be
  1457. restored by using the command-line switch <samp>--check-sections</samp>.
  1458. Section overlap is not usually checked for relocatable links. You can
  1459. force checking in that case by using the <samp>--check-sections</samp>
  1460. option.
  1461. </p>
  1462. <a name="index-_002d_002dcopy_002ddt_002dneeded_002dentries"></a>
  1463. <a name="index-_002d_002dno_002dcopy_002ddt_002dneeded_002dentries"></a>
  1464. </dd>
  1465. <dt><code>--copy-dt-needed-entries</code></dt>
  1466. <dt><code>--no-copy-dt-needed-entries</code></dt>
  1467. <dd><p>This option affects the treatment of dynamic libraries referred to
  1468. by DT_NEEDED tags <em>inside</em> ELF dynamic libraries mentioned on the
  1469. command line. Normally the linker won&rsquo;t add a DT_NEEDED tag to the
  1470. output binary for each library mentioned in a DT_NEEDED tag in an
  1471. input dynamic library. With <samp>--copy-dt-needed-entries</samp>
  1472. specified on the command line however any dynamic libraries that
  1473. follow it will have their DT_NEEDED entries added. The default
  1474. behaviour can be restored with <samp>--no-copy-dt-needed-entries</samp>.
  1475. </p>
  1476. <p>This option also has an effect on the resolution of symbols in dynamic
  1477. libraries. With <samp>--copy-dt-needed-entries</samp> dynamic libraries
  1478. mentioned on the command line will be recursively searched, following
  1479. their DT_NEEDED tags to other libraries, in order to resolve symbols
  1480. required by the output binary. With the default setting however
  1481. the searching of dynamic libraries that follow it will stop with the
  1482. dynamic library itself. No DT_NEEDED links will be traversed to resolve
  1483. symbols.
  1484. </p>
  1485. <a name="index-cross-reference-table"></a>
  1486. <a name="index-_002d_002dcref"></a>
  1487. </dd>
  1488. <dt><code>--cref</code></dt>
  1489. <dd><p>Output a cross reference table. If a linker map file is being
  1490. generated, the cross reference table is printed to the map file.
  1491. Otherwise, it is printed on the standard output.
  1492. </p>
  1493. <p>The format of the table is intentionally simple, so that it may be
  1494. easily processed by a script if necessary. The symbols are printed out,
  1495. sorted by name. For each symbol, a list of file names is given. If the
  1496. symbol is defined, the first file listed is the location of the
  1497. definition. If the symbol is defined as a common value then any files
  1498. where this happens appear next. Finally any files that reference the
  1499. symbol are listed.
  1500. </p>
  1501. <a name="index-common-allocation-1"></a>
  1502. <a name="index-_002d_002dno_002ddefine_002dcommon"></a>
  1503. </dd>
  1504. <dt><code>--no-define-common</code></dt>
  1505. <dd><p>This option inhibits the assignment of addresses to common symbols.
  1506. The script command <code>INHIBIT_COMMON_ALLOCATION</code> has the same effect.
  1507. See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>.
  1508. </p>
  1509. <p>The &lsquo;<samp>--no-define-common</samp>&rsquo; option allows decoupling
  1510. the decision to assign addresses to Common symbols from the choice
  1511. of the output file type; otherwise a non-Relocatable output type
  1512. forces assigning addresses to Common symbols.
  1513. Using &lsquo;<samp>--no-define-common</samp>&rsquo; allows Common symbols that are referenced
  1514. from a shared library to be assigned addresses only in the main program.
  1515. This eliminates the unused duplicate space in the shared library,
  1516. and also prevents any possible confusion over resolving to the wrong
  1517. duplicate when there are many dynamic modules with specialized search
  1518. paths for runtime symbol resolution.
  1519. </p>
  1520. <a name="index-group-allocation-in-linker-script"></a>
  1521. <a name="index-section-groups"></a>
  1522. <a name="index-COMDAT"></a>
  1523. <a name="index-_002d_002dforce_002dgroup_002dallocation"></a>
  1524. </dd>
  1525. <dt><code>--force-group-allocation</code></dt>
  1526. <dd><p>This option causes the linker to place section group members like
  1527. normal input sections, and to delete the section groups. This is the
  1528. default behaviour for a final link but this option can be used to
  1529. change the behaviour of a relocatable link (&lsquo;<samp>-r</samp>&rsquo;). The script
  1530. command <code>FORCE_GROUP_ALLOCATION</code> has the same
  1531. effect. See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>.
  1532. </p>
  1533. <a name="index-symbols_002c-from-command-line"></a>
  1534. <a name="index-_002d_002ddefsym_003dsymbol_003dexp"></a>
  1535. </dd>
  1536. <dt><code>--defsym=<var>symbol</var>=<var>expression</var></code></dt>
  1537. <dd><p>Create a global symbol in the output file, containing the absolute
  1538. address given by <var>expression</var>. You may use this option as many
  1539. times as necessary to define multiple symbols in the command line. A
  1540. limited form of arithmetic is supported for the <var>expression</var> in this
  1541. context: you may give a hexadecimal constant or the name of an existing
  1542. symbol, or use <code>+</code> and <code>-</code> to add or subtract hexadecimal
  1543. constants or symbols. If you need more elaborate expressions, consider
  1544. using the linker command language from a script (see <a href="Assignments.html#Assignments">Assignments</a>).
  1545. <em>Note:</em> there should be no white space between <var>symbol</var>, the
  1546. equals sign (&ldquo;<tt class="key">=</tt>&rdquo;), and <var>expression</var>.
  1547. </p>
  1548. <a name="index-demangling_002c-from-command-line"></a>
  1549. <a name="index-_002d_002ddemangle_005b_003dstyle_005d"></a>
  1550. <a name="index-_002d_002dno_002ddemangle"></a>
  1551. </dd>
  1552. <dt><code>--demangle[=<var>style</var>]</code></dt>
  1553. <dt><code>--no-demangle</code></dt>
  1554. <dd><p>These options control whether to demangle symbol names in error messages
  1555. and other output. When the linker is told to demangle, it tries to
  1556. present symbol names in a readable fashion: it strips leading
  1557. underscores if they are used by the object file format, and converts C++
  1558. mangled symbol names into user readable names. Different compilers have
  1559. different mangling styles. The optional demangling style argument can be used
  1560. to choose an appropriate demangling style for your compiler. The linker will
  1561. demangle by default unless the environment variable &lsquo;<samp>COLLECT_NO_DEMANGLE</samp>&rsquo;
  1562. is set. These options may be used to override the default.
  1563. </p>
  1564. <a name="index-dynamic-linker_002c-from-command-line"></a>
  1565. <a name="index-_002dIfile"></a>
  1566. <a name="index-_002d_002ddynamic_002dlinker_003dfile"></a>
  1567. </dd>
  1568. <dt><code>-I<var>file</var></code></dt>
  1569. <dt><code>--dynamic-linker=<var>file</var></code></dt>
  1570. <dd><p>Set the name of the dynamic linker. This is only meaningful when
  1571. generating dynamically linked ELF executables. The default dynamic
  1572. linker is normally correct; don&rsquo;t use this unless you know what you are
  1573. doing.
  1574. </p>
  1575. <a name="index-_002d_002dno_002ddynamic_002dlinker"></a>
  1576. </dd>
  1577. <dt><code>--no-dynamic-linker</code></dt>
  1578. <dd><p>When producing an executable file, omit the request for a dynamic
  1579. linker to be used at load-time. This is only meaningful for ELF
  1580. executables that contain dynamic relocations, and usually requires
  1581. entry point code that is capable of processing these relocations.
  1582. </p>
  1583. <a name="index-_002d_002dembedded_002drelocs"></a>
  1584. </dd>
  1585. <dt><code>--embedded-relocs</code></dt>
  1586. <dd><p>This option is similar to the <samp>--emit-relocs</samp> option except
  1587. that the relocs are stored in a target-specific section. This option
  1588. is only supported by the &lsquo;<samp>BFIN</samp>&rsquo;, &lsquo;<samp>CR16</samp>&rsquo; and <em>M68K</em>
  1589. targets.
  1590. </p>
  1591. <a name="index-_002d_002ddisable_002dmultiple_002dabs_002ddefs"></a>
  1592. </dd>
  1593. <dt><code>--disable-multiple-abs-defs</code></dt>
  1594. <dd><p>Do not allow multiple definitions with symbols included
  1595. in filename invoked by -R or &ndash;just-symbols
  1596. </p>
  1597. <a name="index-_002d_002dfatal_002dwarnings"></a>
  1598. <a name="index-_002d_002dno_002dfatal_002dwarnings"></a>
  1599. </dd>
  1600. <dt><code>--fatal-warnings</code></dt>
  1601. <dt><code>--no-fatal-warnings</code></dt>
  1602. <dd><p>Treat all warnings as errors. The default behaviour can be restored
  1603. with the option <samp>--no-fatal-warnings</samp>.
  1604. </p>
  1605. <a name="index-_002d_002dforce_002dexe_002dsuffix"></a>
  1606. </dd>
  1607. <dt><code>--force-exe-suffix</code></dt>
  1608. <dd><p>Make sure that an output file has a .exe suffix.
  1609. </p>
  1610. <p>If a successfully built fully linked output file does not have a
  1611. <code>.exe</code> or <code>.dll</code> suffix, this option forces the linker to copy
  1612. the output file to one of the same name with a <code>.exe</code> suffix. This
  1613. option is useful when using unmodified Unix makefiles on a Microsoft
  1614. Windows host, since some versions of Windows won&rsquo;t run an image unless
  1615. it ends in a <code>.exe</code> suffix.
  1616. </p>
  1617. <a name="index-_002d_002dgc_002dsections"></a>
  1618. <a name="index-_002d_002dno_002dgc_002dsections"></a>
  1619. <a name="index-garbage-collection"></a>
  1620. </dd>
  1621. <dt><code>--gc-sections</code></dt>
  1622. <dt><code>--no-gc-sections</code></dt>
  1623. <dd><p>Enable garbage collection of unused input sections. It is ignored on
  1624. targets that do not support this option. The default behaviour (of not
  1625. performing this garbage collection) can be restored by specifying
  1626. &lsquo;<samp>--no-gc-sections</samp>&rsquo; on the command line. Note that garbage
  1627. collection for COFF and PE format targets is supported, but the
  1628. implementation is currently considered to be experimental.
  1629. </p>
  1630. <p>&lsquo;<samp>--gc-sections</samp>&rsquo; decides which input sections are used by
  1631. examining symbols and relocations. The section containing the entry
  1632. symbol and all sections containing symbols undefined on the
  1633. command-line will be kept, as will sections containing symbols
  1634. referenced by dynamic objects. Note that when building shared
  1635. libraries, the linker must assume that any visible symbol is
  1636. referenced. Once this initial set of sections has been determined,
  1637. the linker recursively marks as used any section referenced by their
  1638. relocations. See &lsquo;<samp>--entry</samp>&rsquo;, &lsquo;<samp>--undefined</samp>&rsquo;, and
  1639. &lsquo;<samp>--gc-keep-exported</samp>&rsquo;.
  1640. </p>
  1641. <p>This option can be set when doing a partial link (enabled with option
  1642. &lsquo;<samp>-r</samp>&rsquo;). In this case the root of symbols kept must be explicitly
  1643. specified either by one of the options &lsquo;<samp>--entry</samp>&rsquo;,
  1644. &lsquo;<samp>--undefined</samp>&rsquo;, or &lsquo;<samp>--gc-keep-exported</samp>&rsquo; or by a <code>ENTRY</code>
  1645. command in the linker script.
  1646. </p>
  1647. <a name="index-_002d_002dprint_002dgc_002dsections"></a>
  1648. <a name="index-_002d_002dno_002dprint_002dgc_002dsections"></a>
  1649. <a name="index-garbage-collection-1"></a>
  1650. </dd>
  1651. <dt><code>--print-gc-sections</code></dt>
  1652. <dt><code>--no-print-gc-sections</code></dt>
  1653. <dd><p>List all sections removed by garbage collection. The listing is
  1654. printed on stderr. This option is only effective if garbage
  1655. collection has been enabled via the &lsquo;<samp>--gc-sections</samp>&rsquo;) option. The
  1656. default behaviour (of not listing the sections that are removed) can
  1657. be restored by specifying &lsquo;<samp>--no-print-gc-sections</samp>&rsquo; on the command
  1658. line.
  1659. </p>
  1660. <a name="index-_002d_002dgc_002dkeep_002dexported"></a>
  1661. <a name="index-garbage-collection-2"></a>
  1662. </dd>
  1663. <dt><code>--gc-keep-exported</code></dt>
  1664. <dd><p>When &lsquo;<samp>--gc-sections</samp>&rsquo; is enabled, this option prevents garbage
  1665. collection of unused input sections that contain global symbols having
  1666. default or protected visibility. This option is intended to be used for
  1667. executables where unreferenced sections would otherwise be garbage
  1668. collected regardless of the external visibility of contained symbols.
  1669. Note that this option has no effect when linking shared objects since
  1670. it is already the default behaviour. This option is only supported for
  1671. ELF format targets.
  1672. </p>
  1673. <a name="index-_002d_002dprint_002doutput_002dformat"></a>
  1674. <a name="index-output-format"></a>
  1675. </dd>
  1676. <dt><code>--print-output-format</code></dt>
  1677. <dd><p>Print the name of the default output format (perhaps influenced by
  1678. other command-line options). This is the string that would appear
  1679. in an <code>OUTPUT_FORMAT</code> linker script command (see <a href="File-Commands.html#File-Commands">File Commands</a>).
  1680. </p>
  1681. <a name="index-_002d_002dprint_002dmemory_002dusage"></a>
  1682. <a name="index-memory-usage"></a>
  1683. </dd>
  1684. <dt><code>--print-memory-usage</code></dt>
  1685. <dd><p>Print used size, total size and used size of memory regions created with
  1686. the <a href="MEMORY.html#MEMORY">MEMORY</a> command. This is useful on embedded targets to have a
  1687. quick view of amount of free memory. The format of the output has one
  1688. headline and one line per region. It is both human readable and easily
  1689. parsable by tools. Here is an example of an output:
  1690. </p>
  1691. <div class="smallexample">
  1692. <pre class="smallexample">Memory region Used Size Region Size %age Used
  1693. ROM: 256 KB 1 MB 25.00%
  1694. RAM: 32 B 2 GB 0.00%
  1695. </pre></div>
  1696. <a name="index-help"></a>
  1697. <a name="index-usage"></a>
  1698. <a name="index-_002d_002dhelp"></a>
  1699. </dd>
  1700. <dt><code>--help</code></dt>
  1701. <dd><p>Print a summary of the command-line options on the standard output and exit.
  1702. </p>
  1703. <a name="index-_002d_002dtarget_002dhelp"></a>
  1704. </dd>
  1705. <dt><code>--target-help</code></dt>
  1706. <dd><p>Print a summary of all target-specific options on the standard output and exit.
  1707. </p>
  1708. <a name="index-_002dMap_003dmapfile"></a>
  1709. </dd>
  1710. <dt><code>-Map=<var>mapfile</var></code></dt>
  1711. <dd><p>Print a link map to the file <var>mapfile</var>. See the description of the
  1712. <samp>-M</samp> option, above. Specifying a directory as <var>mapfile</var>
  1713. causes the linker map to be written into a file inside the directory.
  1714. The name of the file is based upon the <var>output</var> filename with
  1715. <code>.map</code> appended.
  1716. </p>
  1717. <a name="index-memory-usage-1"></a>
  1718. <a name="index-_002d_002dno_002dkeep_002dmemory"></a>
  1719. </dd>
  1720. <dt><code>--no-keep-memory</code></dt>
  1721. <dd><p><code>ld</code> normally optimizes for speed over memory usage by caching the
  1722. symbol tables of input files in memory. This option tells <code>ld</code> to
  1723. instead optimize for memory usage, by rereading the symbol tables as
  1724. necessary. This may be required if <code>ld</code> runs out of memory space
  1725. while linking a large executable.
  1726. </p>
  1727. <a name="index-_002d_002dno_002dundefined"></a>
  1728. <a name="index-_002dz-defs"></a>
  1729. <a name="index-_002dz-undefs"></a>
  1730. </dd>
  1731. <dt><code>--no-undefined</code></dt>
  1732. <dt><code>-z defs</code></dt>
  1733. <dd><p>Report unresolved symbol references from regular object files. This
  1734. is done even if the linker is creating a non-symbolic shared library.
  1735. The switch <samp>--[no-]allow-shlib-undefined</samp> controls the
  1736. behaviour for reporting unresolved references found in shared
  1737. libraries being linked in.
  1738. </p>
  1739. <p>The effects of this option can be reverted by using <code>-z undefs</code>.
  1740. </p>
  1741. <a name="index-_002d_002dallow_002dmultiple_002ddefinition"></a>
  1742. <a name="index-_002dz-muldefs"></a>
  1743. </dd>
  1744. <dt><code>--allow-multiple-definition</code></dt>
  1745. <dt><code>-z muldefs</code></dt>
  1746. <dd><p>Normally when a symbol is defined multiple times, the linker will
  1747. report a fatal error. These options allow multiple definitions and the
  1748. first definition will be used.
  1749. </p>
  1750. <a name="index-_002d_002dallow_002dshlib_002dundefined"></a>
  1751. <a name="index-_002d_002dno_002dallow_002dshlib_002dundefined"></a>
  1752. </dd>
  1753. <dt><code>--allow-shlib-undefined</code></dt>
  1754. <dt><code>--no-allow-shlib-undefined</code></dt>
  1755. <dd><p>Allows or disallows undefined symbols in shared libraries.
  1756. This switch is similar to <samp>--no-undefined</samp> except that it
  1757. determines the behaviour when the undefined symbols are in a
  1758. shared library rather than a regular object file. It does not affect
  1759. how undefined symbols in regular object files are handled.
  1760. </p>
  1761. <p>The default behaviour is to report errors for any undefined symbols
  1762. referenced in shared libraries if the linker is being used to create
  1763. an executable, but to allow them if the linker is being used to create
  1764. a shared library.
  1765. </p>
  1766. <p>The reasons for allowing undefined symbol references in shared
  1767. libraries specified at link time are that:
  1768. </p>
  1769. <ul>
  1770. <li> A shared library specified at link time may not be the same as the one
  1771. that is available at load time, so the symbol might actually be
  1772. resolvable at load time.
  1773. </li><li> There are some operating systems, eg BeOS and HPPA, where undefined
  1774. symbols in shared libraries are normal.
  1775. <p>The BeOS kernel for example patches shared libraries at load time to
  1776. select whichever function is most appropriate for the current
  1777. architecture. This is used, for example, to dynamically select an
  1778. appropriate memset function.
  1779. </p></li></ul>
  1780. <a name="index-_002d_002dno_002dundefined_002dversion"></a>
  1781. </dd>
  1782. <dt><code>--no-undefined-version</code></dt>
  1783. <dd><p>Normally when a symbol has an undefined version, the linker will ignore
  1784. it. This option disallows symbols with undefined version and a fatal error
  1785. will be issued instead.
  1786. </p>
  1787. <a name="index-_002d_002ddefault_002dsymver"></a>
  1788. </dd>
  1789. <dt><code>--default-symver</code></dt>
  1790. <dd><p>Create and use a default symbol version (the soname) for unversioned
  1791. exported symbols.
  1792. </p>
  1793. <a name="index-_002d_002ddefault_002dimported_002dsymver"></a>
  1794. </dd>
  1795. <dt><code>--default-imported-symver</code></dt>
  1796. <dd><p>Create and use a default symbol version (the soname) for unversioned
  1797. imported symbols.
  1798. </p>
  1799. <a name="index-_002d_002dno_002dwarn_002dmismatch"></a>
  1800. </dd>
  1801. <dt><code>--no-warn-mismatch</code></dt>
  1802. <dd><p>Normally <code>ld</code> will give an error if you try to link together input
  1803. files that are mismatched for some reason, perhaps because they have
  1804. been compiled for different processors or for different endiannesses.
  1805. This option tells <code>ld</code> that it should silently permit such possible
  1806. errors. This option should only be used with care, in cases when you
  1807. have taken some special action that ensures that the linker errors are
  1808. inappropriate.
  1809. </p>
  1810. <a name="index-_002d_002dno_002dwarn_002dsearch_002dmismatch"></a>
  1811. </dd>
  1812. <dt><code>--no-warn-search-mismatch</code></dt>
  1813. <dd><p>Normally <code>ld</code> will give a warning if it finds an incompatible
  1814. library during a library search. This option silences the warning.
  1815. </p>
  1816. <a name="index-_002d_002dno_002dwhole_002darchive"></a>
  1817. </dd>
  1818. <dt><code>--no-whole-archive</code></dt>
  1819. <dd><p>Turn off the effect of the <samp>--whole-archive</samp> option for subsequent
  1820. archive files.
  1821. </p>
  1822. <a name="index-output-file-after-errors"></a>
  1823. <a name="index-_002d_002dnoinhibit_002dexec"></a>
  1824. </dd>
  1825. <dt><code>--noinhibit-exec</code></dt>
  1826. <dd><p>Retain the executable output file whenever it is still usable.
  1827. Normally, the linker will not produce an output file if it encounters
  1828. errors during the link process; it exits without writing an output file
  1829. when it issues any error whatsoever.
  1830. </p>
  1831. <a name="index-_002dnostdlib"></a>
  1832. </dd>
  1833. <dt><code>-nostdlib</code></dt>
  1834. <dd><p>Only search library directories explicitly specified on the
  1835. command line. Library directories specified in linker scripts
  1836. (including linker scripts specified on the command line) are ignored.
  1837. </p>
  1838. <a name="index-_002d_002doformat_003doutput_002dformat"></a>
  1839. </dd>
  1840. <dt><code>--oformat=<var>output-format</var></code></dt>
  1841. <dd><p><code>ld</code> may be configured to support more than one kind of object
  1842. file. If your <code>ld</code> is configured this way, you can use the
  1843. &lsquo;<samp>--oformat</samp>&rsquo; option to specify the binary format for the output
  1844. object file. Even when <code>ld</code> is configured to support alternative
  1845. object formats, you don&rsquo;t usually need to specify this, as <code>ld</code>
  1846. should be configured to produce as a default output format the most
  1847. usual format on each machine. <var>output-format</var> is a text string, the
  1848. name of a particular format supported by the BFD libraries. (You can
  1849. list the available binary formats with &lsquo;<samp>objdump -i</samp>&rsquo;.) The script
  1850. command <code>OUTPUT_FORMAT</code> can also specify the output format, but
  1851. this option overrides it. See <a href="BFD.html#BFD">BFD</a>.
  1852. </p>
  1853. <a name="index-_002d_002dout_002dimplib"></a>
  1854. </dd>
  1855. <dt><code>--out-implib <var>file</var></code></dt>
  1856. <dd><p>Create an import library in <var>file</var> corresponding to the executable
  1857. the linker is generating (eg. a DLL or ELF program). This import
  1858. library (which should be called <code>*.dll.a</code> or <code>*.a</code> for DLLs)
  1859. may be used to link clients against the generated executable; this
  1860. behaviour makes it possible to skip a separate import library creation
  1861. step (eg. <code>dlltool</code> for DLLs). This option is only available for
  1862. the i386 PE and ELF targetted ports of the linker.
  1863. </p>
  1864. <a name="index-_002dpie"></a>
  1865. <a name="index-_002d_002dpic_002dexecutable"></a>
  1866. </dd>
  1867. <dt><code>-pie</code></dt>
  1868. <dt><code>--pic-executable</code></dt>
  1869. <dd><a name="index-position-independent-executables"></a>
  1870. <p>Create a position independent executable. This is currently only supported on
  1871. ELF platforms. Position independent executables are similar to shared
  1872. libraries in that they are relocated by the dynamic linker to the virtual
  1873. address the OS chooses for them (which can vary between invocations). Like
  1874. normal dynamically linked executables they can be executed and symbols
  1875. defined in the executable cannot be overridden by shared libraries.
  1876. </p>
  1877. <a name="index-_002dqmagic"></a>
  1878. </dd>
  1879. <dt><code>-qmagic</code></dt>
  1880. <dd><p>This option is ignored for Linux compatibility.
  1881. </p>
  1882. <a name="index-_002dQy"></a>
  1883. </dd>
  1884. <dt><code>-Qy</code></dt>
  1885. <dd><p>This option is ignored for SVR4 compatibility.
  1886. </p>
  1887. <a name="index-_002d_002drelax"></a>
  1888. <a name="index-synthesizing-linker"></a>
  1889. <a name="index-relaxing-addressing-modes"></a>
  1890. <a name="index-_002d_002dno_002drelax"></a>
  1891. </dd>
  1892. <dt><code>--relax</code></dt>
  1893. <dt><code>--no-relax</code></dt>
  1894. <dd><p>An option with machine dependent effects.
  1895. This option is only supported on a few targets.
  1896. See <a href="H8_002f300.html#H8_002f300"><code>ld</code> and the H8/300</a>.
  1897. See <a href="Xtensa.html#Xtensa"><code>ld</code> and Xtensa Processors</a>.
  1898. See <a href="M68HC11_002f68HC12.html#M68HC11_002f68HC12"><code>ld</code> and the 68HC11 and 68HC12</a>.
  1899. See <a href="Nios-II.html#Nios-II"><code>ld</code> and the Altera Nios II</a>.
  1900. See <a href="PowerPC-ELF32.html#PowerPC-ELF32"><code>ld</code> and PowerPC 32-bit ELF Support</a>.
  1901. </p>
  1902. <p>On some platforms the &lsquo;<samp>--relax</samp>&rsquo; option performs target-specific,
  1903. global optimizations that become possible when the linker resolves
  1904. addressing in the program, such as relaxing address modes,
  1905. synthesizing new instructions, selecting shorter version of current
  1906. instructions, and combining constant values.
  1907. </p>
  1908. <p>On some platforms these link time global optimizations may make symbolic
  1909. debugging of the resulting executable impossible.
  1910. This is known to be the case for the Matsushita MN10200 and MN10300
  1911. family of processors.
  1912. </p>
  1913. <p>On platforms where this is not supported, &lsquo;<samp>--relax</samp>&rsquo; is accepted,
  1914. but ignored.
  1915. </p>
  1916. <p>On platforms where &lsquo;<samp>--relax</samp>&rsquo; is accepted the option
  1917. &lsquo;<samp>--no-relax</samp>&rsquo; can be used to disable the feature.
  1918. </p>
  1919. <a name="index-retaining-specified-symbols"></a>
  1920. <a name="index-stripping-all-but-some-symbols"></a>
  1921. <a name="index-symbols_002c-retaining-selectively"></a>
  1922. <a name="index-_002d_002dretain_002dsymbols_002dfile_003dfilename"></a>
  1923. </dd>
  1924. <dt><code>--retain-symbols-file=<var>filename</var></code></dt>
  1925. <dd><p>Retain <em>only</em> the symbols listed in the file <var>filename</var>,
  1926. discarding all others. <var>filename</var> is simply a flat file, with one
  1927. symbol name per line. This option is especially useful in environments
  1928. (such as VxWorks)
  1929. where a large global symbol table is accumulated gradually, to conserve
  1930. run-time memory.
  1931. </p>
  1932. <p>&lsquo;<samp>--retain-symbols-file</samp>&rsquo; does <em>not</em> discard undefined symbols,
  1933. or symbols needed for relocations.
  1934. </p>
  1935. <p>You may only specify &lsquo;<samp>--retain-symbols-file</samp>&rsquo; once in the command
  1936. line. It overrides &lsquo;<samp>-s</samp>&rsquo; and &lsquo;<samp>-S</samp>&rsquo;.
  1937. </p>
  1938. </dd>
  1939. <dt><code>-rpath=<var>dir</var></code></dt>
  1940. <dd><a name="index-runtime-library-search-path"></a>
  1941. <a name="index-_002drpath_003ddir"></a>
  1942. <p>Add a directory to the runtime library search path. This is used when
  1943. linking an ELF executable with shared objects. All <samp>-rpath</samp>
  1944. arguments are concatenated and passed to the runtime linker, which uses
  1945. them to locate shared objects at runtime.
  1946. </p>
  1947. <p>The <samp>-rpath</samp> option is also used when locating shared objects which
  1948. are needed by shared objects explicitly included in the link; see the
  1949. description of the <samp>-rpath-link</samp> option. Searching <samp>-rpath</samp>
  1950. in this way is only supported by native linkers and cross linkers which
  1951. have been configured with the <samp>--with-sysroot</samp> option.
  1952. </p>
  1953. <p>If <samp>-rpath</samp> is not used when linking an ELF executable, the
  1954. contents of the environment variable <code>LD_RUN_PATH</code> will be used if it
  1955. is defined.
  1956. </p>
  1957. <p>The <samp>-rpath</samp> option may also be used on SunOS. By default, on
  1958. SunOS, the linker will form a runtime search path out of all the
  1959. <samp>-L</samp> options it is given. If a <samp>-rpath</samp> option is used, the
  1960. runtime search path will be formed exclusively using the <samp>-rpath</samp>
  1961. options, ignoring the <samp>-L</samp> options. This can be useful when using
  1962. gcc, which adds many <samp>-L</samp> options which may be on NFS mounted
  1963. file systems.
  1964. </p>
  1965. <p>For compatibility with other ELF linkers, if the <samp>-R</samp> option is
  1966. followed by a directory name, rather than a file name, it is treated as
  1967. the <samp>-rpath</samp> option.
  1968. </p>
  1969. <a name="index-link_002dtime-runtime-library-search-path"></a>
  1970. <a name="index-_002drpath_002dlink_003ddir"></a>
  1971. </dd>
  1972. <dt><code>-rpath-link=<var>dir</var></code></dt>
  1973. <dd><p>When using ELF or SunOS, one shared library may require another. This
  1974. happens when an <code>ld -shared</code> link includes a shared library as one
  1975. of the input files.
  1976. </p>
  1977. <p>When the linker encounters such a dependency when doing a non-shared,
  1978. non-relocatable link, it will automatically try to locate the required
  1979. shared library and include it in the link, if it is not included
  1980. explicitly. In such a case, the <samp>-rpath-link</samp> option
  1981. specifies the first set of directories to search. The
  1982. <samp>-rpath-link</samp> option may specify a sequence of directory names
  1983. either by specifying a list of names separated by colons, or by
  1984. appearing multiple times.
  1985. </p>
  1986. <p>The tokens <var>$ORIGIN</var> and <var>$LIB</var> can appear in these search
  1987. directories. They will be replaced by the full path to the directory
  1988. containing the program or shared object in the case of <var>$ORIGIN</var>
  1989. and either &lsquo;<samp>lib</samp>&rsquo; - for 32-bit binaries - or &lsquo;<samp>lib64</samp>&rsquo; - for
  1990. 64-bit binaries - in the case of <var>$LIB</var>.
  1991. </p>
  1992. <p>The alternative form of these tokens - <var>${ORIGIN}</var> and
  1993. <var>${LIB}</var> can also be used. The token <var>$PLATFORM</var> is not
  1994. supported.
  1995. </p>
  1996. <p>This option should be used with caution as it overrides the search path
  1997. that may have been hard compiled into a shared library. In such a case it
  1998. is possible to use unintentionally a different search path than the
  1999. runtime linker would do.
  2000. </p>
  2001. <p>The linker uses the following search paths to locate required shared
  2002. libraries:
  2003. </p>
  2004. <ol>
  2005. <li> Any directories specified by <samp>-rpath-link</samp> options.
  2006. </li><li> Any directories specified by <samp>-rpath</samp> options. The difference
  2007. between <samp>-rpath</samp> and <samp>-rpath-link</samp> is that directories
  2008. specified by <samp>-rpath</samp> options are included in the executable and
  2009. used at runtime, whereas the <samp>-rpath-link</samp> option is only effective
  2010. at link time. Searching <samp>-rpath</samp> in this way is only supported
  2011. by native linkers and cross linkers which have been configured with
  2012. the <samp>--with-sysroot</samp> option.
  2013. </li><li> On an ELF system, for native linkers, if the <samp>-rpath</samp> and
  2014. <samp>-rpath-link</samp> options were not used, search the contents of the
  2015. environment variable <code>LD_RUN_PATH</code>.
  2016. </li><li> On SunOS, if the <samp>-rpath</samp> option was not used, search any
  2017. directories specified using <samp>-L</samp> options.
  2018. </li><li> For a native linker, search the contents of the environment
  2019. variable <code>LD_LIBRARY_PATH</code>.
  2020. </li><li> For a native ELF linker, the directories in <code>DT_RUNPATH</code> or
  2021. <code>DT_RPATH</code> of a shared library are searched for shared
  2022. libraries needed by it. The <code>DT_RPATH</code> entries are ignored if
  2023. <code>DT_RUNPATH</code> entries exist.
  2024. </li><li> The default directories, normally <samp>/lib</samp> and <samp>/usr/lib</samp>.
  2025. </li><li> For a linker for a Linux system, if the file <samp>/etc/ld.so.conf</samp>
  2026. exists, the list of directories found in that file. Note: the path
  2027. to this file is prefixed with the <code>sysroot</code> value, if that is
  2028. defined, and then any <code>prefix</code> string if the linker was
  2029. configured with the <code>--prefix=&lt;path&gt;</code> option.
  2030. </li><li> For a native linker on a FreeBSD system, any directories specified by
  2031. the <code>_PATH_ELF_HINTS</code> macro defined in the <samp>elf-hints.h</samp>
  2032. header file.
  2033. </li><li> Any directories specifed by a <code>SEARCH_DIR</code> command in the
  2034. linker script being used.
  2035. </li></ol>
  2036. <p>If the required shared library is not found, the linker will issue a
  2037. warning and continue with the link.
  2038. </p>
  2039. <a name="index-_002dshared"></a>
  2040. <a name="index-_002dBshareable"></a>
  2041. </dd>
  2042. <dt><code>-shared</code></dt>
  2043. <dt><code>-Bshareable</code></dt>
  2044. <dd><a name="index-shared-libraries"></a>
  2045. <p>Create a shared library. This is currently only supported on ELF, XCOFF
  2046. and SunOS platforms. On SunOS, the linker will automatically create a
  2047. shared library if the <samp>-e</samp> option is not used and there are
  2048. undefined symbols in the link.
  2049. </p>
  2050. <a name="index-_002d_002dsort_002dcommon"></a>
  2051. </dd>
  2052. <dt><code>--sort-common</code></dt>
  2053. <dt><code>--sort-common=ascending</code></dt>
  2054. <dt><code>--sort-common=descending</code></dt>
  2055. <dd><p>This option tells <code>ld</code> to sort the common symbols by alignment in
  2056. ascending or descending order when it places them in the appropriate output
  2057. sections. The symbol alignments considered are sixteen-byte or larger,
  2058. eight-byte, four-byte, two-byte, and one-byte. This is to prevent gaps
  2059. between symbols due to alignment constraints. If no sorting order is
  2060. specified, then descending order is assumed.
  2061. </p>
  2062. <a name="index-_002d_002dsort_002dsection_003dname"></a>
  2063. </dd>
  2064. <dt><code>--sort-section=name</code></dt>
  2065. <dd><p>This option will apply <code>SORT_BY_NAME</code> to all wildcard section
  2066. patterns in the linker script.
  2067. </p>
  2068. <a name="index-_002d_002dsort_002dsection_003dalignment"></a>
  2069. </dd>
  2070. <dt><code>--sort-section=alignment</code></dt>
  2071. <dd><p>This option will apply <code>SORT_BY_ALIGNMENT</code> to all wildcard section
  2072. patterns in the linker script.
  2073. </p>
  2074. <a name="index-_002d_002dspare_002ddynamic_002dtags"></a>
  2075. </dd>
  2076. <dt><code>--spare-dynamic-tags=<var>count</var></code></dt>
  2077. <dd><p>This option specifies the number of empty slots to leave in the
  2078. .dynamic section of ELF shared objects. Empty slots may be needed by
  2079. post processing tools, such as the prelinker. The default is 5.
  2080. </p>
  2081. <a name="index-_002d_002dsplit_002dby_002dfile"></a>
  2082. </dd>
  2083. <dt><code>--split-by-file[=<var>size</var>]</code></dt>
  2084. <dd><p>Similar to <samp>--split-by-reloc</samp> but creates a new output section for
  2085. each input file when <var>size</var> is reached. <var>size</var> defaults to a
  2086. size of 1 if not given.
  2087. </p>
  2088. <a name="index-_002d_002dsplit_002dby_002dreloc"></a>
  2089. </dd>
  2090. <dt><code>--split-by-reloc[=<var>count</var>]</code></dt>
  2091. <dd><p>Tries to creates extra sections in the output file so that no single
  2092. output section in the file contains more than <var>count</var> relocations.
  2093. This is useful when generating huge relocatable files for downloading into
  2094. certain real time kernels with the COFF object file format; since COFF
  2095. cannot represent more than 65535 relocations in a single section. Note
  2096. that this will fail to work with object file formats which do not
  2097. support arbitrary sections. The linker will not split up individual
  2098. input sections for redistribution, so if a single input section contains
  2099. more than <var>count</var> relocations one output section will contain that
  2100. many relocations. <var>count</var> defaults to a value of 32768.
  2101. </p>
  2102. <a name="index-_002d_002dstats"></a>
  2103. </dd>
  2104. <dt><code>--stats</code></dt>
  2105. <dd><p>Compute and display statistics about the operation of the linker, such
  2106. as execution time and memory usage.
  2107. </p>
  2108. <a name="index-_002d_002dsysroot_003ddirectory"></a>
  2109. </dd>
  2110. <dt><code>--sysroot=<var>directory</var></code></dt>
  2111. <dd><p>Use <var>directory</var> as the location of the sysroot, overriding the
  2112. configure-time default. This option is only supported by linkers
  2113. that were configured using <samp>--with-sysroot</samp>.
  2114. </p>
  2115. <a name="index-_002d_002dtask_002dlink"></a>
  2116. </dd>
  2117. <dt><code>--task-link</code></dt>
  2118. <dd><p>This is used by COFF/PE based targets to create a task-linked object
  2119. file where all of the global symbols have been converted to statics.
  2120. </p>
  2121. <a name="index-_002d_002dtraditional_002dformat"></a>
  2122. <a name="index-traditional-format"></a>
  2123. </dd>
  2124. <dt><code>--traditional-format</code></dt>
  2125. <dd><p>For some targets, the output of <code>ld</code> is different in some ways from
  2126. the output of some existing linker. This switch requests <code>ld</code> to
  2127. use the traditional format instead.
  2128. </p>
  2129. <a name="index-dbx"></a>
  2130. <p>For example, on SunOS, <code>ld</code> combines duplicate entries in the
  2131. symbol string table. This can reduce the size of an output file with
  2132. full debugging information by over 30 percent. Unfortunately, the SunOS
  2133. <code>dbx</code> program can not read the resulting program (<code>gdb</code> has no
  2134. trouble). The &lsquo;<samp>--traditional-format</samp>&rsquo; switch tells <code>ld</code> to not
  2135. combine duplicate entries.
  2136. </p>
  2137. <a name="index-_002d_002dsection_002dstart_003dsectionname_003dorg"></a>
  2138. </dd>
  2139. <dt><code>--section-start=<var>sectionname</var>=<var>org</var></code></dt>
  2140. <dd><p>Locate a section in the output file at the absolute
  2141. address given by <var>org</var>. You may use this option as many
  2142. times as necessary to locate multiple sections in the command
  2143. line.
  2144. <var>org</var> must be a single hexadecimal integer;
  2145. for compatibility with other linkers, you may omit the leading
  2146. &lsquo;<samp>0x</samp>&rsquo; usually associated with hexadecimal values. <em>Note:</em> there
  2147. should be no white space between <var>sectionname</var>, the equals
  2148. sign (&ldquo;<tt class="key">=</tt>&rdquo;), and <var>org</var>.
  2149. </p>
  2150. <a name="index-_002dTbss_003dorg"></a>
  2151. <a name="index-_002dTdata_003dorg"></a>
  2152. <a name="index-_002dTtext_003dorg"></a>
  2153. <a name="index-segment-origins_002c-cmd-line"></a>
  2154. </dd>
  2155. <dt><code>-Tbss=<var>org</var></code></dt>
  2156. <dt><code>-Tdata=<var>org</var></code></dt>
  2157. <dt><code>-Ttext=<var>org</var></code></dt>
  2158. <dd><p>Same as <samp>--section-start</samp>, with <code>.bss</code>, <code>.data</code> or
  2159. <code>.text</code> as the <var>sectionname</var>.
  2160. </p>
  2161. <a name="index-_002dTtext_002dsegment_003dorg"></a>
  2162. </dd>
  2163. <dt><code>-Ttext-segment=<var>org</var></code></dt>
  2164. <dd><a name="index-text-segment-origin_002c-cmd-line"></a>
  2165. <p>When creating an ELF executable, it will set the address of the first
  2166. byte of the text segment.
  2167. </p>
  2168. <a name="index-_002dTrodata_002dsegment_003dorg"></a>
  2169. </dd>
  2170. <dt><code>-Trodata-segment=<var>org</var></code></dt>
  2171. <dd><a name="index-rodata-segment-origin_002c-cmd-line"></a>
  2172. <p>When creating an ELF executable or shared object for a target where
  2173. the read-only data is in its own segment separate from the executable
  2174. text, it will set the address of the first byte of the read-only data segment.
  2175. </p>
  2176. <a name="index-_002dTldata_002dsegment_003dorg"></a>
  2177. </dd>
  2178. <dt><code>-Tldata-segment=<var>org</var></code></dt>
  2179. <dd><a name="index-ldata-segment-origin_002c-cmd-line"></a>
  2180. <p>When creating an ELF executable or shared object for x86-64 medium memory
  2181. model, it will set the address of the first byte of the ldata segment.
  2182. </p>
  2183. <a name="index-_002d_002dunresolved_002dsymbols"></a>
  2184. </dd>
  2185. <dt><code>--unresolved-symbols=<var>method</var></code></dt>
  2186. <dd><p>Determine how to handle unresolved symbols. There are four possible
  2187. values for &lsquo;<samp>method</samp>&rsquo;:
  2188. </p>
  2189. <dl compact="compact">
  2190. <dt>&lsquo;<samp>ignore-all</samp>&rsquo;</dt>
  2191. <dd><p>Do not report any unresolved symbols.
  2192. </p>
  2193. </dd>
  2194. <dt>&lsquo;<samp>report-all</samp>&rsquo;</dt>
  2195. <dd><p>Report all unresolved symbols. This is the default.
  2196. </p>
  2197. </dd>
  2198. <dt>&lsquo;<samp>ignore-in-object-files</samp>&rsquo;</dt>
  2199. <dd><p>Report unresolved symbols that are contained in shared libraries, but
  2200. ignore them if they come from regular object files.
  2201. </p>
  2202. </dd>
  2203. <dt>&lsquo;<samp>ignore-in-shared-libs</samp>&rsquo;</dt>
  2204. <dd><p>Report unresolved symbols that come from regular object files, but
  2205. ignore them if they come from shared libraries. This can be useful
  2206. when creating a dynamic binary and it is known that all the shared
  2207. libraries that it should be referencing are included on the linker&rsquo;s
  2208. command line.
  2209. </p></dd>
  2210. </dl>
  2211. <p>The behaviour for shared libraries on their own can also be controlled
  2212. by the <samp>--[no-]allow-shlib-undefined</samp> option.
  2213. </p>
  2214. <p>Normally the linker will generate an error message for each reported
  2215. unresolved symbol but the option <samp>--warn-unresolved-symbols</samp>
  2216. can change this to a warning.
  2217. </p>
  2218. <a name="index-_002d_002dverbose_005b_003dNUMBER_005d"></a>
  2219. <a name="index-verbose_005b_003dNUMBER_005d"></a>
  2220. </dd>
  2221. <dt><code>--dll-verbose</code></dt>
  2222. <dt><code>--verbose[=<var>NUMBER</var>]</code></dt>
  2223. <dd><p>Display the version number for <code>ld</code> and list the linker emulations
  2224. supported. Display which input files can and cannot be opened. Display
  2225. the linker script being used by the linker. If the optional <var>NUMBER</var>
  2226. argument &gt; 1, plugin symbol status will also be displayed.
  2227. </p>
  2228. <a name="index-_002d_002dversion_002dscript_003dversion_002dscriptfile"></a>
  2229. <a name="index-version-script_002c-symbol-versions"></a>
  2230. </dd>
  2231. <dt><code>--version-script=<var>version-scriptfile</var></code></dt>
  2232. <dd><p>Specify the name of a version script to the linker. This is typically
  2233. used when creating shared libraries to specify additional information
  2234. about the version hierarchy for the library being created. This option
  2235. is only fully supported on ELF platforms which support shared libraries;
  2236. see <a href="VERSION.html#VERSION">VERSION</a>. It is partially supported on PE platforms, which can
  2237. use version scripts to filter symbol visibility in auto-export mode: any
  2238. symbols marked &lsquo;<samp>local</samp>&rsquo; in the version script will not be exported.
  2239. See <a href="WIN32.html#WIN32">WIN32</a>.
  2240. </p>
  2241. <a name="index-_002d_002dwarn_002dcommon"></a>
  2242. <a name="index-warnings_002c-on-combining-symbols"></a>
  2243. <a name="index-combining-symbols_002c-warnings-on"></a>
  2244. </dd>
  2245. <dt><code>--warn-common</code></dt>
  2246. <dd><p>Warn when a common symbol is combined with another common symbol or with
  2247. a symbol definition. Unix linkers allow this somewhat sloppy practice,
  2248. but linkers on some other operating systems do not. This option allows
  2249. you to find potential problems from combining global symbols.
  2250. Unfortunately, some C libraries use this practice, so you may get some
  2251. warnings about symbols in the libraries as well as in your programs.
  2252. </p>
  2253. <p>There are three kinds of global symbols, illustrated here by C examples:
  2254. </p>
  2255. <dl compact="compact">
  2256. <dt>&lsquo;<samp>int i = 1;</samp>&rsquo;</dt>
  2257. <dd><p>A definition, which goes in the initialized data section of the output
  2258. file.
  2259. </p>
  2260. </dd>
  2261. <dt>&lsquo;<samp>extern int i;</samp>&rsquo;</dt>
  2262. <dd><p>An undefined reference, which does not allocate space.
  2263. There must be either a definition or a common symbol for the
  2264. variable somewhere.
  2265. </p>
  2266. </dd>
  2267. <dt>&lsquo;<samp>int i;</samp>&rsquo;</dt>
  2268. <dd><p>A common symbol. If there are only (one or more) common symbols for a
  2269. variable, it goes in the uninitialized data area of the output file.
  2270. The linker merges multiple common symbols for the same variable into a
  2271. single symbol. If they are of different sizes, it picks the largest
  2272. size. The linker turns a common symbol into a declaration, if there is
  2273. a definition of the same variable.
  2274. </p></dd>
  2275. </dl>
  2276. <p>The &lsquo;<samp>--warn-common</samp>&rsquo; option can produce five kinds of warnings.
  2277. Each warning consists of a pair of lines: the first describes the symbol
  2278. just encountered, and the second describes the previous symbol
  2279. encountered with the same name. One or both of the two symbols will be
  2280. a common symbol.
  2281. </p>
  2282. <ol>
  2283. <li> Turning a common symbol into a reference, because there is already a
  2284. definition for the symbol.
  2285. <div class="smallexample">
  2286. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
  2287. overridden by definition
  2288. <var>file</var>(<var>section</var>): warning: defined here
  2289. </pre></div>
  2290. </li><li> Turning a common symbol into a reference, because a later definition for
  2291. the symbol is encountered. This is the same as the previous case,
  2292. except that the symbols are encountered in a different order.
  2293. <div class="smallexample">
  2294. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: definition of `<var>symbol</var>'
  2295. overriding common
  2296. <var>file</var>(<var>section</var>): warning: common is here
  2297. </pre></div>
  2298. </li><li> Merging a common symbol with a previous same-sized common symbol.
  2299. <div class="smallexample">
  2300. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: multiple common
  2301. of `<var>symbol</var>'
  2302. <var>file</var>(<var>section</var>): warning: previous common is here
  2303. </pre></div>
  2304. </li><li> Merging a common symbol with a previous larger common symbol.
  2305. <div class="smallexample">
  2306. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
  2307. overridden by larger common
  2308. <var>file</var>(<var>section</var>): warning: larger common is here
  2309. </pre></div>
  2310. </li><li> Merging a common symbol with a previous smaller common symbol. This is
  2311. the same as the previous case, except that the symbols are
  2312. encountered in a different order.
  2313. <div class="smallexample">
  2314. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
  2315. overriding smaller common
  2316. <var>file</var>(<var>section</var>): warning: smaller common is here
  2317. </pre></div>
  2318. </li></ol>
  2319. <a name="index-_002d_002dwarn_002dconstructors"></a>
  2320. </dd>
  2321. <dt><code>--warn-constructors</code></dt>
  2322. <dd><p>Warn if any global constructors are used. This is only useful for a few
  2323. object file formats. For formats like COFF or ELF, the linker can not
  2324. detect the use of global constructors.
  2325. </p>
  2326. <a name="index-_002d_002dwarn_002dmultiple_002dgp"></a>
  2327. </dd>
  2328. <dt><code>--warn-multiple-gp</code></dt>
  2329. <dd><p>Warn if multiple global pointer values are required in the output file.
  2330. This is only meaningful for certain processors, such as the Alpha.
  2331. Specifically, some processors put large-valued constants in a special
  2332. section. A special register (the global pointer) points into the middle
  2333. of this section, so that constants can be loaded efficiently via a
  2334. base-register relative addressing mode. Since the offset in
  2335. base-register relative mode is fixed and relatively small (e.g., 16
  2336. bits), this limits the maximum size of the constant pool. Thus, in
  2337. large programs, it is often necessary to use multiple global pointer
  2338. values in order to be able to address all possible constants. This
  2339. option causes a warning to be issued whenever this case occurs.
  2340. </p>
  2341. <a name="index-_002d_002dwarn_002donce"></a>
  2342. <a name="index-warnings_002c-on-undefined-symbols"></a>
  2343. <a name="index-undefined-symbols_002c-warnings-on"></a>
  2344. </dd>
  2345. <dt><code>--warn-once</code></dt>
  2346. <dd><p>Only warn once for each undefined symbol, rather than once per module
  2347. which refers to it.
  2348. </p>
  2349. <a name="index-_002d_002dwarn_002dsection_002dalign"></a>
  2350. <a name="index-warnings_002c-on-section-alignment"></a>
  2351. <a name="index-section-alignment_002c-warnings-on"></a>
  2352. </dd>
  2353. <dt><code>--warn-section-align</code></dt>
  2354. <dd><p>Warn if the address of an output section is changed because of
  2355. alignment. Typically, the alignment will be set by an input section.
  2356. The address will only be changed if it not explicitly specified; that
  2357. is, if the <code>SECTIONS</code> command does not specify a start address for
  2358. the section (see <a href="SECTIONS.html#SECTIONS">SECTIONS</a>).
  2359. </p>
  2360. <a name="index-_002d_002dwarn_002dtextrel"></a>
  2361. </dd>
  2362. <dt><code>--warn-textrel</code></dt>
  2363. <dd><p>Warn if the linker adds DT_TEXTREL to a position-independent executable
  2364. or shared object.
  2365. </p>
  2366. <a name="index-_002d_002dwarn_002dalternate_002dem"></a>
  2367. </dd>
  2368. <dt><code>--warn-alternate-em</code></dt>
  2369. <dd><p>Warn if an object has alternate ELF machine code.
  2370. </p>
  2371. <a name="index-_002d_002dwarn_002dunresolved_002dsymbols"></a>
  2372. </dd>
  2373. <dt><code>--warn-unresolved-symbols</code></dt>
  2374. <dd><p>If the linker is going to report an unresolved symbol (see the option
  2375. <samp>--unresolved-symbols</samp>) it will normally generate an error.
  2376. This option makes it generate a warning instead.
  2377. </p>
  2378. <a name="index-_002d_002derror_002dunresolved_002dsymbols"></a>
  2379. </dd>
  2380. <dt><code>--error-unresolved-symbols</code></dt>
  2381. <dd><p>This restores the linker&rsquo;s default behaviour of generating errors when
  2382. it is reporting unresolved symbols.
  2383. </p>
  2384. <a name="index-_002d_002dwhole_002darchive"></a>
  2385. <a name="index-including-an-entire-archive"></a>
  2386. </dd>
  2387. <dt><code>--whole-archive</code></dt>
  2388. <dd><p>For each archive mentioned on the command line after the
  2389. <samp>--whole-archive</samp> option, include every object file in the archive
  2390. in the link, rather than searching the archive for the required object
  2391. files. This is normally used to turn an archive file into a shared
  2392. library, forcing every object to be included in the resulting shared
  2393. library. This option may be used more than once.
  2394. </p>
  2395. <p>Two notes when using this option from gcc: First, gcc doesn&rsquo;t know
  2396. about this option, so you have to use <samp>-Wl,-whole-archive</samp>.
  2397. Second, don&rsquo;t forget to use <samp>-Wl,-no-whole-archive</samp> after your
  2398. list of archives, because gcc will add its own list of archives to
  2399. your link and you may not want this flag to affect those as well.
  2400. </p>
  2401. <a name="index-_002d_002dwrap_003dsymbol"></a>
  2402. </dd>
  2403. <dt><code>--wrap=<var>symbol</var></code></dt>
  2404. <dd><p>Use a wrapper function for <var>symbol</var>. Any undefined reference to
  2405. <var>symbol</var> will be resolved to <code>__wrap_<var>symbol</var></code>. Any
  2406. undefined reference to <code>__real_<var>symbol</var></code> will be resolved to
  2407. <var>symbol</var>.
  2408. </p>
  2409. <p>This can be used to provide a wrapper for a system function. The
  2410. wrapper function should be called <code>__wrap_<var>symbol</var></code>. If it
  2411. wishes to call the system function, it should call
  2412. <code>__real_<var>symbol</var></code>.
  2413. </p>
  2414. <p>Here is a trivial example:
  2415. </p>
  2416. <div class="smallexample">
  2417. <pre class="smallexample">void *
  2418. __wrap_malloc (size_t c)
  2419. {
  2420. printf (&quot;malloc called with %zu\n&quot;, c);
  2421. return __real_malloc (c);
  2422. }
  2423. </pre></div>
  2424. <p>If you link other code with this file using <samp>--wrap malloc</samp>, then
  2425. all calls to <code>malloc</code> will call the function <code>__wrap_malloc</code>
  2426. instead. The call to <code>__real_malloc</code> in <code>__wrap_malloc</code> will
  2427. call the real <code>malloc</code> function.
  2428. </p>
  2429. <p>You may wish to provide a <code>__real_malloc</code> function as well, so that
  2430. links without the <samp>--wrap</samp> option will succeed. If you do this,
  2431. you should not put the definition of <code>__real_malloc</code> in the same
  2432. file as <code>__wrap_malloc</code>; if you do, the assembler may resolve the
  2433. call before the linker has a chance to wrap it to <code>malloc</code>.
  2434. </p>
  2435. <p>Only undefined references are replaced by the linker. So, translation unit
  2436. internal references to <var>symbol</var> are not resolved to
  2437. <code>__wrap_<var>symbol</var></code>. In the next example, the call to <code>f</code> in
  2438. <code>g</code> is not resolved to <code>__wrap_f</code>.
  2439. </p>
  2440. <div class="smallexample">
  2441. <pre class="smallexample">int
  2442. f (void)
  2443. {
  2444. return 123;
  2445. }
  2446. int
  2447. g (void)
  2448. {
  2449. return f();
  2450. }
  2451. </pre></div>
  2452. <a name="index-_002d_002deh_002dframe_002dhdr"></a>
  2453. <a name="index-_002d_002dno_002deh_002dframe_002dhdr"></a>
  2454. </dd>
  2455. <dt><code>--eh-frame-hdr</code></dt>
  2456. <dt><code>--no-eh-frame-hdr</code></dt>
  2457. <dd><p>Request (<samp>--eh-frame-hdr</samp>) or suppress
  2458. (<samp>--no-eh-frame-hdr</samp>) the creation of <code>.eh_frame_hdr</code>
  2459. section and ELF <code>PT_GNU_EH_FRAME</code> segment header.
  2460. </p>
  2461. <a name="index-_002d_002dld_002dgenerated_002dunwind_002dinfo"></a>
  2462. </dd>
  2463. <dt><code>--no-ld-generated-unwind-info</code></dt>
  2464. <dd><p>Request creation of <code>.eh_frame</code> unwind info for linker
  2465. generated code sections like PLT. This option is on by default
  2466. if linker generated unwind info is supported.
  2467. </p>
  2468. <a name="index-_002d_002denable_002dnew_002ddtags"></a>
  2469. <a name="index-_002d_002ddisable_002dnew_002ddtags"></a>
  2470. </dd>
  2471. <dt><code>--enable-new-dtags</code></dt>
  2472. <dt><code>--disable-new-dtags</code></dt>
  2473. <dd><p>This linker can create the new dynamic tags in ELF. But the older ELF
  2474. systems may not understand them. If you specify
  2475. <samp>--enable-new-dtags</samp>, the new dynamic tags will be created as needed
  2476. and older dynamic tags will be omitted.
  2477. If you specify <samp>--disable-new-dtags</samp>, no new dynamic tags will be
  2478. created. By default, the new dynamic tags are not created. Note that
  2479. those options are only available for ELF systems.
  2480. </p>
  2481. <a name="index-_002d_002dhash_002dsize_003dnumber"></a>
  2482. </dd>
  2483. <dt><code>--hash-size=<var>number</var></code></dt>
  2484. <dd><p>Set the default size of the linker&rsquo;s hash tables to a prime number
  2485. close to <var>number</var>. Increasing this value can reduce the length of
  2486. time it takes the linker to perform its tasks, at the expense of
  2487. increasing the linker&rsquo;s memory requirements. Similarly reducing this
  2488. value can reduce the memory requirements at the expense of speed.
  2489. </p>
  2490. <a name="index-_002d_002dhash_002dstyle_003dstyle"></a>
  2491. </dd>
  2492. <dt><code>--hash-style=<var>style</var></code></dt>
  2493. <dd><p>Set the type of linker&rsquo;s hash table(s). <var>style</var> can be either
  2494. <code>sysv</code> for classic ELF <code>.hash</code> section, <code>gnu</code> for
  2495. new style GNU <code>.gnu.hash</code> section or <code>both</code> for both
  2496. the classic ELF <code>.hash</code> and new style GNU <code>.gnu.hash</code>
  2497. hash tables. The default depends upon how the linker was configured,
  2498. but for most Linux based systems it will be <code>both</code>.
  2499. </p>
  2500. <a name="index-_002d_002dcompress_002ddebug_002dsections_003dnone"></a>
  2501. <a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib"></a>
  2502. <a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib_002dgnu"></a>
  2503. <a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib_002dgabi"></a>
  2504. </dd>
  2505. <dt><code>--compress-debug-sections=none</code></dt>
  2506. <dt><code>--compress-debug-sections=zlib</code></dt>
  2507. <dt><code>--compress-debug-sections=zlib-gnu</code></dt>
  2508. <dt><code>--compress-debug-sections=zlib-gabi</code></dt>
  2509. <dd><p>On ELF platforms, these options control how DWARF debug sections are
  2510. compressed using zlib.
  2511. </p>
  2512. <p><samp>--compress-debug-sections=none</samp> doesn&rsquo;t compress DWARF debug
  2513. sections. <samp>--compress-debug-sections=zlib-gnu</samp> compresses
  2514. DWARF debug sections and renames them to begin with &lsquo;<samp>.zdebug</samp>&rsquo;
  2515. instead of &lsquo;<samp>.debug</samp>&rsquo;. <samp>--compress-debug-sections=zlib-gabi</samp>
  2516. also compresses DWARF debug sections, but rather than renaming them it
  2517. sets the SHF_COMPRESSED flag in the sections&rsquo; headers.
  2518. </p>
  2519. <p>The <samp>--compress-debug-sections=zlib</samp> option is an alias for
  2520. <samp>--compress-debug-sections=zlib-gabi</samp>.
  2521. </p>
  2522. <p>Note that this option overrides any compression in input debug
  2523. sections, so if a binary is linked with <samp>--compress-debug-sections=none</samp>
  2524. for example, then any compressed debug sections in input files will be
  2525. uncompressed before they are copied into the output binary.
  2526. </p>
  2527. <p>The default compression behaviour varies depending upon the target
  2528. involved and the configure options used to build the toolchain. The
  2529. default can be determined by examining the output from the linker&rsquo;s
  2530. <samp>--help</samp> option.
  2531. </p>
  2532. <a name="index-_002d_002dreduce_002dmemory_002doverheads"></a>
  2533. </dd>
  2534. <dt><code>--reduce-memory-overheads</code></dt>
  2535. <dd><p>This option reduces memory requirements at ld runtime, at the expense of
  2536. linking speed. This was introduced to select the old O(n^2) algorithm
  2537. for link map file generation, rather than the new O(n) algorithm which uses
  2538. about 40% more memory for symbol storage.
  2539. </p>
  2540. <p>Another effect of the switch is to set the default hash table size to
  2541. 1021, which again saves memory at the cost of lengthening the linker&rsquo;s
  2542. run time. This is not done however if the <samp>--hash-size</samp> switch
  2543. has been used.
  2544. </p>
  2545. <p>The <samp>--reduce-memory-overheads</samp> switch may be also be used to
  2546. enable other tradeoffs in future versions of the linker.
  2547. </p>
  2548. <a name="index-_002d_002dbuild_002did"></a>
  2549. <a name="index-_002d_002dbuild_002did_003dstyle"></a>
  2550. </dd>
  2551. <dt><code>--build-id</code></dt>
  2552. <dt><code>--build-id=<var>style</var></code></dt>
  2553. <dd><p>Request the creation of a <code>.note.gnu.build-id</code> ELF note section
  2554. or a <code>.buildid</code> COFF section. The contents of the note are
  2555. unique bits identifying this linked file. <var>style</var> can be
  2556. <code>uuid</code> to use 128 random bits, <code>sha1</code> to use a 160-bit
  2557. <small>SHA1</small> hash on the normative parts of the output contents,
  2558. <code>md5</code> to use a 128-bit <small>MD5</small> hash on the normative parts of
  2559. the output contents, or <code>0x<var>hexstring</var></code> to use a chosen bit
  2560. string specified as an even number of hexadecimal digits (<code>-</code> and
  2561. <code>:</code> characters between digit pairs are ignored). If <var>style</var>
  2562. is omitted, <code>sha1</code> is used.
  2563. </p>
  2564. <p>The <code>md5</code> and <code>sha1</code> styles produces an identifier
  2565. that is always the same in an identical output file, but will be
  2566. unique among all nonidentical output files. It is not intended
  2567. to be compared as a checksum for the file&rsquo;s contents. A linked
  2568. file may be changed later by other tools, but the build ID bit
  2569. string identifying the original linked file does not change.
  2570. </p>
  2571. <p>Passing <code>none</code> for <var>style</var> disables the setting from any
  2572. <code>--build-id</code> options earlier on the command line.
  2573. </p></dd>
  2574. </dl>
  2575. <a name="Options-Specific-to-i386-PE-Targets"></a>
  2576. <h4 class="subsection">2.1.1 Options Specific to i386 PE Targets</h4>
  2577. <p>The i386 PE linker supports the <samp>-shared</samp> option, which causes
  2578. the output to be a dynamically linked library (DLL) instead of a
  2579. normal executable. You should name the output <code>*.dll</code> when you
  2580. use this option. In addition, the linker fully supports the standard
  2581. <code>*.def</code> files, which may be specified on the linker command line
  2582. like an object file (in fact, it should precede archives it exports
  2583. symbols from, to ensure that they get linked in, just like a normal
  2584. object file).
  2585. </p>
  2586. <p>In addition to the options common to all targets, the i386 PE linker
  2587. support additional command-line options that are specific to the i386
  2588. PE target. Options that take values may be separated from their
  2589. values by either a space or an equals sign.
  2590. </p>
  2591. <dl compact="compact">
  2592. <dd>
  2593. <a name="index-_002d_002dadd_002dstdcall_002dalias"></a>
  2594. </dd>
  2595. <dt><code>--add-stdcall-alias</code></dt>
  2596. <dd><p>If given, symbols with a stdcall suffix (@<var>nn</var>) will be exported
  2597. as-is and also with the suffix stripped.
  2598. [This option is specific to the i386 PE targeted port of the linker]
  2599. </p>
  2600. <a name="index-_002d_002dbase_002dfile"></a>
  2601. </dd>
  2602. <dt><code>--base-file <var>file</var></code></dt>
  2603. <dd><p>Use <var>file</var> as the name of a file in which to save the base
  2604. addresses of all the relocations needed for generating DLLs with
  2605. <samp>dlltool</samp>.
  2606. [This is an i386 PE specific option]
  2607. </p>
  2608. <a name="index-_002d_002ddll"></a>
  2609. </dd>
  2610. <dt><code>--dll</code></dt>
  2611. <dd><p>Create a DLL instead of a regular executable. You may also use
  2612. <samp>-shared</samp> or specify a <code>LIBRARY</code> in a given <code>.def</code>
  2613. file.
  2614. [This option is specific to the i386 PE targeted port of the linker]
  2615. </p>
  2616. <a name="index-_002d_002denable_002dlong_002dsection_002dnames"></a>
  2617. <a name="index-_002d_002ddisable_002dlong_002dsection_002dnames"></a>
  2618. </dd>
  2619. <dt><code>--enable-long-section-names</code></dt>
  2620. <dt><code>--disable-long-section-names</code></dt>
  2621. <dd><p>The PE variants of the COFF object format add an extension that permits
  2622. the use of section names longer than eight characters, the normal limit
  2623. for COFF. By default, these names are only allowed in object files, as
  2624. fully-linked executable images do not carry the COFF string table required
  2625. to support the longer names. As a GNU extension, it is possible to
  2626. allow their use in executable images as well, or to (probably pointlessly!)
  2627. disallow it in object files, by using these two options. Executable images
  2628. generated with these long section names are slightly non-standard, carrying
  2629. as they do a string table, and may generate confusing output when examined
  2630. with non-GNU PE-aware tools, such as file viewers and dumpers. However,
  2631. GDB relies on the use of PE long section names to find Dwarf-2 debug
  2632. information sections in an executable image at runtime, and so if neither
  2633. option is specified on the command-line, <code>ld</code> will enable long
  2634. section names, overriding the default and technically correct behaviour,
  2635. when it finds the presence of debug information while linking an executable
  2636. image and not stripping symbols.
  2637. [This option is valid for all PE targeted ports of the linker]
  2638. </p>
  2639. <a name="index-_002d_002denable_002dstdcall_002dfixup"></a>
  2640. <a name="index-_002d_002ddisable_002dstdcall_002dfixup"></a>
  2641. </dd>
  2642. <dt><code>--enable-stdcall-fixup</code></dt>
  2643. <dt><code>--disable-stdcall-fixup</code></dt>
  2644. <dd><p>If the link finds a symbol that it cannot resolve, it will attempt to
  2645. do &ldquo;fuzzy linking&rdquo; by looking for another defined symbol that differs
  2646. only in the format of the symbol name (cdecl vs stdcall) and will
  2647. resolve that symbol by linking to the match. For example, the
  2648. undefined symbol <code>_foo</code> might be linked to the function
  2649. <code>_foo@12</code>, or the undefined symbol <code>_bar@16</code> might be linked
  2650. to the function <code>_bar</code>. When the linker does this, it prints a
  2651. warning, since it normally should have failed to link, but sometimes
  2652. import libraries generated from third-party dlls may need this feature
  2653. to be usable. If you specify <samp>--enable-stdcall-fixup</samp>, this
  2654. feature is fully enabled and warnings are not printed. If you specify
  2655. <samp>--disable-stdcall-fixup</samp>, this feature is disabled and such
  2656. mismatches are considered to be errors.
  2657. [This option is specific to the i386 PE targeted port of the linker]
  2658. </p>
  2659. <a name="index-_002d_002dleading_002dunderscore"></a>
  2660. <a name="index-_002d_002dno_002dleading_002dunderscore"></a>
  2661. </dd>
  2662. <dt><code>--leading-underscore</code></dt>
  2663. <dt><code>--no-leading-underscore</code></dt>
  2664. <dd><p>For most targets default symbol-prefix is an underscore and is defined
  2665. in target&rsquo;s description. By this option it is possible to
  2666. disable/enable the default underscore symbol-prefix.
  2667. </p>
  2668. <a name="index-DLLs_002c-creating"></a>
  2669. <a name="index-_002d_002dexport_002dall_002dsymbols"></a>
  2670. </dd>
  2671. <dt><code>--export-all-symbols</code></dt>
  2672. <dd><p>If given, all global symbols in the objects used to build a DLL will
  2673. be exported by the DLL. Note that this is the default if there
  2674. otherwise wouldn&rsquo;t be any exported symbols. When symbols are
  2675. explicitly exported via DEF files or implicitly exported via function
  2676. attributes, the default is to not export anything else unless this
  2677. option is given. Note that the symbols <code>DllMain@12</code>,
  2678. <code>DllEntryPoint@0</code>, <code>DllMainCRTStartup@12</code>, and
  2679. <code>impure_ptr</code> will not be automatically
  2680. exported. Also, symbols imported from other DLLs will not be
  2681. re-exported, nor will symbols specifying the DLL&rsquo;s internal layout
  2682. such as those beginning with <code>_head_</code> or ending with
  2683. <code>_iname</code>. In addition, no symbols from <code>libgcc</code>,
  2684. <code>libstd++</code>, <code>libmingw32</code>, or <code>crtX.o</code> will be exported.
  2685. Symbols whose names begin with <code>__rtti_</code> or <code>__builtin_</code> will
  2686. not be exported, to help with C++ DLLs. Finally, there is an
  2687. extensive list of cygwin-private symbols that are not exported
  2688. (obviously, this applies on when building DLLs for cygwin targets).
  2689. These cygwin-excludes are: <code>_cygwin_dll_entry@12</code>,
  2690. <code>_cygwin_crt0_common@8</code>, <code>_cygwin_noncygwin_dll_entry@12</code>,
  2691. <code>_fmode</code>, <code>_impure_ptr</code>, <code>cygwin_attach_dll</code>,
  2692. <code>cygwin_premain0</code>, <code>cygwin_premain1</code>, <code>cygwin_premain2</code>,
  2693. <code>cygwin_premain3</code>, and <code>environ</code>.
  2694. [This option is specific to the i386 PE targeted port of the linker]
  2695. </p>
  2696. <a name="index-_002d_002dexclude_002dsymbols"></a>
  2697. </dd>
  2698. <dt><code>--exclude-symbols <var>symbol</var>,<var>symbol</var>,...</code></dt>
  2699. <dd><p>Specifies a list of symbols which should not be automatically
  2700. exported. The symbol names may be delimited by commas or colons.
  2701. [This option is specific to the i386 PE targeted port of the linker]
  2702. </p>
  2703. <a name="index-_002d_002dexclude_002dall_002dsymbols"></a>
  2704. </dd>
  2705. <dt><code>--exclude-all-symbols</code></dt>
  2706. <dd><p>Specifies no symbols should be automatically exported.
  2707. [This option is specific to the i386 PE targeted port of the linker]
  2708. </p>
  2709. <a name="index-_002d_002dfile_002dalignment"></a>
  2710. </dd>
  2711. <dt><code>--file-alignment</code></dt>
  2712. <dd><p>Specify the file alignment. Sections in the file will always begin at
  2713. file offsets which are multiples of this number. This defaults to
  2714. 512.
  2715. [This option is specific to the i386 PE targeted port of the linker]
  2716. </p>
  2717. <a name="index-heap-size"></a>
  2718. <a name="index-_002d_002dheap"></a>
  2719. </dd>
  2720. <dt><code>--heap <var>reserve</var></code></dt>
  2721. <dt><code>--heap <var>reserve</var>,<var>commit</var></code></dt>
  2722. <dd><p>Specify the number of bytes of memory to reserve (and optionally commit)
  2723. to be used as heap for this program. The default is 1MB reserved, 4K
  2724. committed.
  2725. [This option is specific to the i386 PE targeted port of the linker]
  2726. </p>
  2727. <a name="index-image-base"></a>
  2728. <a name="index-_002d_002dimage_002dbase"></a>
  2729. </dd>
  2730. <dt><code>--image-base <var>value</var></code></dt>
  2731. <dd><p>Use <var>value</var> as the base address of your program or dll. This is
  2732. the lowest memory location that will be used when your program or dll
  2733. is loaded. To reduce the need to relocate and improve performance of
  2734. your dlls, each should have a unique base address and not overlap any
  2735. other dlls. The default is 0x400000 for executables, and 0x10000000
  2736. for dlls.
  2737. [This option is specific to the i386 PE targeted port of the linker]
  2738. </p>
  2739. <a name="index-_002d_002dkill_002dat"></a>
  2740. </dd>
  2741. <dt><code>--kill-at</code></dt>
  2742. <dd><p>If given, the stdcall suffixes (@<var>nn</var>) will be stripped from
  2743. symbols before they are exported.
  2744. [This option is specific to the i386 PE targeted port of the linker]
  2745. </p>
  2746. <a name="index-_002d_002dlarge_002daddress_002daware"></a>
  2747. </dd>
  2748. <dt><code>--large-address-aware</code></dt>
  2749. <dd><p>If given, the appropriate bit in the &ldquo;Characteristics&rdquo; field of the COFF
  2750. header is set to indicate that this executable supports virtual addresses
  2751. greater than 2 gigabytes. This should be used in conjunction with the /3GB
  2752. or /USERVA=<var>value</var> megabytes switch in the &ldquo;[operating systems]&rdquo;
  2753. section of the BOOT.INI. Otherwise, this bit has no effect.
  2754. [This option is specific to PE targeted ports of the linker]
  2755. </p>
  2756. <a name="index-_002d_002ddisable_002dlarge_002daddress_002daware"></a>
  2757. </dd>
  2758. <dt><code>--disable-large-address-aware</code></dt>
  2759. <dd><p>Reverts the effect of a previous &lsquo;<samp>--large-address-aware</samp>&rsquo; option.
  2760. This is useful if &lsquo;<samp>--large-address-aware</samp>&rsquo; is always set by the compiler
  2761. driver (e.g. Cygwin gcc) and the executable does not support virtual
  2762. addresses greater than 2 gigabytes.
  2763. [This option is specific to PE targeted ports of the linker]
  2764. </p>
  2765. <a name="index-_002d_002dmajor_002dimage_002dversion"></a>
  2766. </dd>
  2767. <dt><code>--major-image-version <var>value</var></code></dt>
  2768. <dd><p>Sets the major number of the &ldquo;image version&rdquo;. Defaults to 1.
  2769. [This option is specific to the i386 PE targeted port of the linker]
  2770. </p>
  2771. <a name="index-_002d_002dmajor_002dos_002dversion"></a>
  2772. </dd>
  2773. <dt><code>--major-os-version <var>value</var></code></dt>
  2774. <dd><p>Sets the major number of the &ldquo;os version&rdquo;. Defaults to 4.
  2775. [This option is specific to the i386 PE targeted port of the linker]
  2776. </p>
  2777. <a name="index-_002d_002dmajor_002dsubsystem_002dversion"></a>
  2778. </dd>
  2779. <dt><code>--major-subsystem-version <var>value</var></code></dt>
  2780. <dd><p>Sets the major number of the &ldquo;subsystem version&rdquo;. Defaults to 4.
  2781. [This option is specific to the i386 PE targeted port of the linker]
  2782. </p>
  2783. <a name="index-_002d_002dminor_002dimage_002dversion"></a>
  2784. </dd>
  2785. <dt><code>--minor-image-version <var>value</var></code></dt>
  2786. <dd><p>Sets the minor number of the &ldquo;image version&rdquo;. Defaults to 0.
  2787. [This option is specific to the i386 PE targeted port of the linker]
  2788. </p>
  2789. <a name="index-_002d_002dminor_002dos_002dversion"></a>
  2790. </dd>
  2791. <dt><code>--minor-os-version <var>value</var></code></dt>
  2792. <dd><p>Sets the minor number of the &ldquo;os version&rdquo;. Defaults to 0.
  2793. [This option is specific to the i386 PE targeted port of the linker]
  2794. </p>
  2795. <a name="index-_002d_002dminor_002dsubsystem_002dversion"></a>
  2796. </dd>
  2797. <dt><code>--minor-subsystem-version <var>value</var></code></dt>
  2798. <dd><p>Sets the minor number of the &ldquo;subsystem version&rdquo;. Defaults to 0.
  2799. [This option is specific to the i386 PE targeted port of the linker]
  2800. </p>
  2801. <a name="index-DEF-files_002c-creating"></a>
  2802. <a name="index-DLLs_002c-creating-1"></a>
  2803. <a name="index-_002d_002doutput_002ddef"></a>
  2804. </dd>
  2805. <dt><code>--output-def <var>file</var></code></dt>
  2806. <dd><p>The linker will create the file <var>file</var> which will contain a DEF
  2807. file corresponding to the DLL the linker is generating. This DEF file
  2808. (which should be called <code>*.def</code>) may be used to create an import
  2809. library with <code>dlltool</code> or may be used as a reference to
  2810. automatically or implicitly exported symbols.
  2811. [This option is specific to the i386 PE targeted port of the linker]
  2812. </p>
  2813. <a name="index-DLLs_002c-creating-2"></a>
  2814. <a name="index-_002d_002denable_002dauto_002dimage_002dbase"></a>
  2815. </dd>
  2816. <dt><code>--enable-auto-image-base</code></dt>
  2817. <dt><code>--enable-auto-image-base=<var>value</var></code></dt>
  2818. <dd><p>Automatically choose the image base for DLLs, optionally starting with base
  2819. <var>value</var>, unless one is specified using the <code>--image-base</code> argument.
  2820. By using a hash generated from the dllname to create unique image bases
  2821. for each DLL, in-memory collisions and relocations which can delay program
  2822. execution are avoided.
  2823. [This option is specific to the i386 PE targeted port of the linker]
  2824. </p>
  2825. <a name="index-_002d_002ddisable_002dauto_002dimage_002dbase"></a>
  2826. </dd>
  2827. <dt><code>--disable-auto-image-base</code></dt>
  2828. <dd><p>Do not automatically generate a unique image base. If there is no
  2829. user-specified image base (<code>--image-base</code>) then use the platform
  2830. default.
  2831. [This option is specific to the i386 PE targeted port of the linker]
  2832. </p>
  2833. <a name="index-DLLs_002c-linking-to"></a>
  2834. <a name="index-_002d_002ddll_002dsearch_002dprefix"></a>
  2835. </dd>
  2836. <dt><code>--dll-search-prefix <var>string</var></code></dt>
  2837. <dd><p>When linking dynamically to a dll without an import library,
  2838. search for <code>&lt;string&gt;&lt;basename&gt;.dll</code> in preference to
  2839. <code>lib&lt;basename&gt;.dll</code>. This behaviour allows easy distinction
  2840. between DLLs built for the various &quot;subplatforms&quot;: native, cygwin,
  2841. uwin, pw, etc. For instance, cygwin DLLs typically use
  2842. <code>--dll-search-prefix=cyg</code>.
  2843. [This option is specific to the i386 PE targeted port of the linker]
  2844. </p>
  2845. <a name="index-_002d_002denable_002dauto_002dimport"></a>
  2846. </dd>
  2847. <dt><code>--enable-auto-import</code></dt>
  2848. <dd><p>Do sophisticated linking of <code>_symbol</code> to <code>__imp__symbol</code> for
  2849. DATA imports from DLLs, thus making it possible to bypass the dllimport
  2850. mechanism on the user side and to reference unmangled symbol names.
  2851. [This option is specific to the i386 PE targeted port of the linker]
  2852. </p>
  2853. <p>The following remarks pertain to the original implementation of the
  2854. feature and are obsolete nowadays for Cygwin and MinGW targets.
  2855. </p>
  2856. <p>Note: Use of the &rsquo;auto-import&rsquo; extension will cause the text section
  2857. of the image file to be made writable. This does not conform to the
  2858. PE-COFF format specification published by Microsoft.
  2859. </p>
  2860. <p>Note - use of the &rsquo;auto-import&rsquo; extension will also cause read only
  2861. data which would normally be placed into the .rdata section to be
  2862. placed into the .data section instead. This is in order to work
  2863. around a problem with consts that is described here:
  2864. http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
  2865. </p>
  2866. <p>Using &rsquo;auto-import&rsquo; generally will &rsquo;just work&rsquo; &ndash; but sometimes you may
  2867. see this message:
  2868. </p>
  2869. <p>&quot;variable &rsquo;&lt;var&gt;&rsquo; can&rsquo;t be auto-imported. Please read the
  2870. documentation for ld&rsquo;s <code>--enable-auto-import</code> for details.&quot;
  2871. </p>
  2872. <p>This message occurs when some (sub)expression accesses an address
  2873. ultimately given by the sum of two constants (Win32 import tables only
  2874. allow one). Instances where this may occur include accesses to member
  2875. fields of struct variables imported from a DLL, as well as using a
  2876. constant index into an array variable imported from a DLL. Any
  2877. multiword variable (arrays, structs, long long, etc) may trigger
  2878. this error condition. However, regardless of the exact data type
  2879. of the offending exported variable, ld will always detect it, issue
  2880. the warning, and exit.
  2881. </p>
  2882. <p>There are several ways to address this difficulty, regardless of the
  2883. data type of the exported variable:
  2884. </p>
  2885. <p>One way is to use &ndash;enable-runtime-pseudo-reloc switch. This leaves the task
  2886. of adjusting references in your client code for runtime environment, so
  2887. this method works only when runtime environment supports this feature.
  2888. </p>
  2889. <p>A second solution is to force one of the &rsquo;constants&rsquo; to be a variable &ndash;
  2890. that is, unknown and un-optimizable at compile time. For arrays,
  2891. there are two possibilities: a) make the indexee (the array&rsquo;s address)
  2892. a variable, or b) make the &rsquo;constant&rsquo; index a variable. Thus:
  2893. </p>
  2894. <div class="example">
  2895. <pre class="example">extern type extern_array[];
  2896. extern_array[1] --&gt;
  2897. { volatile type *t=extern_array; t[1] }
  2898. </pre></div>
  2899. <p>or
  2900. </p>
  2901. <div class="example">
  2902. <pre class="example">extern type extern_array[];
  2903. extern_array[1] --&gt;
  2904. { volatile int t=1; extern_array[t] }
  2905. </pre></div>
  2906. <p>For structs (and most other multiword data types) the only option
  2907. is to make the struct itself (or the long long, or the ...) variable:
  2908. </p>
  2909. <div class="example">
  2910. <pre class="example">extern struct s extern_struct;
  2911. extern_struct.field --&gt;
  2912. { volatile struct s *t=&amp;extern_struct; t-&gt;field }
  2913. </pre></div>
  2914. <p>or
  2915. </p>
  2916. <div class="example">
  2917. <pre class="example">extern long long extern_ll;
  2918. extern_ll --&gt;
  2919. { volatile long long * local_ll=&amp;extern_ll; *local_ll }
  2920. </pre></div>
  2921. <p>A third method of dealing with this difficulty is to abandon
  2922. &rsquo;auto-import&rsquo; for the offending symbol and mark it with
  2923. <code>__declspec(dllimport)</code>. However, in practice that
  2924. requires using compile-time #defines to indicate whether you are
  2925. building a DLL, building client code that will link to the DLL, or
  2926. merely building/linking to a static library. In making the choice
  2927. between the various methods of resolving the &rsquo;direct address with
  2928. constant offset&rsquo; problem, you should consider typical real-world usage:
  2929. </p>
  2930. <p>Original:
  2931. </p><div class="example">
  2932. <pre class="example">--foo.h
  2933. extern int arr[];
  2934. --foo.c
  2935. #include &quot;foo.h&quot;
  2936. void main(int argc, char **argv){
  2937. printf(&quot;%d\n&quot;,arr[1]);
  2938. }
  2939. </pre></div>
  2940. <p>Solution 1:
  2941. </p><div class="example">
  2942. <pre class="example">--foo.h
  2943. extern int arr[];
  2944. --foo.c
  2945. #include &quot;foo.h&quot;
  2946. void main(int argc, char **argv){
  2947. /* This workaround is for win32 and cygwin; do not &quot;optimize&quot; */
  2948. volatile int *parr = arr;
  2949. printf(&quot;%d\n&quot;,parr[1]);
  2950. }
  2951. </pre></div>
  2952. <p>Solution 2:
  2953. </p><div class="example">
  2954. <pre class="example">--foo.h
  2955. /* Note: auto-export is assumed (no __declspec(dllexport)) */
  2956. #if (defined(_WIN32) || defined(__CYGWIN__)) &amp;&amp; \
  2957. !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
  2958. #define FOO_IMPORT __declspec(dllimport)
  2959. #else
  2960. #define FOO_IMPORT
  2961. #endif
  2962. extern FOO_IMPORT int arr[];
  2963. --foo.c
  2964. #include &quot;foo.h&quot;
  2965. void main(int argc, char **argv){
  2966. printf(&quot;%d\n&quot;,arr[1]);
  2967. }
  2968. </pre></div>
  2969. <p>A fourth way to avoid this problem is to re-code your
  2970. library to use a functional interface rather than a data interface
  2971. for the offending variables (e.g. set_foo() and get_foo() accessor
  2972. functions).
  2973. </p>
  2974. <a name="index-_002d_002ddisable_002dauto_002dimport"></a>
  2975. </dd>
  2976. <dt><code>--disable-auto-import</code></dt>
  2977. <dd><p>Do not attempt to do sophisticated linking of <code>_symbol</code> to
  2978. <code>__imp__symbol</code> for DATA imports from DLLs.
  2979. [This option is specific to the i386 PE targeted port of the linker]
  2980. </p>
  2981. <a name="index-_002d_002denable_002druntime_002dpseudo_002dreloc"></a>
  2982. </dd>
  2983. <dt><code>--enable-runtime-pseudo-reloc</code></dt>
  2984. <dd><p>If your code contains expressions described in &ndash;enable-auto-import section,
  2985. that is, DATA imports from DLL with non-zero offset, this switch will create
  2986. a vector of &rsquo;runtime pseudo relocations&rsquo; which can be used by runtime
  2987. environment to adjust references to such data in your client code.
  2988. [This option is specific to the i386 PE targeted port of the linker]
  2989. </p>
  2990. <a name="index-_002d_002ddisable_002druntime_002dpseudo_002dreloc"></a>
  2991. </dd>
  2992. <dt><code>--disable-runtime-pseudo-reloc</code></dt>
  2993. <dd><p>Do not create pseudo relocations for non-zero offset DATA imports from DLLs.
  2994. [This option is specific to the i386 PE targeted port of the linker]
  2995. </p>
  2996. <a name="index-_002d_002denable_002dextra_002dpe_002ddebug"></a>
  2997. </dd>
  2998. <dt><code>--enable-extra-pe-debug</code></dt>
  2999. <dd><p>Show additional debug info related to auto-import symbol thunking.
  3000. [This option is specific to the i386 PE targeted port of the linker]
  3001. </p>
  3002. <a name="index-_002d_002dsection_002dalignment"></a>
  3003. </dd>
  3004. <dt><code>--section-alignment</code></dt>
  3005. <dd><p>Sets the section alignment. Sections in memory will always begin at
  3006. addresses which are a multiple of this number. Defaults to 0x1000.
  3007. [This option is specific to the i386 PE targeted port of the linker]
  3008. </p>
  3009. <a name="index-stack-size"></a>
  3010. <a name="index-_002d_002dstack"></a>
  3011. </dd>
  3012. <dt><code>--stack <var>reserve</var></code></dt>
  3013. <dt><code>--stack <var>reserve</var>,<var>commit</var></code></dt>
  3014. <dd><p>Specify the number of bytes of memory to reserve (and optionally commit)
  3015. to be used as stack for this program. The default is 2MB reserved, 4K
  3016. committed.
  3017. [This option is specific to the i386 PE targeted port of the linker]
  3018. </p>
  3019. <a name="index-_002d_002dsubsystem"></a>
  3020. </dd>
  3021. <dt><code>--subsystem <var>which</var></code></dt>
  3022. <dt><code>--subsystem <var>which</var>:<var>major</var></code></dt>
  3023. <dt><code>--subsystem <var>which</var>:<var>major</var>.<var>minor</var></code></dt>
  3024. <dd><p>Specifies the subsystem under which your program will execute. The
  3025. legal values for <var>which</var> are <code>native</code>, <code>windows</code>,
  3026. <code>console</code>, <code>posix</code>, and <code>xbox</code>. You may optionally set
  3027. the subsystem version also. Numeric values are also accepted for
  3028. <var>which</var>.
  3029. [This option is specific to the i386 PE targeted port of the linker]
  3030. </p>
  3031. <p>The following options set flags in the <code>DllCharacteristics</code> field
  3032. of the PE file header:
  3033. [These options are specific to PE targeted ports of the linker]
  3034. </p>
  3035. <a name="index-_002d_002dhigh_002dentropy_002dva"></a>
  3036. </dd>
  3037. <dt><code>--high-entropy-va</code></dt>
  3038. <dd><p>Image is compatible with 64-bit address space layout randomization
  3039. (ASLR).
  3040. This option also implies <samp>--dynamicbase</samp> and
  3041. <samp>--enable-reloc-section</samp>.
  3042. </p>
  3043. <a name="index-_002d_002ddynamicbase"></a>
  3044. </dd>
  3045. <dt><code>--dynamicbase</code></dt>
  3046. <dd><p>The image base address may be relocated using address space layout
  3047. randomization (ASLR). This feature was introduced with MS Windows
  3048. Vista for i386 PE targets.
  3049. This option also implies <samp>--enable-reloc-section</samp>.
  3050. </p>
  3051. <a name="index-_002d_002dforceinteg"></a>
  3052. </dd>
  3053. <dt><code>--forceinteg</code></dt>
  3054. <dd><p>Code integrity checks are enforced.
  3055. </p>
  3056. <a name="index-_002d_002dnxcompat"></a>
  3057. </dd>
  3058. <dt><code>--nxcompat</code></dt>
  3059. <dd><p>The image is compatible with the Data Execution Prevention.
  3060. This feature was introduced with MS Windows XP SP2 for i386 PE targets.
  3061. </p>
  3062. <a name="index-_002d_002dno_002disolation"></a>
  3063. </dd>
  3064. <dt><code>--no-isolation</code></dt>
  3065. <dd><p>Although the image understands isolation, do not isolate the image.
  3066. </p>
  3067. <a name="index-_002d_002dno_002dseh"></a>
  3068. </dd>
  3069. <dt><code>--no-seh</code></dt>
  3070. <dd><p>The image does not use SEH. No SE handler may be called from
  3071. this image.
  3072. </p>
  3073. <a name="index-_002d_002dno_002dbind"></a>
  3074. </dd>
  3075. <dt><code>--no-bind</code></dt>
  3076. <dd><p>Do not bind this image.
  3077. </p>
  3078. <a name="index-_002d_002dwdmdriver"></a>
  3079. </dd>
  3080. <dt><code>--wdmdriver</code></dt>
  3081. <dd><p>The driver uses the MS Windows Driver Model.
  3082. </p>
  3083. <a name="index-_002d_002dtsaware"></a>
  3084. </dd>
  3085. <dt><code>--tsaware</code></dt>
  3086. <dd><p>The image is Terminal Server aware.
  3087. </p>
  3088. <a name="index-_002d_002dinsert_002dtimestamp"></a>
  3089. </dd>
  3090. <dt><code>--insert-timestamp</code></dt>
  3091. <dt><code>--no-insert-timestamp</code></dt>
  3092. <dd><p>Insert a real timestamp into the image. This is the default behaviour
  3093. as it matches legacy code and it means that the image will work with
  3094. other, proprietary tools. The problem with this default is that it
  3095. will result in slightly different images being produced each time the
  3096. same sources are linked. The option <samp>--no-insert-timestamp</samp>
  3097. can be used to insert a zero value for the timestamp, this ensuring
  3098. that binaries produced from identical sources will compare
  3099. identically.
  3100. </p>
  3101. <a name="index-_002d_002denable_002dreloc_002dsection"></a>
  3102. </dd>
  3103. <dt><code>--enable-reloc-section</code></dt>
  3104. <dd><p>Create the base relocation table, which is necessary if the image
  3105. is loaded at a different image base than specified in the PE header.
  3106. </p></dd>
  3107. </dl>
  3108. <a name="Options-specific-to-C6X-uClinux-targets"></a>
  3109. <h4 class="subsection">2.1.2 Options specific to C6X uClinux targets</h4>
  3110. <p>The C6X uClinux target uses a binary format called DSBT to support shared
  3111. libraries. Each shared library in the system needs to have a unique index;
  3112. all executables use an index of 0.
  3113. </p>
  3114. <dl compact="compact">
  3115. <dd>
  3116. <a name="index-_002d_002ddsbt_002dsize"></a>
  3117. </dd>
  3118. <dt><code>--dsbt-size <var>size</var></code></dt>
  3119. <dd><p>This option sets the number of entries in the DSBT of the current executable
  3120. or shared library to <var>size</var>. The default is to create a table with 64
  3121. entries.
  3122. </p>
  3123. <a name="index-_002d_002ddsbt_002dindex"></a>
  3124. </dd>
  3125. <dt><code>--dsbt-index <var>index</var></code></dt>
  3126. <dd><p>This option sets the DSBT index of the current executable or shared library
  3127. to <var>index</var>. The default is 0, which is appropriate for generating
  3128. executables. If a shared library is generated with a DSBT index of 0, the
  3129. <code>R_C6000_DSBT_INDEX</code> relocs are copied into the output file.
  3130. </p>
  3131. <a name="index-_002d_002dno_002dmerge_002dexidx_002dentries"></a>
  3132. <p>The &lsquo;<samp>--no-merge-exidx-entries</samp>&rsquo; switch disables the merging of adjacent
  3133. exidx entries in frame unwind info.
  3134. </p>
  3135. </dd>
  3136. </dl>
  3137. <a name="Options-specific-to-C_002dSKY-targets"></a>
  3138. <h4 class="subsection">2.1.3 Options specific to C-SKY targets</h4>
  3139. <dl compact="compact">
  3140. <dd>
  3141. <a name="index-_002d_002dbranch_002dstub-on-C_002dSKY"></a>
  3142. </dd>
  3143. <dt><code>--branch-stub</code></dt>
  3144. <dd><p>This option enables linker branch relaxation by inserting branch stub
  3145. sections when needed to extend the range of branches. This option is
  3146. usually not required since C-SKY supports branch and call instructions that
  3147. can access the full memory range and branch relaxation is normally handled by
  3148. the compiler or assembler.
  3149. </p>
  3150. <a name="index-_002d_002dstub_002dgroup_002dsize-on-C_002dSKY"></a>
  3151. </dd>
  3152. <dt><code>--stub-group-size=<var>N</var></code></dt>
  3153. <dd><p>This option allows finer control of linker branch stub creation.
  3154. It sets the maximum size of a group of input sections that can
  3155. be handled by one stub section. A negative value of <var>N</var> locates
  3156. stub sections after their branches, while a positive value allows stub
  3157. sections to appear either before or after the branches. Values of
  3158. &lsquo;<samp>1</samp>&rsquo; or &lsquo;<samp>-1</samp>&rsquo; indicate that the
  3159. linker should choose suitable defaults.
  3160. </p>
  3161. </dd>
  3162. </dl>
  3163. <a name="Options-specific-to-Motorola-68HC11-and-68HC12-targets"></a>
  3164. <h4 class="subsection">2.1.4 Options specific to Motorola 68HC11 and 68HC12 targets</h4>
  3165. <p>The 68HC11 and 68HC12 linkers support specific options to control the
  3166. memory bank switching mapping and trampoline code generation.
  3167. </p>
  3168. <dl compact="compact">
  3169. <dd>
  3170. <a name="index-_002d_002dno_002dtrampoline"></a>
  3171. </dd>
  3172. <dt><code>--no-trampoline</code></dt>
  3173. <dd><p>This option disables the generation of trampoline. By default a trampoline
  3174. is generated for each far function which is called using a <code>jsr</code>
  3175. instruction (this happens when a pointer to a far function is taken).
  3176. </p>
  3177. <a name="index-_002d_002dbank_002dwindow"></a>
  3178. </dd>
  3179. <dt><code>--bank-window <var>name</var></code></dt>
  3180. <dd><p>This option indicates to the linker the name of the memory region in
  3181. the &lsquo;<samp>MEMORY</samp>&rsquo; specification that describes the memory bank window.
  3182. The definition of such region is then used by the linker to compute
  3183. paging and addresses within the memory window.
  3184. </p>
  3185. </dd>
  3186. </dl>
  3187. <a name="Options-specific-to-Motorola-68K-target"></a>
  3188. <h4 class="subsection">2.1.5 Options specific to Motorola 68K target</h4>
  3189. <p>The following options are supported to control handling of GOT generation
  3190. when linking for 68K targets.
  3191. </p>
  3192. <dl compact="compact">
  3193. <dd>
  3194. <a name="index-_002d_002dgot"></a>
  3195. </dd>
  3196. <dt><code>--got=<var>type</var></code></dt>
  3197. <dd><p>This option tells the linker which GOT generation scheme to use.
  3198. <var>type</var> should be one of &lsquo;<samp>single</samp>&rsquo;, &lsquo;<samp>negative</samp>&rsquo;,
  3199. &lsquo;<samp>multigot</samp>&rsquo; or &lsquo;<samp>target</samp>&rsquo;. For more information refer to the
  3200. Info entry for <samp>ld</samp>.
  3201. </p>
  3202. </dd>
  3203. </dl>
  3204. <a name="Options-specific-to-MIPS-targets"></a>
  3205. <h4 class="subsection">2.1.6 Options specific to MIPS targets</h4>
  3206. <p>The following options are supported to control microMIPS instruction
  3207. generation and branch relocation checks for ISA mode transitions when
  3208. linking for MIPS targets.
  3209. </p>
  3210. <dl compact="compact">
  3211. <dd>
  3212. <a name="index-_002d_002dinsn32"></a>
  3213. </dd>
  3214. <dt><code>--insn32</code></dt>
  3215. <dd><a name="index-_002d_002dno_002dinsn32"></a>
  3216. </dd>
  3217. <dt><code>--no-insn32</code></dt>
  3218. <dd><p>These options control the choice of microMIPS instructions used in code
  3219. generated by the linker, such as that in the PLT or lazy binding stubs,
  3220. or in relaxation. If &lsquo;<samp>--insn32</samp>&rsquo; is used, then the linker only uses
  3221. 32-bit instruction encodings. By default or if &lsquo;<samp>--no-insn32</samp>&rsquo; is
  3222. used, all instruction encodings are used, including 16-bit ones where
  3223. possible.
  3224. </p>
  3225. <a name="index-_002d_002dignore_002dbranch_002disa"></a>
  3226. </dd>
  3227. <dt><code>--ignore-branch-isa</code></dt>
  3228. <dd><a name="index-_002d_002dno_002dignore_002dbranch_002disa"></a>
  3229. </dd>
  3230. <dt><code>--no-ignore-branch-isa</code></dt>
  3231. <dd><p>These options control branch relocation checks for invalid ISA mode
  3232. transitions. If &lsquo;<samp>--ignore-branch-isa</samp>&rsquo; is used, then the linker
  3233. accepts any branch relocations and any ISA mode transition required
  3234. is lost in relocation calculation, except for some cases of <code>BAL</code>
  3235. instructions which meet relaxation conditions and are converted to
  3236. equivalent <code>JALX</code> instructions as the associated relocation is
  3237. calculated. By default or if &lsquo;<samp>--no-ignore-branch-isa</samp>&rsquo; is used
  3238. a check is made causing the loss of an ISA mode transition to produce
  3239. an error.
  3240. </p>
  3241. <a name="index-_002d_002dcompact_002dbranches"></a>
  3242. </dd>
  3243. <dt><code>--compact-branches</code></dt>
  3244. <dd><a name="index-_002d_002dno_002dcompact_002dbranches"></a>
  3245. </dd>
  3246. <dt><code>--no-compact-branches</code></dt>
  3247. <dd><p>These options control the generation of compact instructions by the linker
  3248. in the PLT entries for MIPS R6.
  3249. </p>
  3250. </dd>
  3251. </dl>
  3252. <a name="Options-specific-to-PDP11-targets"></a>
  3253. <h4 class="subsection">2.1.7 Options specific to PDP11 targets</h4>
  3254. <p>For the pdp11-aout target, three variants of the output format can be
  3255. produced as selected by the following options. The default variant
  3256. for pdp11-aout is the &lsquo;<samp>--omagic</samp>&rsquo; option, whereas for other
  3257. targets &lsquo;<samp>--nmagic</samp>&rsquo; is the default. The &lsquo;<samp>--imagic</samp>&rsquo; option is
  3258. defined only for the pdp11-aout target, while the others are described
  3259. here as they apply to the pdp11-aout target.
  3260. </p>
  3261. <dl compact="compact">
  3262. <dd>
  3263. <a name="index-_002dN-1"></a>
  3264. </dd>
  3265. <dt><code>-N</code></dt>
  3266. <dd><a name="index-_002d_002domagic-1"></a>
  3267. </dd>
  3268. <dt><code>--omagic</code></dt>
  3269. <dd>
  3270. <p>Mark the output as <code>OMAGIC</code> (0407) in the <samp>a.out</samp> header to
  3271. indicate that the text segment is not to be write-protected and
  3272. shared. Since the text and data sections are both readable and
  3273. writable, the data section is allocated immediately contiguous after
  3274. the text segment. This is the oldest format for PDP11 executable
  3275. programs and is the default for <code>ld</code> on PDP11 Unix systems
  3276. from the beginning through 2.11BSD.
  3277. </p>
  3278. <a name="index-_002dn-1"></a>
  3279. </dd>
  3280. <dt><code>-n</code></dt>
  3281. <dd><a name="index-_002d_002dnmagic-1"></a>
  3282. </dd>
  3283. <dt><code>--nmagic</code></dt>
  3284. <dd>
  3285. <p>Mark the output as <code>NMAGIC</code> (0410) in the <samp>a.out</samp> header to
  3286. indicate that when the output file is executed, the text portion will
  3287. be read-only and shareable among all processes executing the same
  3288. file. This involves moving the data areas up to the first possible 8K
  3289. byte page boundary following the end of the text. This option creates
  3290. a <em>pure executable</em> format.
  3291. </p>
  3292. <a name="index-_002dz"></a>
  3293. </dd>
  3294. <dt><code>-z</code></dt>
  3295. <dd><a name="index-_002d_002dimagic"></a>
  3296. </dd>
  3297. <dt><code>--imagic</code></dt>
  3298. <dd>
  3299. <p>Mark the output as <code>IMAGIC</code> (0411) in the <samp>a.out</samp> header to
  3300. indicate that when the output file is executed, the program text and
  3301. data areas will be loaded into separate address spaces using the split
  3302. instruction and data space feature of the memory management unit in
  3303. larger models of the PDP11. This doubles the address space available
  3304. to the program. The text segment is again pure, write-protected, and
  3305. shareable. The only difference in the output format between this
  3306. option and the others, besides the magic number, is that both the text
  3307. and data sections start at location 0. The &lsquo;<samp>-z</samp>&rsquo; option selected
  3308. this format in 2.11BSD. This option creates a <em>separate
  3309. executable</em> format.
  3310. </p>
  3311. <a name="index-_002d_002dno_002domagic-1"></a>
  3312. </dd>
  3313. <dt><code>--no-omagic</code></dt>
  3314. <dd>
  3315. <p>Equivalent to &lsquo;<samp>--nmagic</samp>&rsquo; for pdp11-aout.
  3316. </p>
  3317. </dd>
  3318. </dl>
  3319. <hr>
  3320. <div class="header">
  3321. <p>
  3322. Next: <a href="Environment.html#Environment" accesskey="n" rel="next">Environment</a>, Up: <a href="Invocation.html#Invocation" accesskey="u" rel="up">Invocation</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
  3323. </div>
  3324. </body>
  3325. </html>