Options.html 165 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592
  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 Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))
  5. version 2.36.1.
  6. Copyright (C) 1991-2021 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 one 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>unique</samp>&rsquo;</dt>
  1159. <dt>&lsquo;<samp>nounique</samp>&rsquo;</dt>
  1160. <dd><p>When generating a shared library or other dynamically loadable ELF
  1161. object mark it as one that should (by default) only ever be loaded once,
  1162. and only in the main namespace (when using <code>dlmopen</code>). This is
  1163. primarily used to mark fundamental libraries such as libc, libpthread et
  1164. al which do not usually function correctly unless they are the sole instances
  1165. of themselves. This behaviour can be overridden by the <code>dlmopen</code> caller
  1166. and does not apply to certain loading mechanisms (such as audit libraries).
  1167. </p>
  1168. </dd>
  1169. <dt>&lsquo;<samp>lam-u48</samp>&rsquo;</dt>
  1170. <dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_LAM_U48 in .note.gnu.property section
  1171. to indicate compatibility with Intel LAM_U48. Supported for Linux/x86_64.
  1172. </p>
  1173. </dd>
  1174. <dt>&lsquo;<samp>lam-u57</samp>&rsquo;</dt>
  1175. <dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_LAM_U57 in .note.gnu.property section
  1176. to indicate compatibility with Intel LAM_U57. Supported for Linux/x86_64.
  1177. </p>
  1178. </dd>
  1179. <dt>&lsquo;<samp>lam-u48-report=none</samp>&rsquo;</dt>
  1180. <dt>&lsquo;<samp>lam-u48-report=warning</samp>&rsquo;</dt>
  1181. <dt>&lsquo;<samp>lam-u48-report=error</samp>&rsquo;</dt>
  1182. <dd><p>Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U48
  1183. property in input .note.gnu.property section.
  1184. <samp>lam-u48-report=none</samp>, which is the default, will make the
  1185. linker not report missing properties in input files.
  1186. <samp>lam-u48-report=warning</samp> will make the linker issue a warning for
  1187. missing properties in input files. <samp>lam-u48-report=error</samp> will
  1188. make the linker issue an error for missing properties in input files.
  1189. Supported for Linux/x86_64.
  1190. </p>
  1191. </dd>
  1192. <dt>&lsquo;<samp>lam-u57-report=none</samp>&rsquo;</dt>
  1193. <dt>&lsquo;<samp>lam-u57-report=warning</samp>&rsquo;</dt>
  1194. <dt>&lsquo;<samp>lam-u57-report=error</samp>&rsquo;</dt>
  1195. <dd><p>Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U57
  1196. property in input .note.gnu.property section.
  1197. <samp>lam-u57-report=none</samp>, which is the default, will make the
  1198. linker not report missing properties in input files.
  1199. <samp>lam-u57-report=warning</samp> will make the linker issue a warning for
  1200. missing properties in input files. <samp>lam-u57-report=error</samp> will
  1201. make the linker issue an error for missing properties in input files.
  1202. Supported for Linux/x86_64.
  1203. </p>
  1204. </dd>
  1205. <dt>&lsquo;<samp>lam-report=none</samp>&rsquo;</dt>
  1206. <dt>&lsquo;<samp>lam-report=warning</samp>&rsquo;</dt>
  1207. <dt>&lsquo;<samp>lam-report=error</samp>&rsquo;</dt>
  1208. <dd><p>Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U48 and
  1209. GNU_PROPERTY_X86_FEATURE_1_LAM_U57 properties in input .note.gnu.property
  1210. section. <samp>lam-report=none</samp>, which is the default, will make the
  1211. linker not report missing properties in input files.
  1212. <samp>lam-report=warning</samp> will make the linker issue a warning for
  1213. missing properties in input files. <samp>lam-report=error</samp> will make
  1214. the linker issue an error for missing properties in input files.
  1215. Supported for Linux/x86_64.
  1216. </p>
  1217. </dd>
  1218. <dt>&lsquo;<samp>lazy</samp>&rsquo;</dt>
  1219. <dd><p>When generating an executable or shared library, mark it to tell the
  1220. dynamic linker to defer function call resolution to the point when
  1221. the function is called (lazy binding), rather than at load time.
  1222. Lazy binding is the default.
  1223. </p>
  1224. </dd>
  1225. <dt>&lsquo;<samp>loadfltr</samp>&rsquo;</dt>
  1226. <dd><p>Specify that the object&rsquo;s filters be processed immediately at runtime.
  1227. </p>
  1228. </dd>
  1229. <dt>&lsquo;<samp>max-page-size=<var>value</var></samp>&rsquo;</dt>
  1230. <dd><p>Set the maximum memory page size supported to <var>value</var>.
  1231. </p>
  1232. </dd>
  1233. <dt>&lsquo;<samp>muldefs</samp>&rsquo;</dt>
  1234. <dd><p>Allow multiple definitions.
  1235. </p>
  1236. </dd>
  1237. <dt>&lsquo;<samp>nocopyreloc</samp>&rsquo;</dt>
  1238. <dd><p>Disable linker generated .dynbss variables used in place of variables
  1239. defined in shared libraries. May result in dynamic text relocations.
  1240. </p>
  1241. </dd>
  1242. <dt>&lsquo;<samp>nodefaultlib</samp>&rsquo;</dt>
  1243. <dd><p>Specify that the dynamic loader search for dependencies of this object
  1244. should ignore any default library search paths.
  1245. </p>
  1246. </dd>
  1247. <dt>&lsquo;<samp>nodelete</samp>&rsquo;</dt>
  1248. <dd><p>Specify that the object shouldn&rsquo;t be unloaded at runtime.
  1249. </p>
  1250. </dd>
  1251. <dt>&lsquo;<samp>nodlopen</samp>&rsquo;</dt>
  1252. <dd><p>Specify that the object is not available to <code>dlopen</code>.
  1253. </p>
  1254. </dd>
  1255. <dt>&lsquo;<samp>nodump</samp>&rsquo;</dt>
  1256. <dd><p>Specify that the object can not be dumped by <code>dldump</code>.
  1257. </p>
  1258. </dd>
  1259. <dt>&lsquo;<samp>noexecstack</samp>&rsquo;</dt>
  1260. <dd><p>Marks the object as not requiring executable stack.
  1261. </p>
  1262. </dd>
  1263. <dt>&lsquo;<samp>noextern-protected-data</samp>&rsquo;</dt>
  1264. <dd><p>Don&rsquo;t treat protected data symbols as external when building a shared
  1265. library. This option overrides the linker backend default. It can be
  1266. used to work around incorrect relocations against protected data symbols
  1267. generated by compiler. Updates on protected data symbols by another
  1268. module aren&rsquo;t visible to the resulting shared library. Supported for
  1269. i386 and x86-64.
  1270. </p>
  1271. </dd>
  1272. <dt>&lsquo;<samp>noreloc-overflow</samp>&rsquo;</dt>
  1273. <dd><p>Disable relocation overflow check. This can be used to disable
  1274. relocation overflow check if there will be no dynamic relocation
  1275. overflow at run-time. Supported for x86_64.
  1276. </p>
  1277. </dd>
  1278. <dt>&lsquo;<samp>now</samp>&rsquo;</dt>
  1279. <dd><p>When generating an executable or shared library, mark it to tell the
  1280. dynamic linker to resolve all symbols when the program is started, or
  1281. when the shared library is loaded by dlopen, instead of deferring
  1282. function call resolution to the point when the function is first
  1283. called.
  1284. </p>
  1285. </dd>
  1286. <dt>&lsquo;<samp>origin</samp>&rsquo;</dt>
  1287. <dd><p>Specify that the object requires &lsquo;<samp>$ORIGIN</samp>&rsquo; handling in paths.
  1288. </p>
  1289. </dd>
  1290. <dt>&lsquo;<samp>relro</samp>&rsquo;</dt>
  1291. <dt>&lsquo;<samp>norelro</samp>&rsquo;</dt>
  1292. <dd><p>Create an ELF <code>PT_GNU_RELRO</code> segment header in the object. This
  1293. specifies a memory segment that should be made read-only after
  1294. relocation, if supported. Specifying &lsquo;<samp>common-page-size</samp>&rsquo; smaller
  1295. than the system page size will render this protection ineffective.
  1296. Don&rsquo;t create an ELF <code>PT_GNU_RELRO</code> segment if &lsquo;<samp>norelro</samp>&rsquo;.
  1297. </p>
  1298. </dd>
  1299. <dt>&lsquo;<samp>separate-code</samp>&rsquo;</dt>
  1300. <dt>&lsquo;<samp>noseparate-code</samp>&rsquo;</dt>
  1301. <dd><p>Create separate code <code>PT_LOAD</code> segment header in the object. This
  1302. specifies a memory segment that should contain only instructions and must
  1303. be in wholly disjoint pages from any other data. Don&rsquo;t create separate
  1304. code <code>PT_LOAD</code> segment if &lsquo;<samp>noseparate-code</samp>&rsquo; is used.
  1305. </p>
  1306. </dd>
  1307. <dt>&lsquo;<samp>unique-symbol</samp>&rsquo;</dt>
  1308. <dt>&lsquo;<samp>nounique-symbol</samp>&rsquo;</dt>
  1309. <dd><p>Avoid duplicated local symbol names in the symbol string table. Append
  1310. &quot;.<code>number</code>&quot; to duplicated local symbol names if &lsquo;<samp>unique-symbol</samp>&rsquo;
  1311. is used. <samp>nounique-symbol</samp> is the default.
  1312. </p>
  1313. </dd>
  1314. <dt>&lsquo;<samp>shstk</samp>&rsquo;</dt>
  1315. <dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK in .note.gnu.property section
  1316. to indicate compatibility with Intel Shadow Stack. Supported for
  1317. Linux/i386 and Linux/x86_64.
  1318. </p>
  1319. </dd>
  1320. <dt>&lsquo;<samp>stack-size=<var>value</var></samp>&rsquo;</dt>
  1321. <dd><p>Specify a stack size for an ELF <code>PT_GNU_STACK</code> segment.
  1322. Specifying zero will override any default non-zero sized
  1323. <code>PT_GNU_STACK</code> segment creation.
  1324. </p>
  1325. </dd>
  1326. <dt>&lsquo;<samp>start-stop-visibility=<var>value</var></samp>&rsquo;</dt>
  1327. <dd><a name="index-visibility"></a>
  1328. <a name="index-ELF-symbol-visibility"></a>
  1329. <p>Specify the ELF symbol visibility for synthesized
  1330. <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;,
  1331. &lsquo;<samp>internal</samp>&rsquo;, &lsquo;<samp>hidden</samp>&rsquo;, or &lsquo;<samp>protected</samp>&rsquo;. If no &lsquo;<samp>-z
  1332. start-stop-visibility</samp>&rsquo; option is given, &lsquo;<samp>protected</samp>&rsquo; is used for
  1333. compatibility with historical practice. However, it&rsquo;s highly
  1334. recommended to use &lsquo;<samp>-z start-stop-visibility=hidden</samp>&rsquo; in new
  1335. programs and shared libraries so that these symbols are not exported
  1336. between shared objects, which is not usually what&rsquo;s intended.
  1337. </p>
  1338. </dd>
  1339. <dt>&lsquo;<samp>text</samp>&rsquo;</dt>
  1340. <dt>&lsquo;<samp>notext</samp>&rsquo;</dt>
  1341. <dt>&lsquo;<samp>textoff</samp>&rsquo;</dt>
  1342. <dd><p>Report an error if DT_TEXTREL is set, i.e., if the position-independent
  1343. or shared object has dynamic relocations in read-only sections. Don&rsquo;t
  1344. report an error if &lsquo;<samp>notext</samp>&rsquo; or &lsquo;<samp>textoff</samp>&rsquo;.
  1345. </p>
  1346. </dd>
  1347. <dt>&lsquo;<samp>undefs</samp>&rsquo;</dt>
  1348. <dd><p>Do not report unresolved symbol references from regular object files,
  1349. either when creating an executable, or when creating a shared library.
  1350. This option is the inverse of &lsquo;<samp>-z defs</samp>&rsquo;.
  1351. </p>
  1352. </dd>
  1353. <dt>&lsquo;<samp>x86-64-baseline</samp>&rsquo;</dt>
  1354. <dt>&lsquo;<samp>x86-64-v2</samp>&rsquo;</dt>
  1355. <dt>&lsquo;<samp>x86-64-v3</samp>&rsquo;</dt>
  1356. <dt>&lsquo;<samp>x86-64-v4</samp>&rsquo;</dt>
  1357. <dd><p>Specify the x86-64 ISA level needed in .note.gnu.property section.
  1358. <samp>x86-64-baseline</samp> generates <code>GNU_PROPERTY_X86_ISA_1_BASELINE</code>.
  1359. <samp>x86-64-v2</samp> generates <code>GNU_PROPERTY_X86_ISA_1_V2</code>.
  1360. <samp>x86-64-v3</samp> generates <code>GNU_PROPERTY_X86_ISA_1_V3</code>.
  1361. <samp>x86-64-v4</samp> generates <code>GNU_PROPERTY_X86_ISA_1_V4</code>.
  1362. Supported for Linux/i386 and Linux/x86_64.
  1363. </p>
  1364. </dd>
  1365. </dl>
  1366. <p>Other keywords are ignored for Solaris compatibility.
  1367. </p>
  1368. <a name="index-_002d_0028"></a>
  1369. <a name="index-groups-of-archives"></a>
  1370. </dd>
  1371. <dt><code>-( <var>archives</var> -)</code></dt>
  1372. <dt><code>--start-group <var>archives</var> --end-group</code></dt>
  1373. <dd><p>The <var>archives</var> should be a list of archive files. They may be
  1374. either explicit file names, or &lsquo;<samp>-l</samp>&rsquo; options.
  1375. </p>
  1376. <p>The specified archives are searched repeatedly until no new undefined
  1377. references are created. Normally, an archive is searched only once in
  1378. the order that it is specified on the command line. If a symbol in that
  1379. archive is needed to resolve an undefined symbol referred to by an
  1380. object in an archive that appears later on the command line, the linker
  1381. would not be able to resolve that reference. By grouping the archives,
  1382. they will all be searched repeatedly until all possible references are
  1383. resolved.
  1384. </p>
  1385. <p>Using this option has a significant performance cost. It is best to use
  1386. it only when there are unavoidable circular references between two or
  1387. more archives.
  1388. </p>
  1389. <a name="index-_002d_002daccept_002dunknown_002dinput_002darch"></a>
  1390. <a name="index-_002d_002dno_002daccept_002dunknown_002dinput_002darch"></a>
  1391. </dd>
  1392. <dt><code>--accept-unknown-input-arch</code></dt>
  1393. <dt><code>--no-accept-unknown-input-arch</code></dt>
  1394. <dd><p>Tells the linker to accept input files whose architecture cannot be
  1395. recognised. The assumption is that the user knows what they are doing
  1396. and deliberately wants to link in these unknown input files. This was
  1397. the default behaviour of the linker, before release 2.14. The default
  1398. behaviour from release 2.14 onwards is to reject such input files, and
  1399. so the &lsquo;<samp>--accept-unknown-input-arch</samp>&rsquo; option has been added to
  1400. restore the old behaviour.
  1401. </p>
  1402. <a name="index-_002d_002das_002dneeded"></a>
  1403. <a name="index-_002d_002dno_002das_002dneeded"></a>
  1404. </dd>
  1405. <dt><code>--as-needed</code></dt>
  1406. <dt><code>--no-as-needed</code></dt>
  1407. <dd><p>This option affects ELF DT_NEEDED tags for dynamic libraries mentioned
  1408. on the command line after the <samp>--as-needed</samp> option. Normally
  1409. the linker will add a DT_NEEDED tag for each dynamic library mentioned
  1410. on the command line, regardless of whether the library is actually
  1411. needed or not. <samp>--as-needed</samp> causes a DT_NEEDED tag to only be
  1412. emitted for a library that <em>at that point in the link</em> satisfies a
  1413. non-weak undefined symbol reference from a regular object file or, if
  1414. the library is not found in the DT_NEEDED lists of other needed libraries, a
  1415. non-weak undefined symbol reference from another needed dynamic library.
  1416. Object files or libraries appearing on the command line <em>after</em>
  1417. the library in question do not affect whether the library is seen as
  1418. needed. This is similar to the rules for extraction of object files
  1419. from archives. <samp>--no-as-needed</samp> restores the default behaviour.
  1420. </p>
  1421. <a name="index-_002d_002dadd_002dneeded"></a>
  1422. <a name="index-_002d_002dno_002dadd_002dneeded"></a>
  1423. </dd>
  1424. <dt><code>--add-needed</code></dt>
  1425. <dt><code>--no-add-needed</code></dt>
  1426. <dd><p>These two options have been deprecated because of the similarity of
  1427. their names to the <samp>--as-needed</samp> and <samp>--no-as-needed</samp>
  1428. options. They have been replaced by <samp>--copy-dt-needed-entries</samp>
  1429. and <samp>--no-copy-dt-needed-entries</samp>.
  1430. </p>
  1431. <a name="index-_002dassert-keyword"></a>
  1432. </dd>
  1433. <dt><code>-assert <var>keyword</var></code></dt>
  1434. <dd><p>This option is ignored for SunOS compatibility.
  1435. </p>
  1436. <a name="index-_002dBdynamic"></a>
  1437. <a name="index-_002ddy"></a>
  1438. <a name="index-_002dcall_005fshared"></a>
  1439. </dd>
  1440. <dt><code>-Bdynamic</code></dt>
  1441. <dt><code>-dy</code></dt>
  1442. <dt><code>-call_shared</code></dt>
  1443. <dd><p>Link against dynamic libraries. This is only meaningful on platforms
  1444. for which shared libraries are supported. This option is normally the
  1445. default on such platforms. The different variants of this option are
  1446. for compatibility with various systems. You may use this option
  1447. multiple times on the command line: it affects library searching for
  1448. <samp>-l</samp> options which follow it.
  1449. </p>
  1450. <a name="index-_002dBgroup"></a>
  1451. </dd>
  1452. <dt><code>-Bgroup</code></dt>
  1453. <dd><p>Set the <code>DF_1_GROUP</code> flag in the <code>DT_FLAGS_1</code> entry in the dynamic
  1454. section. This causes the runtime linker to handle lookups in this
  1455. object and its dependencies to be performed only inside the group.
  1456. <samp>--unresolved-symbols=report-all</samp> is implied. This option is
  1457. only meaningful on ELF platforms which support shared libraries.
  1458. </p>
  1459. <a name="index-_002dBstatic"></a>
  1460. <a name="index-_002ddn"></a>
  1461. <a name="index-_002dnon_005fshared"></a>
  1462. <a name="index-_002dstatic"></a>
  1463. </dd>
  1464. <dt><code>-Bstatic</code></dt>
  1465. <dt><code>-dn</code></dt>
  1466. <dt><code>-non_shared</code></dt>
  1467. <dt><code>-static</code></dt>
  1468. <dd><p>Do not link against shared libraries. This is only meaningful on
  1469. platforms for which shared libraries are supported. The different
  1470. variants of this option are for compatibility with various systems. You
  1471. may use this option multiple times on the command line: it affects
  1472. library searching for <samp>-l</samp> options which follow it. This
  1473. option also implies <samp>--unresolved-symbols=report-all</samp>. This
  1474. option can be used with <samp>-shared</samp>. Doing so means that a
  1475. shared library is being created but that all of the library&rsquo;s external
  1476. references must be resolved by pulling in entries from static
  1477. libraries.
  1478. </p>
  1479. <a name="index-_002dBsymbolic"></a>
  1480. </dd>
  1481. <dt><code>-Bsymbolic</code></dt>
  1482. <dd><p>When creating a shared library, bind references to global symbols to the
  1483. definition within the shared library, if any. Normally, it is possible
  1484. for a program linked against a shared library to override the definition
  1485. within the shared library. This option is only meaningful on ELF
  1486. platforms which support shared libraries.
  1487. </p>
  1488. <a name="index-_002dBsymbolic_002dfunctions"></a>
  1489. </dd>
  1490. <dt><code>-Bsymbolic-functions</code></dt>
  1491. <dd><p>When creating a shared library, bind references to global function
  1492. symbols to the definition within the shared library, if any.
  1493. This option is only meaningful on ELF platforms which support shared
  1494. libraries.
  1495. </p>
  1496. <a name="index-_002d_002ddynamic_002dlist_003ddynamic_002dlist_002dfile"></a>
  1497. </dd>
  1498. <dt><code>--dynamic-list=<var>dynamic-list-file</var></code></dt>
  1499. <dd><p>Specify the name of a dynamic list file to the linker. This is
  1500. typically used when creating shared libraries to specify a list of
  1501. global symbols whose references shouldn&rsquo;t be bound to the definition
  1502. within the shared library, or creating dynamically linked executables
  1503. to specify a list of symbols which should be added to the symbol table
  1504. in the executable. This option is only meaningful on ELF platforms
  1505. which support shared libraries.
  1506. </p>
  1507. <p>The format of the dynamic list is the same as the version node without
  1508. scope and node name. See <a href="VERSION.html#VERSION">VERSION</a> for more information.
  1509. </p>
  1510. <a name="index-_002d_002ddynamic_002dlist_002ddata"></a>
  1511. </dd>
  1512. <dt><code>--dynamic-list-data</code></dt>
  1513. <dd><p>Include all global data symbols to the dynamic list.
  1514. </p>
  1515. <a name="index-_002d_002ddynamic_002dlist_002dcpp_002dnew"></a>
  1516. </dd>
  1517. <dt><code>--dynamic-list-cpp-new</code></dt>
  1518. <dd><p>Provide the builtin dynamic list for C++ operator new and delete. It
  1519. is mainly useful for building shared libstdc++.
  1520. </p>
  1521. <a name="index-_002d_002ddynamic_002dlist_002dcpp_002dtypeinfo"></a>
  1522. </dd>
  1523. <dt><code>--dynamic-list-cpp-typeinfo</code></dt>
  1524. <dd><p>Provide the builtin dynamic list for C++ runtime type identification.
  1525. </p>
  1526. <a name="index-_002d_002dcheck_002dsections"></a>
  1527. <a name="index-_002d_002dno_002dcheck_002dsections"></a>
  1528. </dd>
  1529. <dt><code>--check-sections</code></dt>
  1530. <dt><code>--no-check-sections</code></dt>
  1531. <dd><p>Asks the linker <em>not</em> to check section addresses after they have
  1532. been assigned to see if there are any overlaps. Normally the linker will
  1533. perform this check, and if it finds any overlaps it will produce
  1534. suitable error messages. The linker does know about, and does make
  1535. allowances for sections in overlays. The default behaviour can be
  1536. restored by using the command-line switch <samp>--check-sections</samp>.
  1537. Section overlap is not usually checked for relocatable links. You can
  1538. force checking in that case by using the <samp>--check-sections</samp>
  1539. option.
  1540. </p>
  1541. <a name="index-_002d_002dcopy_002ddt_002dneeded_002dentries"></a>
  1542. <a name="index-_002d_002dno_002dcopy_002ddt_002dneeded_002dentries"></a>
  1543. </dd>
  1544. <dt><code>--copy-dt-needed-entries</code></dt>
  1545. <dt><code>--no-copy-dt-needed-entries</code></dt>
  1546. <dd><p>This option affects the treatment of dynamic libraries referred to
  1547. by DT_NEEDED tags <em>inside</em> ELF dynamic libraries mentioned on the
  1548. command line. Normally the linker won&rsquo;t add a DT_NEEDED tag to the
  1549. output binary for each library mentioned in a DT_NEEDED tag in an
  1550. input dynamic library. With <samp>--copy-dt-needed-entries</samp>
  1551. specified on the command line however any dynamic libraries that
  1552. follow it will have their DT_NEEDED entries added. The default
  1553. behaviour can be restored with <samp>--no-copy-dt-needed-entries</samp>.
  1554. </p>
  1555. <p>This option also has an effect on the resolution of symbols in dynamic
  1556. libraries. With <samp>--copy-dt-needed-entries</samp> dynamic libraries
  1557. mentioned on the command line will be recursively searched, following
  1558. their DT_NEEDED tags to other libraries, in order to resolve symbols
  1559. required by the output binary. With the default setting however
  1560. the searching of dynamic libraries that follow it will stop with the
  1561. dynamic library itself. No DT_NEEDED links will be traversed to resolve
  1562. symbols.
  1563. </p>
  1564. <a name="index-cross-reference-table"></a>
  1565. <a name="index-_002d_002dcref"></a>
  1566. </dd>
  1567. <dt><code>--cref</code></dt>
  1568. <dd><p>Output a cross reference table. If a linker map file is being
  1569. generated, the cross reference table is printed to the map file.
  1570. Otherwise, it is printed on the standard output.
  1571. </p>
  1572. <p>The format of the table is intentionally simple, so that it may be
  1573. easily processed by a script if necessary. The symbols are printed out,
  1574. sorted by name. For each symbol, a list of file names is given. If the
  1575. symbol is defined, the first file listed is the location of the
  1576. definition. If the symbol is defined as a common value then any files
  1577. where this happens appear next. Finally any files that reference the
  1578. symbol are listed.
  1579. </p>
  1580. <a name="index-ctf-variables"></a>
  1581. <a name="index-_002d_002dctf_002dvariables"></a>
  1582. <a name="index-_002d_002dno_002dctf_002dvariables"></a>
  1583. </dd>
  1584. <dt><code>--ctf-variables</code></dt>
  1585. <dt><code>--no-ctf-variables</code></dt>
  1586. <dd><p>The CTF debuginfo format supports a section which encodes the names and
  1587. types of variables found in the program which do not appear in any symbol
  1588. table. These variables clearly cannot be looked up by address by
  1589. conventional debuggers, so the space used for their types and names is
  1590. usually wasted: the types are usually small but the names are often not.
  1591. <samp>--ctf-variables</samp> causes the generation of such a section.
  1592. The default behaviour can be restored with <samp>--no-ctf-variables</samp>.
  1593. </p>
  1594. <a name="index-ctf-type-sharing"></a>
  1595. <a name="index-_002d_002dctf_002dshare_002dtypes"></a>
  1596. </dd>
  1597. <dt><code>--ctf-share-types=<var>method</var></code></dt>
  1598. <dd><p>Adjust the method used to share types between translation units in CTF.
  1599. </p>
  1600. <dl compact="compact">
  1601. <dt>&lsquo;<samp>share-unconflicted</samp>&rsquo;</dt>
  1602. <dd><p>Put all types that do not have ambiguous definitions into the shared dictionary,
  1603. where debuggers can easily access them, even if they only occur in one
  1604. translation unit. This is the default.
  1605. </p>
  1606. </dd>
  1607. <dt>&lsquo;<samp>share-duplicated</samp>&rsquo;</dt>
  1608. <dd><p>Put only types that occur in multiple translation units into the shared
  1609. dictionary: types with only one definition go into per-translation-unit
  1610. dictionaries. Types with ambiguous definitions in multiple translation units
  1611. always go into per-translation-unit dictionaries. This tends to make the CTF
  1612. larger, but may reduce the amount of CTF in the shared dictionary. For very
  1613. large projects this may speed up opening the CTF and save memory in the CTF
  1614. consumer at runtime.
  1615. </p></dd>
  1616. </dl>
  1617. <a name="index-common-allocation-1"></a>
  1618. <a name="index-_002d_002dno_002ddefine_002dcommon"></a>
  1619. </dd>
  1620. <dt><code>--no-define-common</code></dt>
  1621. <dd><p>This option inhibits the assignment of addresses to common symbols.
  1622. The script command <code>INHIBIT_COMMON_ALLOCATION</code> has the same effect.
  1623. See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>.
  1624. </p>
  1625. <p>The &lsquo;<samp>--no-define-common</samp>&rsquo; option allows decoupling
  1626. the decision to assign addresses to Common symbols from the choice
  1627. of the output file type; otherwise a non-Relocatable output type
  1628. forces assigning addresses to Common symbols.
  1629. Using &lsquo;<samp>--no-define-common</samp>&rsquo; allows Common symbols that are referenced
  1630. from a shared library to be assigned addresses only in the main program.
  1631. This eliminates the unused duplicate space in the shared library,
  1632. and also prevents any possible confusion over resolving to the wrong
  1633. duplicate when there are many dynamic modules with specialized search
  1634. paths for runtime symbol resolution.
  1635. </p>
  1636. <a name="index-group-allocation-in-linker-script"></a>
  1637. <a name="index-section-groups"></a>
  1638. <a name="index-COMDAT"></a>
  1639. <a name="index-_002d_002dforce_002dgroup_002dallocation"></a>
  1640. </dd>
  1641. <dt><code>--force-group-allocation</code></dt>
  1642. <dd><p>This option causes the linker to place section group members like
  1643. normal input sections, and to delete the section groups. This is the
  1644. default behaviour for a final link but this option can be used to
  1645. change the behaviour of a relocatable link (&lsquo;<samp>-r</samp>&rsquo;). The script
  1646. command <code>FORCE_GROUP_ALLOCATION</code> has the same
  1647. effect. See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>.
  1648. </p>
  1649. <a name="index-symbols_002c-from-command-line"></a>
  1650. <a name="index-_002d_002ddefsym_003dsymbol_003dexp"></a>
  1651. </dd>
  1652. <dt><code>--defsym=<var>symbol</var>=<var>expression</var></code></dt>
  1653. <dd><p>Create a global symbol in the output file, containing the absolute
  1654. address given by <var>expression</var>. You may use this option as many
  1655. times as necessary to define multiple symbols in the command line. A
  1656. limited form of arithmetic is supported for the <var>expression</var> in this
  1657. context: you may give a hexadecimal constant or the name of an existing
  1658. symbol, or use <code>+</code> and <code>-</code> to add or subtract hexadecimal
  1659. constants or symbols. If you need more elaborate expressions, consider
  1660. using the linker command language from a script (see <a href="Assignments.html#Assignments">Assignments</a>).
  1661. <em>Note:</em> there should be no white space between <var>symbol</var>, the
  1662. equals sign (&ldquo;<tt class="key">=</tt>&rdquo;), and <var>expression</var>.
  1663. </p>
  1664. <p>The linker processes &lsquo;<samp>--defsym</samp>&rsquo; arguments and &lsquo;<samp>-T</samp>&rsquo; arguments
  1665. in order, placing &lsquo;<samp>--defsym</samp>&rsquo; before &lsquo;<samp>-T</samp>&rsquo; will define the
  1666. symbol before the linker script from &lsquo;<samp>-T</samp>&rsquo; is processed, while
  1667. placing &lsquo;<samp>--defsym</samp>&rsquo; after &lsquo;<samp>-T</samp>&rsquo; will define the symbol after
  1668. the linker script has been processed. This difference has
  1669. consequences for expressions within the linker script that use the
  1670. &lsquo;<samp>--defsym</samp>&rsquo; symbols, which order is correct will depend on what
  1671. you are trying to achieve.
  1672. </p>
  1673. <a name="index-demangling_002c-from-command-line"></a>
  1674. <a name="index-_002d_002ddemangle_005b_003dstyle_005d"></a>
  1675. <a name="index-_002d_002dno_002ddemangle"></a>
  1676. </dd>
  1677. <dt><code>--demangle[=<var>style</var>]</code></dt>
  1678. <dt><code>--no-demangle</code></dt>
  1679. <dd><p>These options control whether to demangle symbol names in error messages
  1680. and other output. When the linker is told to demangle, it tries to
  1681. present symbol names in a readable fashion: it strips leading
  1682. underscores if they are used by the object file format, and converts C++
  1683. mangled symbol names into user readable names. Different compilers have
  1684. different mangling styles. The optional demangling style argument can be used
  1685. to choose an appropriate demangling style for your compiler. The linker will
  1686. demangle by default unless the environment variable &lsquo;<samp>COLLECT_NO_DEMANGLE</samp>&rsquo;
  1687. is set. These options may be used to override the default.
  1688. </p>
  1689. <a name="index-dynamic-linker_002c-from-command-line"></a>
  1690. <a name="index-_002dIfile"></a>
  1691. <a name="index-_002d_002ddynamic_002dlinker_003dfile"></a>
  1692. </dd>
  1693. <dt><code>-I<var>file</var></code></dt>
  1694. <dt><code>--dynamic-linker=<var>file</var></code></dt>
  1695. <dd><p>Set the name of the dynamic linker. This is only meaningful when
  1696. generating dynamically linked ELF executables. The default dynamic
  1697. linker is normally correct; don&rsquo;t use this unless you know what you are
  1698. doing.
  1699. </p>
  1700. <a name="index-_002d_002dno_002ddynamic_002dlinker"></a>
  1701. </dd>
  1702. <dt><code>--no-dynamic-linker</code></dt>
  1703. <dd><p>When producing an executable file, omit the request for a dynamic
  1704. linker to be used at load-time. This is only meaningful for ELF
  1705. executables that contain dynamic relocations, and usually requires
  1706. entry point code that is capable of processing these relocations.
  1707. </p>
  1708. <a name="index-_002d_002dembedded_002drelocs"></a>
  1709. </dd>
  1710. <dt><code>--embedded-relocs</code></dt>
  1711. <dd><p>This option is similar to the <samp>--emit-relocs</samp> option except
  1712. that the relocs are stored in a target-specific section. This option
  1713. is only supported by the &lsquo;<samp>BFIN</samp>&rsquo;, &lsquo;<samp>CR16</samp>&rsquo; and <em>M68K</em>
  1714. targets.
  1715. </p>
  1716. <a name="index-_002d_002ddisable_002dmultiple_002dabs_002ddefs"></a>
  1717. </dd>
  1718. <dt><code>--disable-multiple-abs-defs</code></dt>
  1719. <dd><p>Do not allow multiple definitions with symbols included
  1720. in filename invoked by -R or &ndash;just-symbols
  1721. </p>
  1722. <a name="index-_002d_002dfatal_002dwarnings"></a>
  1723. <a name="index-_002d_002dno_002dfatal_002dwarnings"></a>
  1724. </dd>
  1725. <dt><code>--fatal-warnings</code></dt>
  1726. <dt><code>--no-fatal-warnings</code></dt>
  1727. <dd><p>Treat all warnings as errors. The default behaviour can be restored
  1728. with the option <samp>--no-fatal-warnings</samp>.
  1729. </p>
  1730. <a name="index-_002d_002dforce_002dexe_002dsuffix"></a>
  1731. </dd>
  1732. <dt><code>--force-exe-suffix</code></dt>
  1733. <dd><p>Make sure that an output file has a .exe suffix.
  1734. </p>
  1735. <p>If a successfully built fully linked output file does not have a
  1736. <code>.exe</code> or <code>.dll</code> suffix, this option forces the linker to copy
  1737. the output file to one of the same name with a <code>.exe</code> suffix. This
  1738. option is useful when using unmodified Unix makefiles on a Microsoft
  1739. Windows host, since some versions of Windows won&rsquo;t run an image unless
  1740. it ends in a <code>.exe</code> suffix.
  1741. </p>
  1742. <a name="index-_002d_002dgc_002dsections"></a>
  1743. <a name="index-_002d_002dno_002dgc_002dsections"></a>
  1744. <a name="index-garbage-collection"></a>
  1745. </dd>
  1746. <dt><code>--gc-sections</code></dt>
  1747. <dt><code>--no-gc-sections</code></dt>
  1748. <dd><p>Enable garbage collection of unused input sections. It is ignored on
  1749. targets that do not support this option. The default behaviour (of not
  1750. performing this garbage collection) can be restored by specifying
  1751. &lsquo;<samp>--no-gc-sections</samp>&rsquo; on the command line. Note that garbage
  1752. collection for COFF and PE format targets is supported, but the
  1753. implementation is currently considered to be experimental.
  1754. </p>
  1755. <p>&lsquo;<samp>--gc-sections</samp>&rsquo; decides which input sections are used by
  1756. examining symbols and relocations. The section containing the entry
  1757. symbol and all sections containing symbols undefined on the
  1758. command-line will be kept, as will sections containing symbols
  1759. referenced by dynamic objects. Note that when building shared
  1760. libraries, the linker must assume that any visible symbol is
  1761. referenced. Once this initial set of sections has been determined,
  1762. the linker recursively marks as used any section referenced by their
  1763. relocations. See &lsquo;<samp>--entry</samp>&rsquo;, &lsquo;<samp>--undefined</samp>&rsquo;, and
  1764. &lsquo;<samp>--gc-keep-exported</samp>&rsquo;.
  1765. </p>
  1766. <p>This option can be set when doing a partial link (enabled with option
  1767. &lsquo;<samp>-r</samp>&rsquo;). In this case the root of symbols kept must be explicitly
  1768. specified either by one of the options &lsquo;<samp>--entry</samp>&rsquo;,
  1769. &lsquo;<samp>--undefined</samp>&rsquo;, or &lsquo;<samp>--gc-keep-exported</samp>&rsquo; or by a <code>ENTRY</code>
  1770. command in the linker script.
  1771. </p>
  1772. <p>As a GNU extension, ELF input sections marked with the
  1773. <code>SHF_GNU_RETAIN</code> flag will not be garbage collected.
  1774. </p>
  1775. <a name="index-_002d_002dprint_002dgc_002dsections"></a>
  1776. <a name="index-_002d_002dno_002dprint_002dgc_002dsections"></a>
  1777. <a name="index-garbage-collection-1"></a>
  1778. </dd>
  1779. <dt><code>--print-gc-sections</code></dt>
  1780. <dt><code>--no-print-gc-sections</code></dt>
  1781. <dd><p>List all sections removed by garbage collection. The listing is
  1782. printed on stderr. This option is only effective if garbage
  1783. collection has been enabled via the &lsquo;<samp>--gc-sections</samp>&rsquo;) option. The
  1784. default behaviour (of not listing the sections that are removed) can
  1785. be restored by specifying &lsquo;<samp>--no-print-gc-sections</samp>&rsquo; on the command
  1786. line.
  1787. </p>
  1788. <a name="index-_002d_002dgc_002dkeep_002dexported"></a>
  1789. <a name="index-garbage-collection-2"></a>
  1790. </dd>
  1791. <dt><code>--gc-keep-exported</code></dt>
  1792. <dd><p>When &lsquo;<samp>--gc-sections</samp>&rsquo; is enabled, this option prevents garbage
  1793. collection of unused input sections that contain global symbols having
  1794. default or protected visibility. This option is intended to be used for
  1795. executables where unreferenced sections would otherwise be garbage
  1796. collected regardless of the external visibility of contained symbols.
  1797. Note that this option has no effect when linking shared objects since
  1798. it is already the default behaviour. This option is only supported for
  1799. ELF format targets.
  1800. </p>
  1801. <a name="index-_002d_002dprint_002doutput_002dformat"></a>
  1802. <a name="index-output-format"></a>
  1803. </dd>
  1804. <dt><code>--print-output-format</code></dt>
  1805. <dd><p>Print the name of the default output format (perhaps influenced by
  1806. other command-line options). This is the string that would appear
  1807. in an <code>OUTPUT_FORMAT</code> linker script command (see <a href="File-Commands.html#File-Commands">File Commands</a>).
  1808. </p>
  1809. <a name="index-_002d_002dprint_002dmemory_002dusage"></a>
  1810. <a name="index-memory-usage"></a>
  1811. </dd>
  1812. <dt><code>--print-memory-usage</code></dt>
  1813. <dd><p>Print used size, total size and used size of memory regions created with
  1814. the <a href="MEMORY.html#MEMORY">MEMORY</a> command. This is useful on embedded targets to have a
  1815. quick view of amount of free memory. The format of the output has one
  1816. headline and one line per region. It is both human readable and easily
  1817. parsable by tools. Here is an example of an output:
  1818. </p>
  1819. <div class="smallexample">
  1820. <pre class="smallexample">Memory region Used Size Region Size %age Used
  1821. ROM: 256 KB 1 MB 25.00%
  1822. RAM: 32 B 2 GB 0.00%
  1823. </pre></div>
  1824. <a name="index-help"></a>
  1825. <a name="index-usage"></a>
  1826. <a name="index-_002d_002dhelp"></a>
  1827. </dd>
  1828. <dt><code>--help</code></dt>
  1829. <dd><p>Print a summary of the command-line options on the standard output and exit.
  1830. </p>
  1831. <a name="index-_002d_002dtarget_002dhelp"></a>
  1832. </dd>
  1833. <dt><code>--target-help</code></dt>
  1834. <dd><p>Print a summary of all target-specific options on the standard output and exit.
  1835. </p>
  1836. <a name="index-_002dMap_003dmapfile"></a>
  1837. </dd>
  1838. <dt><code>-Map=<var>mapfile</var></code></dt>
  1839. <dd><p>Print a link map to the file <var>mapfile</var>. See the description of the
  1840. <samp>-M</samp> option, above. If <var>mapfile</var> is just the character
  1841. <code>-</code> then the map will be written to stdout.
  1842. </p>
  1843. <p>Specifying a directory as <var>mapfile</var> causes the linker map to be
  1844. written as a file inside the directory. Normally name of the file
  1845. inside the directory is computed as the basename of the <var>output</var>
  1846. file with <code>.map</code> appended. If however the special character
  1847. <code>%</code> is used then this will be replaced by the full path of the
  1848. output file. Additionally if there are any characters after the
  1849. <var>%</var> symbol then <code>.map</code> will no longer be appended.
  1850. </p>
  1851. <div class="smallexample">
  1852. <pre class="smallexample"> -o foo.exe -Map=bar [Creates ./bar]
  1853. -o ../dir/foo.exe -Map=bar [Creates ./bar]
  1854. -o foo.exe -Map=../dir [Creates ../dir/foo.exe.map]
  1855. -o ../dir2/foo.exe -Map=../dir [Creates ../dir/foo.exe.map]
  1856. -o foo.exe -Map=% [Creates ./foo.exe.map]
  1857. -o ../dir/foo.exe -Map=% [Creates ../dir/foo.exe.map]
  1858. -o foo.exe -Map=%.bar [Creates ./foo.exe.bar]
  1859. -o ../dir/foo.exe -Map=%.bar [Creates ../dir/foo.exe.bar]
  1860. -o ../dir2/foo.exe -Map=../dir/% [Creates ../dir/../dir2/foo.exe.map]
  1861. -o ../dir2/foo.exe -Map=../dir/%.bar [Creates ../dir/../dir2/foo.exe.bar]
  1862. </pre></div>
  1863. <p>It is an error to specify more than one <code>%</code> character.
  1864. </p>
  1865. <p>If the map file already exists then it will be overwritten by this
  1866. operation.
  1867. </p>
  1868. <a name="index-memory-usage-1"></a>
  1869. <a name="index-_002d_002dno_002dkeep_002dmemory"></a>
  1870. </dd>
  1871. <dt><code>--no-keep-memory</code></dt>
  1872. <dd><p><code>ld</code> normally optimizes for speed over memory usage by caching the
  1873. symbol tables of input files in memory. This option tells <code>ld</code> to
  1874. instead optimize for memory usage, by rereading the symbol tables as
  1875. necessary. This may be required if <code>ld</code> runs out of memory space
  1876. while linking a large executable.
  1877. </p>
  1878. <a name="index-_002d_002dno_002dundefined"></a>
  1879. <a name="index-_002dz-defs"></a>
  1880. <a name="index-_002dz-undefs"></a>
  1881. </dd>
  1882. <dt><code>--no-undefined</code></dt>
  1883. <dt><code>-z defs</code></dt>
  1884. <dd><p>Report unresolved symbol references from regular object files. This
  1885. is done even if the linker is creating a non-symbolic shared library.
  1886. The switch <samp>--[no-]allow-shlib-undefined</samp> controls the
  1887. behaviour for reporting unresolved references found in shared
  1888. libraries being linked in.
  1889. </p>
  1890. <p>The effects of this option can be reverted by using <code>-z undefs</code>.
  1891. </p>
  1892. <a name="index-_002d_002dallow_002dmultiple_002ddefinition"></a>
  1893. <a name="index-_002dz-muldefs"></a>
  1894. </dd>
  1895. <dt><code>--allow-multiple-definition</code></dt>
  1896. <dt><code>-z muldefs</code></dt>
  1897. <dd><p>Normally when a symbol is defined multiple times, the linker will
  1898. report a fatal error. These options allow multiple definitions and the
  1899. first definition will be used.
  1900. </p>
  1901. <a name="index-_002d_002dallow_002dshlib_002dundefined"></a>
  1902. <a name="index-_002d_002dno_002dallow_002dshlib_002dundefined"></a>
  1903. </dd>
  1904. <dt><code>--allow-shlib-undefined</code></dt>
  1905. <dt><code>--no-allow-shlib-undefined</code></dt>
  1906. <dd><p>Allows or disallows undefined symbols in shared libraries.
  1907. This switch is similar to <samp>--no-undefined</samp> except that it
  1908. determines the behaviour when the undefined symbols are in a
  1909. shared library rather than a regular object file. It does not affect
  1910. how undefined symbols in regular object files are handled.
  1911. </p>
  1912. <p>The default behaviour is to report errors for any undefined symbols
  1913. referenced in shared libraries if the linker is being used to create
  1914. an executable, but to allow them if the linker is being used to create
  1915. a shared library.
  1916. </p>
  1917. <p>The reasons for allowing undefined symbol references in shared
  1918. libraries specified at link time are that:
  1919. </p>
  1920. <ul>
  1921. <li> A shared library specified at link time may not be the same as the one
  1922. that is available at load time, so the symbol might actually be
  1923. resolvable at load time.
  1924. </li><li> There are some operating systems, eg BeOS and HPPA, where undefined
  1925. symbols in shared libraries are normal.
  1926. <p>The BeOS kernel for example patches shared libraries at load time to
  1927. select whichever function is most appropriate for the current
  1928. architecture. This is used, for example, to dynamically select an
  1929. appropriate memset function.
  1930. </p></li></ul>
  1931. <a name="index-_002d_002derror_002dhandling_002dscript_003dscriptname"></a>
  1932. </dd>
  1933. <dt><code>--error-handling-script=<var>scriptname</var></code></dt>
  1934. <dd><p>If this option is provided then the linker will invoke
  1935. <var>scriptname</var> whenever an error is encountered. Currently however
  1936. only two kinds of error are supported: missing symbols and missing
  1937. libraries. Two arguments will be passed to script: the keyword
  1938. &ldquo;undefined-symbol&rdquo; or &lsquo;missing-lib&rdquo; and the <var>name</var> of the
  1939. undefined symbol or missing library. The intention is that the script
  1940. will provide suggestions to the user as to where the symbol or library
  1941. might be found. After the script has finished then the normal linker
  1942. error message will be displayed.
  1943. </p>
  1944. <p>The availability of this option is controlled by a configure time
  1945. switch, so it may not be present in specific implementations.
  1946. </p>
  1947. <a name="index-_002d_002dno_002dundefined_002dversion"></a>
  1948. </dd>
  1949. <dt><code>--no-undefined-version</code></dt>
  1950. <dd><p>Normally when a symbol has an undefined version, the linker will ignore
  1951. it. This option disallows symbols with undefined version and a fatal error
  1952. will be issued instead.
  1953. </p>
  1954. <a name="index-_002d_002ddefault_002dsymver"></a>
  1955. </dd>
  1956. <dt><code>--default-symver</code></dt>
  1957. <dd><p>Create and use a default symbol version (the soname) for unversioned
  1958. exported symbols.
  1959. </p>
  1960. <a name="index-_002d_002ddefault_002dimported_002dsymver"></a>
  1961. </dd>
  1962. <dt><code>--default-imported-symver</code></dt>
  1963. <dd><p>Create and use a default symbol version (the soname) for unversioned
  1964. imported symbols.
  1965. </p>
  1966. <a name="index-_002d_002dno_002dwarn_002dmismatch"></a>
  1967. </dd>
  1968. <dt><code>--no-warn-mismatch</code></dt>
  1969. <dd><p>Normally <code>ld</code> will give an error if you try to link together input
  1970. files that are mismatched for some reason, perhaps because they have
  1971. been compiled for different processors or for different endiannesses.
  1972. This option tells <code>ld</code> that it should silently permit such possible
  1973. errors. This option should only be used with care, in cases when you
  1974. have taken some special action that ensures that the linker errors are
  1975. inappropriate.
  1976. </p>
  1977. <a name="index-_002d_002dno_002dwarn_002dsearch_002dmismatch"></a>
  1978. </dd>
  1979. <dt><code>--no-warn-search-mismatch</code></dt>
  1980. <dd><p>Normally <code>ld</code> will give a warning if it finds an incompatible
  1981. library during a library search. This option silences the warning.
  1982. </p>
  1983. <a name="index-_002d_002dno_002dwhole_002darchive"></a>
  1984. </dd>
  1985. <dt><code>--no-whole-archive</code></dt>
  1986. <dd><p>Turn off the effect of the <samp>--whole-archive</samp> option for subsequent
  1987. archive files.
  1988. </p>
  1989. <a name="index-output-file-after-errors"></a>
  1990. <a name="index-_002d_002dnoinhibit_002dexec"></a>
  1991. </dd>
  1992. <dt><code>--noinhibit-exec</code></dt>
  1993. <dd><p>Retain the executable output file whenever it is still usable.
  1994. Normally, the linker will not produce an output file if it encounters
  1995. errors during the link process; it exits without writing an output file
  1996. when it issues any error whatsoever.
  1997. </p>
  1998. <a name="index-_002dnostdlib"></a>
  1999. </dd>
  2000. <dt><code>-nostdlib</code></dt>
  2001. <dd><p>Only search library directories explicitly specified on the
  2002. command line. Library directories specified in linker scripts
  2003. (including linker scripts specified on the command line) are ignored.
  2004. </p>
  2005. <a name="index-_002d_002doformat_003doutput_002dformat"></a>
  2006. </dd>
  2007. <dt><code>--oformat=<var>output-format</var></code></dt>
  2008. <dd><p><code>ld</code> may be configured to support more than one kind of object
  2009. file. If your <code>ld</code> is configured this way, you can use the
  2010. &lsquo;<samp>--oformat</samp>&rsquo; option to specify the binary format for the output
  2011. object file. Even when <code>ld</code> is configured to support alternative
  2012. object formats, you don&rsquo;t usually need to specify this, as <code>ld</code>
  2013. should be configured to produce as a default output format the most
  2014. usual format on each machine. <var>output-format</var> is a text string, the
  2015. name of a particular format supported by the BFD libraries. (You can
  2016. list the available binary formats with &lsquo;<samp>objdump -i</samp>&rsquo;.) The script
  2017. command <code>OUTPUT_FORMAT</code> can also specify the output format, but
  2018. this option overrides it. See <a href="BFD.html#BFD">BFD</a>.
  2019. </p>
  2020. <a name="index-_002d_002dout_002dimplib"></a>
  2021. </dd>
  2022. <dt><code>--out-implib <var>file</var></code></dt>
  2023. <dd><p>Create an import library in <var>file</var> corresponding to the executable
  2024. the linker is generating (eg. a DLL or ELF program). This import
  2025. library (which should be called <code>*.dll.a</code> or <code>*.a</code> for DLLs)
  2026. may be used to link clients against the generated executable; this
  2027. behaviour makes it possible to skip a separate import library creation
  2028. step (eg. <code>dlltool</code> for DLLs). This option is only available for
  2029. the i386 PE and ELF targetted ports of the linker.
  2030. </p>
  2031. <a name="index-_002dpie"></a>
  2032. <a name="index-_002d_002dpic_002dexecutable"></a>
  2033. </dd>
  2034. <dt><code>-pie</code></dt>
  2035. <dt><code>--pic-executable</code></dt>
  2036. <dd><a name="index-position-independent-executables"></a>
  2037. <p>Create a position independent executable. This is currently only supported on
  2038. ELF platforms. Position independent executables are similar to shared
  2039. libraries in that they are relocated by the dynamic linker to the virtual
  2040. address the OS chooses for them (which can vary between invocations). Like
  2041. normal dynamically linked executables they can be executed and symbols
  2042. defined in the executable cannot be overridden by shared libraries.
  2043. </p>
  2044. <a name="index-_002dqmagic"></a>
  2045. </dd>
  2046. <dt><code>-qmagic</code></dt>
  2047. <dd><p>This option is ignored for Linux compatibility.
  2048. </p>
  2049. <a name="index-_002dQy"></a>
  2050. </dd>
  2051. <dt><code>-Qy</code></dt>
  2052. <dd><p>This option is ignored for SVR4 compatibility.
  2053. </p>
  2054. <a name="index-_002d_002drelax"></a>
  2055. <a name="index-synthesizing-linker"></a>
  2056. <a name="index-relaxing-addressing-modes"></a>
  2057. <a name="index-_002d_002dno_002drelax"></a>
  2058. </dd>
  2059. <dt><code>--relax</code></dt>
  2060. <dt><code>--no-relax</code></dt>
  2061. <dd><p>An option with machine dependent effects.
  2062. This option is only supported on a few targets.
  2063. See <a href="H8_002f300.html#H8_002f300"><code>ld</code> and the H8/300</a>.
  2064. See <a href="Xtensa.html#Xtensa"><code>ld</code> and Xtensa Processors</a>.
  2065. See <a href="M68HC11_002f68HC12.html#M68HC11_002f68HC12"><code>ld</code> and the 68HC11 and 68HC12</a>.
  2066. See <a href="Nios-II.html#Nios-II"><code>ld</code> and the Altera Nios II</a>.
  2067. See <a href="PowerPC-ELF32.html#PowerPC-ELF32"><code>ld</code> and PowerPC 32-bit ELF Support</a>.
  2068. </p>
  2069. <p>On some platforms the <samp>--relax</samp> option performs target specific,
  2070. global optimizations that become possible when the linker resolves
  2071. addressing in the program, such as relaxing address modes,
  2072. synthesizing new instructions, selecting shorter version of current
  2073. instructions, and combining constant values.
  2074. </p>
  2075. <p>On some platforms these link time global optimizations may make symbolic
  2076. debugging of the resulting executable impossible.
  2077. This is known to be the case for the Matsushita MN10200 and MN10300
  2078. family of processors.
  2079. </p>
  2080. <p>On platforms where the feature is supported, the option
  2081. <samp>--no-relax</samp> will disable it.
  2082. </p>
  2083. <p>On platforms where the feature is not supported, both <samp>--relax</samp>
  2084. and <samp>--no-relax</samp> are accepted, but ignored.
  2085. </p>
  2086. <a name="index-retaining-specified-symbols"></a>
  2087. <a name="index-stripping-all-but-some-symbols"></a>
  2088. <a name="index-symbols_002c-retaining-selectively"></a>
  2089. <a name="index-_002d_002dretain_002dsymbols_002dfile_003dfilename"></a>
  2090. </dd>
  2091. <dt><code>--retain-symbols-file=<var>filename</var></code></dt>
  2092. <dd><p>Retain <em>only</em> the symbols listed in the file <var>filename</var>,
  2093. discarding all others. <var>filename</var> is simply a flat file, with one
  2094. symbol name per line. This option is especially useful in environments
  2095. (such as VxWorks)
  2096. where a large global symbol table is accumulated gradually, to conserve
  2097. run-time memory.
  2098. </p>
  2099. <p>&lsquo;<samp>--retain-symbols-file</samp>&rsquo; does <em>not</em> discard undefined symbols,
  2100. or symbols needed for relocations.
  2101. </p>
  2102. <p>You may only specify &lsquo;<samp>--retain-symbols-file</samp>&rsquo; once in the command
  2103. line. It overrides &lsquo;<samp>-s</samp>&rsquo; and &lsquo;<samp>-S</samp>&rsquo;.
  2104. </p>
  2105. </dd>
  2106. <dt><code>-rpath=<var>dir</var></code></dt>
  2107. <dd><a name="index-runtime-library-search-path"></a>
  2108. <a name="index-_002drpath_003ddir"></a>
  2109. <p>Add a directory to the runtime library search path. This is used when
  2110. linking an ELF executable with shared objects. All <samp>-rpath</samp>
  2111. arguments are concatenated and passed to the runtime linker, which uses
  2112. them to locate shared objects at runtime.
  2113. </p>
  2114. <p>The <samp>-rpath</samp> option is also used when locating shared objects which
  2115. are needed by shared objects explicitly included in the link; see the
  2116. description of the <samp>-rpath-link</samp> option. Searching <samp>-rpath</samp>
  2117. in this way is only supported by native linkers and cross linkers which
  2118. have been configured with the <samp>--with-sysroot</samp> option.
  2119. </p>
  2120. <p>If <samp>-rpath</samp> is not used when linking an ELF executable, the
  2121. contents of the environment variable <code>LD_RUN_PATH</code> will be used if it
  2122. is defined.
  2123. </p>
  2124. <p>The <samp>-rpath</samp> option may also be used on SunOS. By default, on
  2125. SunOS, the linker will form a runtime search path out of all the
  2126. <samp>-L</samp> options it is given. If a <samp>-rpath</samp> option is used, the
  2127. runtime search path will be formed exclusively using the <samp>-rpath</samp>
  2128. options, ignoring the <samp>-L</samp> options. This can be useful when using
  2129. gcc, which adds many <samp>-L</samp> options which may be on NFS mounted
  2130. file systems.
  2131. </p>
  2132. <p>For compatibility with other ELF linkers, if the <samp>-R</samp> option is
  2133. followed by a directory name, rather than a file name, it is treated as
  2134. the <samp>-rpath</samp> option.
  2135. </p>
  2136. <a name="index-link_002dtime-runtime-library-search-path"></a>
  2137. <a name="index-_002drpath_002dlink_003ddir"></a>
  2138. </dd>
  2139. <dt><code>-rpath-link=<var>dir</var></code></dt>
  2140. <dd><p>When using ELF or SunOS, one shared library may require another. This
  2141. happens when an <code>ld -shared</code> link includes a shared library as one
  2142. of the input files.
  2143. </p>
  2144. <p>When the linker encounters such a dependency when doing a non-shared,
  2145. non-relocatable link, it will automatically try to locate the required
  2146. shared library and include it in the link, if it is not included
  2147. explicitly. In such a case, the <samp>-rpath-link</samp> option
  2148. specifies the first set of directories to search. The
  2149. <samp>-rpath-link</samp> option may specify a sequence of directory names
  2150. either by specifying a list of names separated by colons, or by
  2151. appearing multiple times.
  2152. </p>
  2153. <p>The tokens <var>$ORIGIN</var> and <var>$LIB</var> can appear in these search
  2154. directories. They will be replaced by the full path to the directory
  2155. containing the program or shared object in the case of <var>$ORIGIN</var>
  2156. and either &lsquo;<samp>lib</samp>&rsquo; - for 32-bit binaries - or &lsquo;<samp>lib64</samp>&rsquo; - for
  2157. 64-bit binaries - in the case of <var>$LIB</var>.
  2158. </p>
  2159. <p>The alternative form of these tokens - <var>${ORIGIN}</var> and
  2160. <var>${LIB}</var> can also be used. The token <var>$PLATFORM</var> is not
  2161. supported.
  2162. </p>
  2163. <p>This option should be used with caution as it overrides the search path
  2164. that may have been hard compiled into a shared library. In such a case it
  2165. is possible to use unintentionally a different search path than the
  2166. runtime linker would do.
  2167. </p>
  2168. <p>The linker uses the following search paths to locate required shared
  2169. libraries:
  2170. </p>
  2171. <ol>
  2172. <li> Any directories specified by <samp>-rpath-link</samp> options.
  2173. </li><li> Any directories specified by <samp>-rpath</samp> options. The difference
  2174. between <samp>-rpath</samp> and <samp>-rpath-link</samp> is that directories
  2175. specified by <samp>-rpath</samp> options are included in the executable and
  2176. used at runtime, whereas the <samp>-rpath-link</samp> option is only effective
  2177. at link time. Searching <samp>-rpath</samp> in this way is only supported
  2178. by native linkers and cross linkers which have been configured with
  2179. the <samp>--with-sysroot</samp> option.
  2180. </li><li> On an ELF system, for native linkers, if the <samp>-rpath</samp> and
  2181. <samp>-rpath-link</samp> options were not used, search the contents of the
  2182. environment variable <code>LD_RUN_PATH</code>.
  2183. </li><li> On SunOS, if the <samp>-rpath</samp> option was not used, search any
  2184. directories specified using <samp>-L</samp> options.
  2185. </li><li> For a native linker, search the contents of the environment
  2186. variable <code>LD_LIBRARY_PATH</code>.
  2187. </li><li> For a native ELF linker, the directories in <code>DT_RUNPATH</code> or
  2188. <code>DT_RPATH</code> of a shared library are searched for shared
  2189. libraries needed by it. The <code>DT_RPATH</code> entries are ignored if
  2190. <code>DT_RUNPATH</code> entries exist.
  2191. </li><li> The default directories, normally <samp>/lib</samp> and <samp>/usr/lib</samp>.
  2192. </li><li> For a linker for a Linux system, if the file <samp>/etc/ld.so.conf</samp>
  2193. exists, the list of directories found in that file. Note: the path
  2194. to this file is prefixed with the <code>sysroot</code> value, if that is
  2195. defined, and then any <code>prefix</code> string if the linker was
  2196. configured with the <code>--prefix=&lt;path&gt;</code> option.
  2197. </li><li> For a native linker on a FreeBSD system, any directories specified by
  2198. the <code>_PATH_ELF_HINTS</code> macro defined in the <samp>elf-hints.h</samp>
  2199. header file.
  2200. </li><li> Any directories specifed by a <code>SEARCH_DIR</code> command in the
  2201. linker script being used.
  2202. </li></ol>
  2203. <p>If the required shared library is not found, the linker will issue a
  2204. warning and continue with the link.
  2205. </p>
  2206. <a name="index-_002dshared"></a>
  2207. <a name="index-_002dBshareable"></a>
  2208. </dd>
  2209. <dt><code>-shared</code></dt>
  2210. <dt><code>-Bshareable</code></dt>
  2211. <dd><a name="index-shared-libraries"></a>
  2212. <p>Create a shared library. This is currently only supported on ELF, XCOFF
  2213. and SunOS platforms. On SunOS, the linker will automatically create a
  2214. shared library if the <samp>-e</samp> option is not used and there are
  2215. undefined symbols in the link.
  2216. </p>
  2217. <a name="index-_002d_002dsort_002dcommon"></a>
  2218. </dd>
  2219. <dt><code>--sort-common</code></dt>
  2220. <dt><code>--sort-common=ascending</code></dt>
  2221. <dt><code>--sort-common=descending</code></dt>
  2222. <dd><p>This option tells <code>ld</code> to sort the common symbols by alignment in
  2223. ascending or descending order when it places them in the appropriate output
  2224. sections. The symbol alignments considered are sixteen-byte or larger,
  2225. eight-byte, four-byte, two-byte, and one-byte. This is to prevent gaps
  2226. between symbols due to alignment constraints. If no sorting order is
  2227. specified, then descending order is assumed.
  2228. </p>
  2229. <a name="index-_002d_002dsort_002dsection_003dname"></a>
  2230. </dd>
  2231. <dt><code>--sort-section=name</code></dt>
  2232. <dd><p>This option will apply <code>SORT_BY_NAME</code> to all wildcard section
  2233. patterns in the linker script.
  2234. </p>
  2235. <a name="index-_002d_002dsort_002dsection_003dalignment"></a>
  2236. </dd>
  2237. <dt><code>--sort-section=alignment</code></dt>
  2238. <dd><p>This option will apply <code>SORT_BY_ALIGNMENT</code> to all wildcard section
  2239. patterns in the linker script.
  2240. </p>
  2241. <a name="index-_002d_002dspare_002ddynamic_002dtags"></a>
  2242. </dd>
  2243. <dt><code>--spare-dynamic-tags=<var>count</var></code></dt>
  2244. <dd><p>This option specifies the number of empty slots to leave in the
  2245. .dynamic section of ELF shared objects. Empty slots may be needed by
  2246. post processing tools, such as the prelinker. The default is 5.
  2247. </p>
  2248. <a name="index-_002d_002dsplit_002dby_002dfile"></a>
  2249. </dd>
  2250. <dt><code>--split-by-file[=<var>size</var>]</code></dt>
  2251. <dd><p>Similar to <samp>--split-by-reloc</samp> but creates a new output section for
  2252. each input file when <var>size</var> is reached. <var>size</var> defaults to a
  2253. size of 1 if not given.
  2254. </p>
  2255. <a name="index-_002d_002dsplit_002dby_002dreloc"></a>
  2256. </dd>
  2257. <dt><code>--split-by-reloc[=<var>count</var>]</code></dt>
  2258. <dd><p>Tries to creates extra sections in the output file so that no single
  2259. output section in the file contains more than <var>count</var> relocations.
  2260. This is useful when generating huge relocatable files for downloading into
  2261. certain real time kernels with the COFF object file format; since COFF
  2262. cannot represent more than 65535 relocations in a single section. Note
  2263. that this will fail to work with object file formats which do not
  2264. support arbitrary sections. The linker will not split up individual
  2265. input sections for redistribution, so if a single input section contains
  2266. more than <var>count</var> relocations one output section will contain that
  2267. many relocations. <var>count</var> defaults to a value of 32768.
  2268. </p>
  2269. <a name="index-_002d_002dstats"></a>
  2270. </dd>
  2271. <dt><code>--stats</code></dt>
  2272. <dd><p>Compute and display statistics about the operation of the linker, such
  2273. as execution time and memory usage.
  2274. </p>
  2275. <a name="index-_002d_002dsysroot_003ddirectory"></a>
  2276. </dd>
  2277. <dt><code>--sysroot=<var>directory</var></code></dt>
  2278. <dd><p>Use <var>directory</var> as the location of the sysroot, overriding the
  2279. configure-time default. This option is only supported by linkers
  2280. that were configured using <samp>--with-sysroot</samp>.
  2281. </p>
  2282. <a name="index-_002d_002dtask_002dlink"></a>
  2283. </dd>
  2284. <dt><code>--task-link</code></dt>
  2285. <dd><p>This is used by COFF/PE based targets to create a task-linked object
  2286. file where all of the global symbols have been converted to statics.
  2287. </p>
  2288. <a name="index-_002d_002dtraditional_002dformat"></a>
  2289. <a name="index-traditional-format"></a>
  2290. </dd>
  2291. <dt><code>--traditional-format</code></dt>
  2292. <dd><p>For some targets, the output of <code>ld</code> is different in some ways from
  2293. the output of some existing linker. This switch requests <code>ld</code> to
  2294. use the traditional format instead.
  2295. </p>
  2296. <a name="index-dbx"></a>
  2297. <p>For example, on SunOS, <code>ld</code> combines duplicate entries in the
  2298. symbol string table. This can reduce the size of an output file with
  2299. full debugging information by over 30 percent. Unfortunately, the SunOS
  2300. <code>dbx</code> program can not read the resulting program (<code>gdb</code> has no
  2301. trouble). The &lsquo;<samp>--traditional-format</samp>&rsquo; switch tells <code>ld</code> to not
  2302. combine duplicate entries.
  2303. </p>
  2304. <a name="index-_002d_002dsection_002dstart_003dsectionname_003dorg"></a>
  2305. </dd>
  2306. <dt><code>--section-start=<var>sectionname</var>=<var>org</var></code></dt>
  2307. <dd><p>Locate a section in the output file at the absolute
  2308. address given by <var>org</var>. You may use this option as many
  2309. times as necessary to locate multiple sections in the command
  2310. line.
  2311. <var>org</var> must be a single hexadecimal integer;
  2312. for compatibility with other linkers, you may omit the leading
  2313. &lsquo;<samp>0x</samp>&rsquo; usually associated with hexadecimal values. <em>Note:</em> there
  2314. should be no white space between <var>sectionname</var>, the equals
  2315. sign (&ldquo;<tt class="key">=</tt>&rdquo;), and <var>org</var>.
  2316. </p>
  2317. <a name="index-_002dTbss_003dorg"></a>
  2318. <a name="index-_002dTdata_003dorg"></a>
  2319. <a name="index-_002dTtext_003dorg"></a>
  2320. <a name="index-segment-origins_002c-cmd-line"></a>
  2321. </dd>
  2322. <dt><code>-Tbss=<var>org</var></code></dt>
  2323. <dt><code>-Tdata=<var>org</var></code></dt>
  2324. <dt><code>-Ttext=<var>org</var></code></dt>
  2325. <dd><p>Same as <samp>--section-start</samp>, with <code>.bss</code>, <code>.data</code> or
  2326. <code>.text</code> as the <var>sectionname</var>.
  2327. </p>
  2328. <a name="index-_002dTtext_002dsegment_003dorg"></a>
  2329. </dd>
  2330. <dt><code>-Ttext-segment=<var>org</var></code></dt>
  2331. <dd><a name="index-text-segment-origin_002c-cmd-line"></a>
  2332. <p>When creating an ELF executable, it will set the address of the first
  2333. byte of the text segment.
  2334. </p>
  2335. <a name="index-_002dTrodata_002dsegment_003dorg"></a>
  2336. </dd>
  2337. <dt><code>-Trodata-segment=<var>org</var></code></dt>
  2338. <dd><a name="index-rodata-segment-origin_002c-cmd-line"></a>
  2339. <p>When creating an ELF executable or shared object for a target where
  2340. the read-only data is in its own segment separate from the executable
  2341. text, it will set the address of the first byte of the read-only data segment.
  2342. </p>
  2343. <a name="index-_002dTldata_002dsegment_003dorg"></a>
  2344. </dd>
  2345. <dt><code>-Tldata-segment=<var>org</var></code></dt>
  2346. <dd><a name="index-ldata-segment-origin_002c-cmd-line"></a>
  2347. <p>When creating an ELF executable or shared object for x86-64 medium memory
  2348. model, it will set the address of the first byte of the ldata segment.
  2349. </p>
  2350. <a name="index-_002d_002dunresolved_002dsymbols"></a>
  2351. </dd>
  2352. <dt><code>--unresolved-symbols=<var>method</var></code></dt>
  2353. <dd><p>Determine how to handle unresolved symbols. There are four possible
  2354. values for &lsquo;<samp>method</samp>&rsquo;:
  2355. </p>
  2356. <dl compact="compact">
  2357. <dt>&lsquo;<samp>ignore-all</samp>&rsquo;</dt>
  2358. <dd><p>Do not report any unresolved symbols.
  2359. </p>
  2360. </dd>
  2361. <dt>&lsquo;<samp>report-all</samp>&rsquo;</dt>
  2362. <dd><p>Report all unresolved symbols. This is the default.
  2363. </p>
  2364. </dd>
  2365. <dt>&lsquo;<samp>ignore-in-object-files</samp>&rsquo;</dt>
  2366. <dd><p>Report unresolved symbols that are contained in shared libraries, but
  2367. ignore them if they come from regular object files.
  2368. </p>
  2369. </dd>
  2370. <dt>&lsquo;<samp>ignore-in-shared-libs</samp>&rsquo;</dt>
  2371. <dd><p>Report unresolved symbols that come from regular object files, but
  2372. ignore them if they come from shared libraries. This can be useful
  2373. when creating a dynamic binary and it is known that all the shared
  2374. libraries that it should be referencing are included on the linker&rsquo;s
  2375. command line.
  2376. </p></dd>
  2377. </dl>
  2378. <p>The behaviour for shared libraries on their own can also be controlled
  2379. by the <samp>--[no-]allow-shlib-undefined</samp> option.
  2380. </p>
  2381. <p>Normally the linker will generate an error message for each reported
  2382. unresolved symbol but the option <samp>--warn-unresolved-symbols</samp>
  2383. can change this to a warning.
  2384. </p>
  2385. <a name="index-_002d_002dverbose_005b_003dNUMBER_005d"></a>
  2386. <a name="index-verbose_005b_003dNUMBER_005d"></a>
  2387. </dd>
  2388. <dt><code>--dll-verbose</code></dt>
  2389. <dt><code>--verbose[=<var>NUMBER</var>]</code></dt>
  2390. <dd><p>Display the version number for <code>ld</code> and list the linker emulations
  2391. supported. Display which input files can and cannot be opened. Display
  2392. the linker script being used by the linker. If the optional <var>NUMBER</var>
  2393. argument &gt; 1, plugin symbol status will also be displayed.
  2394. </p>
  2395. <a name="index-_002d_002dversion_002dscript_003dversion_002dscriptfile"></a>
  2396. <a name="index-version-script_002c-symbol-versions"></a>
  2397. </dd>
  2398. <dt><code>--version-script=<var>version-scriptfile</var></code></dt>
  2399. <dd><p>Specify the name of a version script to the linker. This is typically
  2400. used when creating shared libraries to specify additional information
  2401. about the version hierarchy for the library being created. This option
  2402. is only fully supported on ELF platforms which support shared libraries;
  2403. see <a href="VERSION.html#VERSION">VERSION</a>. It is partially supported on PE platforms, which can
  2404. use version scripts to filter symbol visibility in auto-export mode: any
  2405. symbols marked &lsquo;<samp>local</samp>&rsquo; in the version script will not be exported.
  2406. See <a href="WIN32.html#WIN32">WIN32</a>.
  2407. </p>
  2408. <a name="index-_002d_002dwarn_002dcommon"></a>
  2409. <a name="index-warnings_002c-on-combining-symbols"></a>
  2410. <a name="index-combining-symbols_002c-warnings-on"></a>
  2411. </dd>
  2412. <dt><code>--warn-common</code></dt>
  2413. <dd><p>Warn when a common symbol is combined with another common symbol or with
  2414. a symbol definition. Unix linkers allow this somewhat sloppy practice,
  2415. but linkers on some other operating systems do not. This option allows
  2416. you to find potential problems from combining global symbols.
  2417. Unfortunately, some C libraries use this practice, so you may get some
  2418. warnings about symbols in the libraries as well as in your programs.
  2419. </p>
  2420. <p>There are three kinds of global symbols, illustrated here by C examples:
  2421. </p>
  2422. <dl compact="compact">
  2423. <dt>&lsquo;<samp>int i = 1;</samp>&rsquo;</dt>
  2424. <dd><p>A definition, which goes in the initialized data section of the output
  2425. file.
  2426. </p>
  2427. </dd>
  2428. <dt>&lsquo;<samp>extern int i;</samp>&rsquo;</dt>
  2429. <dd><p>An undefined reference, which does not allocate space.
  2430. There must be either a definition or a common symbol for the
  2431. variable somewhere.
  2432. </p>
  2433. </dd>
  2434. <dt>&lsquo;<samp>int i;</samp>&rsquo;</dt>
  2435. <dd><p>A common symbol. If there are only (one or more) common symbols for a
  2436. variable, it goes in the uninitialized data area of the output file.
  2437. The linker merges multiple common symbols for the same variable into a
  2438. single symbol. If they are of different sizes, it picks the largest
  2439. size. The linker turns a common symbol into a declaration, if there is
  2440. a definition of the same variable.
  2441. </p></dd>
  2442. </dl>
  2443. <p>The &lsquo;<samp>--warn-common</samp>&rsquo; option can produce five kinds of warnings.
  2444. Each warning consists of a pair of lines: the first describes the symbol
  2445. just encountered, and the second describes the previous symbol
  2446. encountered with the same name. One or both of the two symbols will be
  2447. a common symbol.
  2448. </p>
  2449. <ol>
  2450. <li> Turning a common symbol into a reference, because there is already a
  2451. definition for the symbol.
  2452. <div class="smallexample">
  2453. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
  2454. overridden by definition
  2455. <var>file</var>(<var>section</var>): warning: defined here
  2456. </pre></div>
  2457. </li><li> Turning a common symbol into a reference, because a later definition for
  2458. the symbol is encountered. This is the same as the previous case,
  2459. except that the symbols are encountered in a different order.
  2460. <div class="smallexample">
  2461. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: definition of `<var>symbol</var>'
  2462. overriding common
  2463. <var>file</var>(<var>section</var>): warning: common is here
  2464. </pre></div>
  2465. </li><li> Merging a common symbol with a previous same-sized common symbol.
  2466. <div class="smallexample">
  2467. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: multiple common
  2468. of `<var>symbol</var>'
  2469. <var>file</var>(<var>section</var>): warning: previous common is here
  2470. </pre></div>
  2471. </li><li> Merging a common symbol with a previous larger common symbol.
  2472. <div class="smallexample">
  2473. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
  2474. overridden by larger common
  2475. <var>file</var>(<var>section</var>): warning: larger common is here
  2476. </pre></div>
  2477. </li><li> Merging a common symbol with a previous smaller common symbol. This is
  2478. the same as the previous case, except that the symbols are
  2479. encountered in a different order.
  2480. <div class="smallexample">
  2481. <pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
  2482. overriding smaller common
  2483. <var>file</var>(<var>section</var>): warning: smaller common is here
  2484. </pre></div>
  2485. </li></ol>
  2486. <a name="index-_002d_002dwarn_002dconstructors"></a>
  2487. </dd>
  2488. <dt><code>--warn-constructors</code></dt>
  2489. <dd><p>Warn if any global constructors are used. This is only useful for a few
  2490. object file formats. For formats like COFF or ELF, the linker can not
  2491. detect the use of global constructors.
  2492. </p>
  2493. <a name="index-_002d_002dwarn_002dmultiple_002dgp"></a>
  2494. </dd>
  2495. <dt><code>--warn-multiple-gp</code></dt>
  2496. <dd><p>Warn if multiple global pointer values are required in the output file.
  2497. This is only meaningful for certain processors, such as the Alpha.
  2498. Specifically, some processors put large-valued constants in a special
  2499. section. A special register (the global pointer) points into the middle
  2500. of this section, so that constants can be loaded efficiently via a
  2501. base-register relative addressing mode. Since the offset in
  2502. base-register relative mode is fixed and relatively small (e.g., 16
  2503. bits), this limits the maximum size of the constant pool. Thus, in
  2504. large programs, it is often necessary to use multiple global pointer
  2505. values in order to be able to address all possible constants. This
  2506. option causes a warning to be issued whenever this case occurs.
  2507. </p>
  2508. <a name="index-_002d_002dwarn_002donce"></a>
  2509. <a name="index-warnings_002c-on-undefined-symbols"></a>
  2510. <a name="index-undefined-symbols_002c-warnings-on"></a>
  2511. </dd>
  2512. <dt><code>--warn-once</code></dt>
  2513. <dd><p>Only warn once for each undefined symbol, rather than once per module
  2514. which refers to it.
  2515. </p>
  2516. <a name="index-_002d_002dwarn_002dsection_002dalign"></a>
  2517. <a name="index-warnings_002c-on-section-alignment"></a>
  2518. <a name="index-section-alignment_002c-warnings-on"></a>
  2519. </dd>
  2520. <dt><code>--warn-section-align</code></dt>
  2521. <dd><p>Warn if the address of an output section is changed because of
  2522. alignment. Typically, the alignment will be set by an input section.
  2523. The address will only be changed if it not explicitly specified; that
  2524. is, if the <code>SECTIONS</code> command does not specify a start address for
  2525. the section (see <a href="SECTIONS.html#SECTIONS">SECTIONS</a>).
  2526. </p>
  2527. <a name="index-_002d_002dwarn_002dtextrel"></a>
  2528. </dd>
  2529. <dt><code>--warn-textrel</code></dt>
  2530. <dd><p>Warn if the linker adds DT_TEXTREL to a position-independent executable
  2531. or shared object.
  2532. </p>
  2533. <a name="index-_002d_002dwarn_002dalternate_002dem"></a>
  2534. </dd>
  2535. <dt><code>--warn-alternate-em</code></dt>
  2536. <dd><p>Warn if an object has alternate ELF machine code.
  2537. </p>
  2538. <a name="index-_002d_002dwarn_002dunresolved_002dsymbols"></a>
  2539. </dd>
  2540. <dt><code>--warn-unresolved-symbols</code></dt>
  2541. <dd><p>If the linker is going to report an unresolved symbol (see the option
  2542. <samp>--unresolved-symbols</samp>) it will normally generate an error.
  2543. This option makes it generate a warning instead.
  2544. </p>
  2545. <a name="index-_002d_002derror_002dunresolved_002dsymbols"></a>
  2546. </dd>
  2547. <dt><code>--error-unresolved-symbols</code></dt>
  2548. <dd><p>This restores the linker&rsquo;s default behaviour of generating errors when
  2549. it is reporting unresolved symbols.
  2550. </p>
  2551. <a name="index-_002d_002dwhole_002darchive"></a>
  2552. <a name="index-including-an-entire-archive"></a>
  2553. </dd>
  2554. <dt><code>--whole-archive</code></dt>
  2555. <dd><p>For each archive mentioned on the command line after the
  2556. <samp>--whole-archive</samp> option, include every object file in the archive
  2557. in the link, rather than searching the archive for the required object
  2558. files. This is normally used to turn an archive file into a shared
  2559. library, forcing every object to be included in the resulting shared
  2560. library. This option may be used more than once.
  2561. </p>
  2562. <p>Two notes when using this option from gcc: First, gcc doesn&rsquo;t know
  2563. about this option, so you have to use <samp>-Wl,-whole-archive</samp>.
  2564. Second, don&rsquo;t forget to use <samp>-Wl,-no-whole-archive</samp> after your
  2565. list of archives, because gcc will add its own list of archives to
  2566. your link and you may not want this flag to affect those as well.
  2567. </p>
  2568. <a name="index-_002d_002dwrap_003dsymbol"></a>
  2569. </dd>
  2570. <dt><code>--wrap=<var>symbol</var></code></dt>
  2571. <dd><p>Use a wrapper function for <var>symbol</var>. Any undefined reference to
  2572. <var>symbol</var> will be resolved to <code>__wrap_<var>symbol</var></code>. Any
  2573. undefined reference to <code>__real_<var>symbol</var></code> will be resolved to
  2574. <var>symbol</var>.
  2575. </p>
  2576. <p>This can be used to provide a wrapper for a system function. The
  2577. wrapper function should be called <code>__wrap_<var>symbol</var></code>. If it
  2578. wishes to call the system function, it should call
  2579. <code>__real_<var>symbol</var></code>.
  2580. </p>
  2581. <p>Here is a trivial example:
  2582. </p>
  2583. <div class="smallexample">
  2584. <pre class="smallexample">void *
  2585. __wrap_malloc (size_t c)
  2586. {
  2587. printf (&quot;malloc called with %zu\n&quot;, c);
  2588. return __real_malloc (c);
  2589. }
  2590. </pre></div>
  2591. <p>If you link other code with this file using <samp>--wrap malloc</samp>, then
  2592. all calls to <code>malloc</code> will call the function <code>__wrap_malloc</code>
  2593. instead. The call to <code>__real_malloc</code> in <code>__wrap_malloc</code> will
  2594. call the real <code>malloc</code> function.
  2595. </p>
  2596. <p>You may wish to provide a <code>__real_malloc</code> function as well, so that
  2597. links without the <samp>--wrap</samp> option will succeed. If you do this,
  2598. you should not put the definition of <code>__real_malloc</code> in the same
  2599. file as <code>__wrap_malloc</code>; if you do, the assembler may resolve the
  2600. call before the linker has a chance to wrap it to <code>malloc</code>.
  2601. </p>
  2602. <p>Only undefined references are replaced by the linker. So, translation unit
  2603. internal references to <var>symbol</var> are not resolved to
  2604. <code>__wrap_<var>symbol</var></code>. In the next example, the call to <code>f</code> in
  2605. <code>g</code> is not resolved to <code>__wrap_f</code>.
  2606. </p>
  2607. <div class="smallexample">
  2608. <pre class="smallexample">int
  2609. f (void)
  2610. {
  2611. return 123;
  2612. }
  2613. int
  2614. g (void)
  2615. {
  2616. return f();
  2617. }
  2618. </pre></div>
  2619. <a name="index-_002d_002deh_002dframe_002dhdr"></a>
  2620. <a name="index-_002d_002dno_002deh_002dframe_002dhdr"></a>
  2621. </dd>
  2622. <dt><code>--eh-frame-hdr</code></dt>
  2623. <dt><code>--no-eh-frame-hdr</code></dt>
  2624. <dd><p>Request (<samp>--eh-frame-hdr</samp>) or suppress
  2625. (<samp>--no-eh-frame-hdr</samp>) the creation of <code>.eh_frame_hdr</code>
  2626. section and ELF <code>PT_GNU_EH_FRAME</code> segment header.
  2627. </p>
  2628. <a name="index-_002d_002dld_002dgenerated_002dunwind_002dinfo"></a>
  2629. </dd>
  2630. <dt><code>--no-ld-generated-unwind-info</code></dt>
  2631. <dd><p>Request creation of <code>.eh_frame</code> unwind info for linker
  2632. generated code sections like PLT. This option is on by default
  2633. if linker generated unwind info is supported.
  2634. </p>
  2635. <a name="index-_002d_002denable_002dnew_002ddtags"></a>
  2636. <a name="index-_002d_002ddisable_002dnew_002ddtags"></a>
  2637. </dd>
  2638. <dt><code>--enable-new-dtags</code></dt>
  2639. <dt><code>--disable-new-dtags</code></dt>
  2640. <dd><p>This linker can create the new dynamic tags in ELF. But the older ELF
  2641. systems may not understand them. If you specify
  2642. <samp>--enable-new-dtags</samp>, the new dynamic tags will be created as needed
  2643. and older dynamic tags will be omitted.
  2644. If you specify <samp>--disable-new-dtags</samp>, no new dynamic tags will be
  2645. created. By default, the new dynamic tags are not created. Note that
  2646. those options are only available for ELF systems.
  2647. </p>
  2648. <a name="index-_002d_002dhash_002dsize_003dnumber"></a>
  2649. </dd>
  2650. <dt><code>--hash-size=<var>number</var></code></dt>
  2651. <dd><p>Set the default size of the linker&rsquo;s hash tables to a prime number
  2652. close to <var>number</var>. Increasing this value can reduce the length of
  2653. time it takes the linker to perform its tasks, at the expense of
  2654. increasing the linker&rsquo;s memory requirements. Similarly reducing this
  2655. value can reduce the memory requirements at the expense of speed.
  2656. </p>
  2657. <a name="index-_002d_002dhash_002dstyle_003dstyle"></a>
  2658. </dd>
  2659. <dt><code>--hash-style=<var>style</var></code></dt>
  2660. <dd><p>Set the type of linker&rsquo;s hash table(s). <var>style</var> can be either
  2661. <code>sysv</code> for classic ELF <code>.hash</code> section, <code>gnu</code> for
  2662. new style GNU <code>.gnu.hash</code> section or <code>both</code> for both
  2663. the classic ELF <code>.hash</code> and new style GNU <code>.gnu.hash</code>
  2664. hash tables. The default depends upon how the linker was configured,
  2665. but for most Linux based systems it will be <code>both</code>.
  2666. </p>
  2667. <a name="index-_002d_002dcompress_002ddebug_002dsections_003dnone"></a>
  2668. <a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib"></a>
  2669. <a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib_002dgnu"></a>
  2670. <a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib_002dgabi"></a>
  2671. </dd>
  2672. <dt><code>--compress-debug-sections=none</code></dt>
  2673. <dt><code>--compress-debug-sections=zlib</code></dt>
  2674. <dt><code>--compress-debug-sections=zlib-gnu</code></dt>
  2675. <dt><code>--compress-debug-sections=zlib-gabi</code></dt>
  2676. <dd><p>On ELF platforms, these options control how DWARF debug sections are
  2677. compressed using zlib.
  2678. </p>
  2679. <p><samp>--compress-debug-sections=none</samp> doesn&rsquo;t compress DWARF debug
  2680. sections. <samp>--compress-debug-sections=zlib-gnu</samp> compresses
  2681. DWARF debug sections and renames them to begin with &lsquo;<samp>.zdebug</samp>&rsquo;
  2682. instead of &lsquo;<samp>.debug</samp>&rsquo;. <samp>--compress-debug-sections=zlib-gabi</samp>
  2683. also compresses DWARF debug sections, but rather than renaming them it
  2684. sets the SHF_COMPRESSED flag in the sections&rsquo; headers.
  2685. </p>
  2686. <p>The <samp>--compress-debug-sections=zlib</samp> option is an alias for
  2687. <samp>--compress-debug-sections=zlib-gabi</samp>.
  2688. </p>
  2689. <p>Note that this option overrides any compression in input debug
  2690. sections, so if a binary is linked with <samp>--compress-debug-sections=none</samp>
  2691. for example, then any compressed debug sections in input files will be
  2692. uncompressed before they are copied into the output binary.
  2693. </p>
  2694. <p>The default compression behaviour varies depending upon the target
  2695. involved and the configure options used to build the toolchain. The
  2696. default can be determined by examining the output from the linker&rsquo;s
  2697. <samp>--help</samp> option.
  2698. </p>
  2699. <a name="index-_002d_002dreduce_002dmemory_002doverheads"></a>
  2700. </dd>
  2701. <dt><code>--reduce-memory-overheads</code></dt>
  2702. <dd><p>This option reduces memory requirements at ld runtime, at the expense of
  2703. linking speed. This was introduced to select the old O(n^2) algorithm
  2704. for link map file generation, rather than the new O(n) algorithm which uses
  2705. about 40% more memory for symbol storage.
  2706. </p>
  2707. <p>Another effect of the switch is to set the default hash table size to
  2708. 1021, which again saves memory at the cost of lengthening the linker&rsquo;s
  2709. run time. This is not done however if the <samp>--hash-size</samp> switch
  2710. has been used.
  2711. </p>
  2712. <p>The <samp>--reduce-memory-overheads</samp> switch may be also be used to
  2713. enable other tradeoffs in future versions of the linker.
  2714. </p>
  2715. <a name="index-_002d_002dbuild_002did"></a>
  2716. <a name="index-_002d_002dbuild_002did_003dstyle"></a>
  2717. </dd>
  2718. <dt><code>--build-id</code></dt>
  2719. <dt><code>--build-id=<var>style</var></code></dt>
  2720. <dd><p>Request the creation of a <code>.note.gnu.build-id</code> ELF note section
  2721. or a <code>.buildid</code> COFF section. The contents of the note are
  2722. unique bits identifying this linked file. <var>style</var> can be
  2723. <code>uuid</code> to use 128 random bits, <code>sha1</code> to use a 160-bit
  2724. <small>SHA1</small> hash on the normative parts of the output contents,
  2725. <code>md5</code> to use a 128-bit <small>MD5</small> hash on the normative parts of
  2726. the output contents, or <code>0x<var>hexstring</var></code> to use a chosen bit
  2727. string specified as an even number of hexadecimal digits (<code>-</code> and
  2728. <code>:</code> characters between digit pairs are ignored). If <var>style</var>
  2729. is omitted, <code>sha1</code> is used.
  2730. </p>
  2731. <p>The <code>md5</code> and <code>sha1</code> styles produces an identifier
  2732. that is always the same in an identical output file, but will be
  2733. unique among all nonidentical output files. It is not intended
  2734. to be compared as a checksum for the file&rsquo;s contents. A linked
  2735. file may be changed later by other tools, but the build ID bit
  2736. string identifying the original linked file does not change.
  2737. </p>
  2738. <p>Passing <code>none</code> for <var>style</var> disables the setting from any
  2739. <code>--build-id</code> options earlier on the command line.
  2740. </p></dd>
  2741. </dl>
  2742. <a name="Options-Specific-to-i386-PE-Targets"></a>
  2743. <h4 class="subsection">2.1.1 Options Specific to i386 PE Targets</h4>
  2744. <p>The i386 PE linker supports the <samp>-shared</samp> option, which causes
  2745. the output to be a dynamically linked library (DLL) instead of a
  2746. normal executable. You should name the output <code>*.dll</code> when you
  2747. use this option. In addition, the linker fully supports the standard
  2748. <code>*.def</code> files, which may be specified on the linker command line
  2749. like an object file (in fact, it should precede archives it exports
  2750. symbols from, to ensure that they get linked in, just like a normal
  2751. object file).
  2752. </p>
  2753. <p>In addition to the options common to all targets, the i386 PE linker
  2754. support additional command-line options that are specific to the i386
  2755. PE target. Options that take values may be separated from their
  2756. values by either a space or an equals sign.
  2757. </p>
  2758. <dl compact="compact">
  2759. <dd>
  2760. <a name="index-_002d_002dadd_002dstdcall_002dalias"></a>
  2761. </dd>
  2762. <dt><code>--add-stdcall-alias</code></dt>
  2763. <dd><p>If given, symbols with a stdcall suffix (@<var>nn</var>) will be exported
  2764. as-is and also with the suffix stripped.
  2765. [This option is specific to the i386 PE targeted port of the linker]
  2766. </p>
  2767. <a name="index-_002d_002dbase_002dfile"></a>
  2768. </dd>
  2769. <dt><code>--base-file <var>file</var></code></dt>
  2770. <dd><p>Use <var>file</var> as the name of a file in which to save the base
  2771. addresses of all the relocations needed for generating DLLs with
  2772. <samp>dlltool</samp>.
  2773. [This is an i386 PE specific option]
  2774. </p>
  2775. <a name="index-_002d_002ddll"></a>
  2776. </dd>
  2777. <dt><code>--dll</code></dt>
  2778. <dd><p>Create a DLL instead of a regular executable. You may also use
  2779. <samp>-shared</samp> or specify a <code>LIBRARY</code> in a given <code>.def</code>
  2780. file.
  2781. [This option is specific to the i386 PE targeted port of the linker]
  2782. </p>
  2783. <a name="index-_002d_002denable_002dlong_002dsection_002dnames"></a>
  2784. <a name="index-_002d_002ddisable_002dlong_002dsection_002dnames"></a>
  2785. </dd>
  2786. <dt><code>--enable-long-section-names</code></dt>
  2787. <dt><code>--disable-long-section-names</code></dt>
  2788. <dd><p>The PE variants of the COFF object format add an extension that permits
  2789. the use of section names longer than eight characters, the normal limit
  2790. for COFF. By default, these names are only allowed in object files, as
  2791. fully-linked executable images do not carry the COFF string table required
  2792. to support the longer names. As a GNU extension, it is possible to
  2793. allow their use in executable images as well, or to (probably pointlessly!)
  2794. disallow it in object files, by using these two options. Executable images
  2795. generated with these long section names are slightly non-standard, carrying
  2796. as they do a string table, and may generate confusing output when examined
  2797. with non-GNU PE-aware tools, such as file viewers and dumpers. However,
  2798. GDB relies on the use of PE long section names to find Dwarf-2 debug
  2799. information sections in an executable image at runtime, and so if neither
  2800. option is specified on the command-line, <code>ld</code> will enable long
  2801. section names, overriding the default and technically correct behaviour,
  2802. when it finds the presence of debug information while linking an executable
  2803. image and not stripping symbols.
  2804. [This option is valid for all PE targeted ports of the linker]
  2805. </p>
  2806. <a name="index-_002d_002denable_002dstdcall_002dfixup"></a>
  2807. <a name="index-_002d_002ddisable_002dstdcall_002dfixup"></a>
  2808. </dd>
  2809. <dt><code>--enable-stdcall-fixup</code></dt>
  2810. <dt><code>--disable-stdcall-fixup</code></dt>
  2811. <dd><p>If the link finds a symbol that it cannot resolve, it will attempt to
  2812. do &ldquo;fuzzy linking&rdquo; by looking for another defined symbol that differs
  2813. only in the format of the symbol name (cdecl vs stdcall) and will
  2814. resolve that symbol by linking to the match. For example, the
  2815. undefined symbol <code>_foo</code> might be linked to the function
  2816. <code>_foo@12</code>, or the undefined symbol <code>_bar@16</code> might be linked
  2817. to the function <code>_bar</code>. When the linker does this, it prints a
  2818. warning, since it normally should have failed to link, but sometimes
  2819. import libraries generated from third-party dlls may need this feature
  2820. to be usable. If you specify <samp>--enable-stdcall-fixup</samp>, this
  2821. feature is fully enabled and warnings are not printed. If you specify
  2822. <samp>--disable-stdcall-fixup</samp>, this feature is disabled and such
  2823. mismatches are considered to be errors.
  2824. [This option is specific to the i386 PE targeted port of the linker]
  2825. </p>
  2826. <a name="index-_002d_002dleading_002dunderscore"></a>
  2827. <a name="index-_002d_002dno_002dleading_002dunderscore"></a>
  2828. </dd>
  2829. <dt><code>--leading-underscore</code></dt>
  2830. <dt><code>--no-leading-underscore</code></dt>
  2831. <dd><p>For most targets default symbol-prefix is an underscore and is defined
  2832. in target&rsquo;s description. By this option it is possible to
  2833. disable/enable the default underscore symbol-prefix.
  2834. </p>
  2835. <a name="index-DLLs_002c-creating"></a>
  2836. <a name="index-_002d_002dexport_002dall_002dsymbols"></a>
  2837. </dd>
  2838. <dt><code>--export-all-symbols</code></dt>
  2839. <dd><p>If given, all global symbols in the objects used to build a DLL will
  2840. be exported by the DLL. Note that this is the default if there
  2841. otherwise wouldn&rsquo;t be any exported symbols. When symbols are
  2842. explicitly exported via DEF files or implicitly exported via function
  2843. attributes, the default is to not export anything else unless this
  2844. option is given. Note that the symbols <code>DllMain@12</code>,
  2845. <code>DllEntryPoint@0</code>, <code>DllMainCRTStartup@12</code>, and
  2846. <code>impure_ptr</code> will not be automatically
  2847. exported. Also, symbols imported from other DLLs will not be
  2848. re-exported, nor will symbols specifying the DLL&rsquo;s internal layout
  2849. such as those beginning with <code>_head_</code> or ending with
  2850. <code>_iname</code>. In addition, no symbols from <code>libgcc</code>,
  2851. <code>libstd++</code>, <code>libmingw32</code>, or <code>crtX.o</code> will be exported.
  2852. Symbols whose names begin with <code>__rtti_</code> or <code>__builtin_</code> will
  2853. not be exported, to help with C++ DLLs. Finally, there is an
  2854. extensive list of cygwin-private symbols that are not exported
  2855. (obviously, this applies on when building DLLs for cygwin targets).
  2856. These cygwin-excludes are: <code>_cygwin_dll_entry@12</code>,
  2857. <code>_cygwin_crt0_common@8</code>, <code>_cygwin_noncygwin_dll_entry@12</code>,
  2858. <code>_fmode</code>, <code>_impure_ptr</code>, <code>cygwin_attach_dll</code>,
  2859. <code>cygwin_premain0</code>, <code>cygwin_premain1</code>, <code>cygwin_premain2</code>,
  2860. <code>cygwin_premain3</code>, and <code>environ</code>.
  2861. [This option is specific to the i386 PE targeted port of the linker]
  2862. </p>
  2863. <a name="index-_002d_002dexclude_002dsymbols"></a>
  2864. </dd>
  2865. <dt><code>--exclude-symbols <var>symbol</var>,<var>symbol</var>,...</code></dt>
  2866. <dd><p>Specifies a list of symbols which should not be automatically
  2867. exported. The symbol names may be delimited by commas or colons.
  2868. [This option is specific to the i386 PE targeted port of the linker]
  2869. </p>
  2870. <a name="index-_002d_002dexclude_002dall_002dsymbols"></a>
  2871. </dd>
  2872. <dt><code>--exclude-all-symbols</code></dt>
  2873. <dd><p>Specifies no symbols should be automatically exported.
  2874. [This option is specific to the i386 PE targeted port of the linker]
  2875. </p>
  2876. <a name="index-_002d_002dfile_002dalignment"></a>
  2877. </dd>
  2878. <dt><code>--file-alignment</code></dt>
  2879. <dd><p>Specify the file alignment. Sections in the file will always begin at
  2880. file offsets which are multiples of this number. This defaults to
  2881. 512.
  2882. [This option is specific to the i386 PE targeted port of the linker]
  2883. </p>
  2884. <a name="index-heap-size"></a>
  2885. <a name="index-_002d_002dheap"></a>
  2886. </dd>
  2887. <dt><code>--heap <var>reserve</var></code></dt>
  2888. <dt><code>--heap <var>reserve</var>,<var>commit</var></code></dt>
  2889. <dd><p>Specify the number of bytes of memory to reserve (and optionally commit)
  2890. to be used as heap for this program. The default is 1MB reserved, 4K
  2891. committed.
  2892. [This option is specific to the i386 PE targeted port of the linker]
  2893. </p>
  2894. <a name="index-image-base"></a>
  2895. <a name="index-_002d_002dimage_002dbase"></a>
  2896. </dd>
  2897. <dt><code>--image-base <var>value</var></code></dt>
  2898. <dd><p>Use <var>value</var> as the base address of your program or dll. This is
  2899. the lowest memory location that will be used when your program or dll
  2900. is loaded. To reduce the need to relocate and improve performance of
  2901. your dlls, each should have a unique base address and not overlap any
  2902. other dlls. The default is 0x400000 for executables, and 0x10000000
  2903. for dlls.
  2904. [This option is specific to the i386 PE targeted port of the linker]
  2905. </p>
  2906. <a name="index-_002d_002dkill_002dat"></a>
  2907. </dd>
  2908. <dt><code>--kill-at</code></dt>
  2909. <dd><p>If given, the stdcall suffixes (@<var>nn</var>) will be stripped from
  2910. symbols before they are exported.
  2911. [This option is specific to the i386 PE targeted port of the linker]
  2912. </p>
  2913. <a name="index-_002d_002dlarge_002daddress_002daware"></a>
  2914. </dd>
  2915. <dt><code>--large-address-aware</code></dt>
  2916. <dd><p>If given, the appropriate bit in the &ldquo;Characteristics&rdquo; field of the COFF
  2917. header is set to indicate that this executable supports virtual addresses
  2918. greater than 2 gigabytes. This should be used in conjunction with the /3GB
  2919. or /USERVA=<var>value</var> megabytes switch in the &ldquo;[operating systems]&rdquo;
  2920. section of the BOOT.INI. Otherwise, this bit has no effect.
  2921. [This option is specific to PE targeted ports of the linker]
  2922. </p>
  2923. <a name="index-_002d_002ddisable_002dlarge_002daddress_002daware"></a>
  2924. </dd>
  2925. <dt><code>--disable-large-address-aware</code></dt>
  2926. <dd><p>Reverts the effect of a previous &lsquo;<samp>--large-address-aware</samp>&rsquo; option.
  2927. This is useful if &lsquo;<samp>--large-address-aware</samp>&rsquo; is always set by the compiler
  2928. driver (e.g. Cygwin gcc) and the executable does not support virtual
  2929. addresses greater than 2 gigabytes.
  2930. [This option is specific to PE targeted ports of the linker]
  2931. </p>
  2932. <a name="index-_002d_002dmajor_002dimage_002dversion"></a>
  2933. </dd>
  2934. <dt><code>--major-image-version <var>value</var></code></dt>
  2935. <dd><p>Sets the major number of the &ldquo;image version&rdquo;. Defaults to 1.
  2936. [This option is specific to the i386 PE targeted port of the linker]
  2937. </p>
  2938. <a name="index-_002d_002dmajor_002dos_002dversion"></a>
  2939. </dd>
  2940. <dt><code>--major-os-version <var>value</var></code></dt>
  2941. <dd><p>Sets the major number of the &ldquo;os version&rdquo;. Defaults to 4.
  2942. [This option is specific to the i386 PE targeted port of the linker]
  2943. </p>
  2944. <a name="index-_002d_002dmajor_002dsubsystem_002dversion"></a>
  2945. </dd>
  2946. <dt><code>--major-subsystem-version <var>value</var></code></dt>
  2947. <dd><p>Sets the major number of the &ldquo;subsystem version&rdquo;. Defaults to 4.
  2948. [This option is specific to the i386 PE targeted port of the linker]
  2949. </p>
  2950. <a name="index-_002d_002dminor_002dimage_002dversion"></a>
  2951. </dd>
  2952. <dt><code>--minor-image-version <var>value</var></code></dt>
  2953. <dd><p>Sets the minor number of the &ldquo;image version&rdquo;. Defaults to 0.
  2954. [This option is specific to the i386 PE targeted port of the linker]
  2955. </p>
  2956. <a name="index-_002d_002dminor_002dos_002dversion"></a>
  2957. </dd>
  2958. <dt><code>--minor-os-version <var>value</var></code></dt>
  2959. <dd><p>Sets the minor number of the &ldquo;os version&rdquo;. Defaults to 0.
  2960. [This option is specific to the i386 PE targeted port of the linker]
  2961. </p>
  2962. <a name="index-_002d_002dminor_002dsubsystem_002dversion"></a>
  2963. </dd>
  2964. <dt><code>--minor-subsystem-version <var>value</var></code></dt>
  2965. <dd><p>Sets the minor number of the &ldquo;subsystem version&rdquo;. Defaults to 0.
  2966. [This option is specific to the i386 PE targeted port of the linker]
  2967. </p>
  2968. <a name="index-DEF-files_002c-creating"></a>
  2969. <a name="index-DLLs_002c-creating-1"></a>
  2970. <a name="index-_002d_002doutput_002ddef"></a>
  2971. </dd>
  2972. <dt><code>--output-def <var>file</var></code></dt>
  2973. <dd><p>The linker will create the file <var>file</var> which will contain a DEF
  2974. file corresponding to the DLL the linker is generating. This DEF file
  2975. (which should be called <code>*.def</code>) may be used to create an import
  2976. library with <code>dlltool</code> or may be used as a reference to
  2977. automatically or implicitly exported symbols.
  2978. [This option is specific to the i386 PE targeted port of the linker]
  2979. </p>
  2980. <a name="index-DLLs_002c-creating-2"></a>
  2981. <a name="index-_002d_002denable_002dauto_002dimage_002dbase"></a>
  2982. </dd>
  2983. <dt><code>--enable-auto-image-base</code></dt>
  2984. <dt><code>--enable-auto-image-base=<var>value</var></code></dt>
  2985. <dd><p>Automatically choose the image base for DLLs, optionally starting with base
  2986. <var>value</var>, unless one is specified using the <code>--image-base</code> argument.
  2987. By using a hash generated from the dllname to create unique image bases
  2988. for each DLL, in-memory collisions and relocations which can delay program
  2989. execution are avoided.
  2990. [This option is specific to the i386 PE targeted port of the linker]
  2991. </p>
  2992. <a name="index-_002d_002ddisable_002dauto_002dimage_002dbase"></a>
  2993. </dd>
  2994. <dt><code>--disable-auto-image-base</code></dt>
  2995. <dd><p>Do not automatically generate a unique image base. If there is no
  2996. user-specified image base (<code>--image-base</code>) then use the platform
  2997. default.
  2998. [This option is specific to the i386 PE targeted port of the linker]
  2999. </p>
  3000. <a name="index-DLLs_002c-linking-to"></a>
  3001. <a name="index-_002d_002ddll_002dsearch_002dprefix"></a>
  3002. </dd>
  3003. <dt><code>--dll-search-prefix <var>string</var></code></dt>
  3004. <dd><p>When linking dynamically to a dll without an import library,
  3005. search for <code>&lt;string&gt;&lt;basename&gt;.dll</code> in preference to
  3006. <code>lib&lt;basename&gt;.dll</code>. This behaviour allows easy distinction
  3007. between DLLs built for the various &quot;subplatforms&quot;: native, cygwin,
  3008. uwin, pw, etc. For instance, cygwin DLLs typically use
  3009. <code>--dll-search-prefix=cyg</code>.
  3010. [This option is specific to the i386 PE targeted port of the linker]
  3011. </p>
  3012. <a name="index-_002d_002denable_002dauto_002dimport"></a>
  3013. </dd>
  3014. <dt><code>--enable-auto-import</code></dt>
  3015. <dd><p>Do sophisticated linking of <code>_symbol</code> to <code>__imp__symbol</code> for
  3016. DATA imports from DLLs, thus making it possible to bypass the dllimport
  3017. mechanism on the user side and to reference unmangled symbol names.
  3018. [This option is specific to the i386 PE targeted port of the linker]
  3019. </p>
  3020. <p>The following remarks pertain to the original implementation of the
  3021. feature and are obsolete nowadays for Cygwin and MinGW targets.
  3022. </p>
  3023. <p>Note: Use of the &rsquo;auto-import&rsquo; extension will cause the text section
  3024. of the image file to be made writable. This does not conform to the
  3025. PE-COFF format specification published by Microsoft.
  3026. </p>
  3027. <p>Note - use of the &rsquo;auto-import&rsquo; extension will also cause read only
  3028. data which would normally be placed into the .rdata section to be
  3029. placed into the .data section instead. This is in order to work
  3030. around a problem with consts that is described here:
  3031. http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
  3032. </p>
  3033. <p>Using &rsquo;auto-import&rsquo; generally will &rsquo;just work&rsquo; &ndash; but sometimes you may
  3034. see this message:
  3035. </p>
  3036. <p>&quot;variable &rsquo;&lt;var&gt;&rsquo; can&rsquo;t be auto-imported. Please read the
  3037. documentation for ld&rsquo;s <code>--enable-auto-import</code> for details.&quot;
  3038. </p>
  3039. <p>This message occurs when some (sub)expression accesses an address
  3040. ultimately given by the sum of two constants (Win32 import tables only
  3041. allow one). Instances where this may occur include accesses to member
  3042. fields of struct variables imported from a DLL, as well as using a
  3043. constant index into an array variable imported from a DLL. Any
  3044. multiword variable (arrays, structs, long long, etc) may trigger
  3045. this error condition. However, regardless of the exact data type
  3046. of the offending exported variable, ld will always detect it, issue
  3047. the warning, and exit.
  3048. </p>
  3049. <p>There are several ways to address this difficulty, regardless of the
  3050. data type of the exported variable:
  3051. </p>
  3052. <p>One way is to use &ndash;enable-runtime-pseudo-reloc switch. This leaves the task
  3053. of adjusting references in your client code for runtime environment, so
  3054. this method works only when runtime environment supports this feature.
  3055. </p>
  3056. <p>A second solution is to force one of the &rsquo;constants&rsquo; to be a variable &ndash;
  3057. that is, unknown and un-optimizable at compile time. For arrays,
  3058. there are two possibilities: a) make the indexee (the array&rsquo;s address)
  3059. a variable, or b) make the &rsquo;constant&rsquo; index a variable. Thus:
  3060. </p>
  3061. <div class="example">
  3062. <pre class="example">extern type extern_array[];
  3063. extern_array[1] --&gt;
  3064. { volatile type *t=extern_array; t[1] }
  3065. </pre></div>
  3066. <p>or
  3067. </p>
  3068. <div class="example">
  3069. <pre class="example">extern type extern_array[];
  3070. extern_array[1] --&gt;
  3071. { volatile int t=1; extern_array[t] }
  3072. </pre></div>
  3073. <p>For structs (and most other multiword data types) the only option
  3074. is to make the struct itself (or the long long, or the ...) variable:
  3075. </p>
  3076. <div class="example">
  3077. <pre class="example">extern struct s extern_struct;
  3078. extern_struct.field --&gt;
  3079. { volatile struct s *t=&amp;extern_struct; t-&gt;field }
  3080. </pre></div>
  3081. <p>or
  3082. </p>
  3083. <div class="example">
  3084. <pre class="example">extern long long extern_ll;
  3085. extern_ll --&gt;
  3086. { volatile long long * local_ll=&amp;extern_ll; *local_ll }
  3087. </pre></div>
  3088. <p>A third method of dealing with this difficulty is to abandon
  3089. &rsquo;auto-import&rsquo; for the offending symbol and mark it with
  3090. <code>__declspec(dllimport)</code>. However, in practice that
  3091. requires using compile-time #defines to indicate whether you are
  3092. building a DLL, building client code that will link to the DLL, or
  3093. merely building/linking to a static library. In making the choice
  3094. between the various methods of resolving the &rsquo;direct address with
  3095. constant offset&rsquo; problem, you should consider typical real-world usage:
  3096. </p>
  3097. <p>Original:
  3098. </p><div class="example">
  3099. <pre class="example">--foo.h
  3100. extern int arr[];
  3101. --foo.c
  3102. #include &quot;foo.h&quot;
  3103. void main(int argc, char **argv){
  3104. printf(&quot;%d\n&quot;,arr[1]);
  3105. }
  3106. </pre></div>
  3107. <p>Solution 1:
  3108. </p><div class="example">
  3109. <pre class="example">--foo.h
  3110. extern int arr[];
  3111. --foo.c
  3112. #include &quot;foo.h&quot;
  3113. void main(int argc, char **argv){
  3114. /* This workaround is for win32 and cygwin; do not &quot;optimize&quot; */
  3115. volatile int *parr = arr;
  3116. printf(&quot;%d\n&quot;,parr[1]);
  3117. }
  3118. </pre></div>
  3119. <p>Solution 2:
  3120. </p><div class="example">
  3121. <pre class="example">--foo.h
  3122. /* Note: auto-export is assumed (no __declspec(dllexport)) */
  3123. #if (defined(_WIN32) || defined(__CYGWIN__)) &amp;&amp; \
  3124. !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
  3125. #define FOO_IMPORT __declspec(dllimport)
  3126. #else
  3127. #define FOO_IMPORT
  3128. #endif
  3129. extern FOO_IMPORT int arr[];
  3130. --foo.c
  3131. #include &quot;foo.h&quot;
  3132. void main(int argc, char **argv){
  3133. printf(&quot;%d\n&quot;,arr[1]);
  3134. }
  3135. </pre></div>
  3136. <p>A fourth way to avoid this problem is to re-code your
  3137. library to use a functional interface rather than a data interface
  3138. for the offending variables (e.g. set_foo() and get_foo() accessor
  3139. functions).
  3140. </p>
  3141. <a name="index-_002d_002ddisable_002dauto_002dimport"></a>
  3142. </dd>
  3143. <dt><code>--disable-auto-import</code></dt>
  3144. <dd><p>Do not attempt to do sophisticated linking of <code>_symbol</code> to
  3145. <code>__imp__symbol</code> for DATA imports from DLLs.
  3146. [This option is specific to the i386 PE targeted port of the linker]
  3147. </p>
  3148. <a name="index-_002d_002denable_002druntime_002dpseudo_002dreloc"></a>
  3149. </dd>
  3150. <dt><code>--enable-runtime-pseudo-reloc</code></dt>
  3151. <dd><p>If your code contains expressions described in &ndash;enable-auto-import section,
  3152. that is, DATA imports from DLL with non-zero offset, this switch will create
  3153. a vector of &rsquo;runtime pseudo relocations&rsquo; which can be used by runtime
  3154. environment to adjust references to such data in your client code.
  3155. [This option is specific to the i386 PE targeted port of the linker]
  3156. </p>
  3157. <a name="index-_002d_002ddisable_002druntime_002dpseudo_002dreloc"></a>
  3158. </dd>
  3159. <dt><code>--disable-runtime-pseudo-reloc</code></dt>
  3160. <dd><p>Do not create pseudo relocations for non-zero offset DATA imports from DLLs.
  3161. [This option is specific to the i386 PE targeted port of the linker]
  3162. </p>
  3163. <a name="index-_002d_002denable_002dextra_002dpe_002ddebug"></a>
  3164. </dd>
  3165. <dt><code>--enable-extra-pe-debug</code></dt>
  3166. <dd><p>Show additional debug info related to auto-import symbol thunking.
  3167. [This option is specific to the i386 PE targeted port of the linker]
  3168. </p>
  3169. <a name="index-_002d_002dsection_002dalignment"></a>
  3170. </dd>
  3171. <dt><code>--section-alignment</code></dt>
  3172. <dd><p>Sets the section alignment. Sections in memory will always begin at
  3173. addresses which are a multiple of this number. Defaults to 0x1000.
  3174. [This option is specific to the i386 PE targeted port of the linker]
  3175. </p>
  3176. <a name="index-stack-size"></a>
  3177. <a name="index-_002d_002dstack"></a>
  3178. </dd>
  3179. <dt><code>--stack <var>reserve</var></code></dt>
  3180. <dt><code>--stack <var>reserve</var>,<var>commit</var></code></dt>
  3181. <dd><p>Specify the number of bytes of memory to reserve (and optionally commit)
  3182. to be used as stack for this program. The default is 2MB reserved, 4K
  3183. committed.
  3184. [This option is specific to the i386 PE targeted port of the linker]
  3185. </p>
  3186. <a name="index-_002d_002dsubsystem"></a>
  3187. </dd>
  3188. <dt><code>--subsystem <var>which</var></code></dt>
  3189. <dt><code>--subsystem <var>which</var>:<var>major</var></code></dt>
  3190. <dt><code>--subsystem <var>which</var>:<var>major</var>.<var>minor</var></code></dt>
  3191. <dd><p>Specifies the subsystem under which your program will execute. The
  3192. legal values for <var>which</var> are <code>native</code>, <code>windows</code>,
  3193. <code>console</code>, <code>posix</code>, and <code>xbox</code>. You may optionally set
  3194. the subsystem version also. Numeric values are also accepted for
  3195. <var>which</var>.
  3196. [This option is specific to the i386 PE targeted port of the linker]
  3197. </p>
  3198. <p>The following options set flags in the <code>DllCharacteristics</code> field
  3199. of the PE file header:
  3200. [These options are specific to PE targeted ports of the linker]
  3201. </p>
  3202. <a name="index-_002d_002dhigh_002dentropy_002dva"></a>
  3203. </dd>
  3204. <dt><code>--high-entropy-va</code></dt>
  3205. <dt><code>--disable-high-entropy-va</code></dt>
  3206. <dd><p>Image is compatible with 64-bit address space layout randomization
  3207. (ASLR). This option is enabled by default for 64-bit PE images.
  3208. </p>
  3209. <p>This option also implies <samp>--dynamicbase</samp> and
  3210. <samp>--enable-reloc-section</samp>.
  3211. </p>
  3212. <a name="index-_002d_002ddynamicbase"></a>
  3213. </dd>
  3214. <dt><code>--dynamicbase</code></dt>
  3215. <dt><code>--disable-dynamicbase</code></dt>
  3216. <dd><p>The image base address may be relocated using address space layout
  3217. randomization (ASLR). This feature was introduced with MS Windows
  3218. Vista for i386 PE targets. This option is enabled by default but
  3219. can be disabled via the <samp>--disable-dynamicbase</samp> option.
  3220. This option also implies <samp>--enable-reloc-section</samp>.
  3221. </p>
  3222. <a name="index-_002d_002dforceinteg"></a>
  3223. </dd>
  3224. <dt><code>--forceinteg</code></dt>
  3225. <dt><code>--disable-forceinteg</code></dt>
  3226. <dd><p>Code integrity checks are enforced. This option is disabled by
  3227. default.
  3228. </p>
  3229. <a name="index-_002d_002dnxcompat"></a>
  3230. </dd>
  3231. <dt><code>--nxcompat</code></dt>
  3232. <dt><code>--disable-nxcompat</code></dt>
  3233. <dd><p>The image is compatible with the Data Execution Prevention.
  3234. This feature was introduced with MS Windows XP SP2 for i386 PE
  3235. targets. The option is enabled by default.
  3236. </p>
  3237. <a name="index-_002d_002dno_002disolation"></a>
  3238. </dd>
  3239. <dt><code>--no-isolation</code></dt>
  3240. <dt><code>--disable-no-isolation</code></dt>
  3241. <dd><p>Although the image understands isolation, do not isolate the image.
  3242. This option is disabled by default.
  3243. </p>
  3244. <a name="index-_002d_002dno_002dseh"></a>
  3245. </dd>
  3246. <dt><code>--no-seh</code></dt>
  3247. <dt><code>--disable-no-seh</code></dt>
  3248. <dd><p>The image does not use SEH. No SE handler may be called from
  3249. this image. This option is disabled by default.
  3250. </p>
  3251. <a name="index-_002d_002dno_002dbind"></a>
  3252. </dd>
  3253. <dt><code>--no-bind</code></dt>
  3254. <dt><code>--disable-no-bind</code></dt>
  3255. <dd><p>Do not bind this image. This option is disabled by default.
  3256. </p>
  3257. <a name="index-_002d_002dwdmdriver"></a>
  3258. </dd>
  3259. <dt><code>--wdmdriver</code></dt>
  3260. <dt><code>--disable-wdmdriver</code></dt>
  3261. <dd><p>The driver uses the MS Windows Driver Model. This option is disabled
  3262. by default.
  3263. </p>
  3264. <a name="index-_002d_002dtsaware"></a>
  3265. </dd>
  3266. <dt><code>--tsaware</code></dt>
  3267. <dt><code>--disable-tsaware</code></dt>
  3268. <dd><p>The image is Terminal Server aware. This option is disabled by
  3269. default.
  3270. </p>
  3271. <a name="index-_002d_002dinsert_002dtimestamp"></a>
  3272. </dd>
  3273. <dt><code>--insert-timestamp</code></dt>
  3274. <dt><code>--no-insert-timestamp</code></dt>
  3275. <dd><p>Insert a real timestamp into the image. This is the default behaviour
  3276. as it matches legacy code and it means that the image will work with
  3277. other, proprietary tools. The problem with this default is that it
  3278. will result in slightly different images being produced each time the
  3279. same sources are linked. The option <samp>--no-insert-timestamp</samp>
  3280. can be used to insert a zero value for the timestamp, this ensuring
  3281. that binaries produced from identical sources will compare
  3282. identically.
  3283. </p>
  3284. <a name="index-_002d_002denable_002dreloc_002dsection"></a>
  3285. </dd>
  3286. <dt><code>--enable-reloc-section</code></dt>
  3287. <dt><code>--disable-reloc-section</code></dt>
  3288. <dd><p>Create the base relocation table, which is necessary if the image
  3289. is loaded at a different image base than specified in the PE header.
  3290. This option is enabled by default.
  3291. </p></dd>
  3292. </dl>
  3293. <a name="Options-specific-to-C6X-uClinux-targets"></a>
  3294. <h4 class="subsection">2.1.2 Options specific to C6X uClinux targets</h4>
  3295. <p>The C6X uClinux target uses a binary format called DSBT to support shared
  3296. libraries. Each shared library in the system needs to have a unique index;
  3297. all executables use an index of 0.
  3298. </p>
  3299. <dl compact="compact">
  3300. <dd>
  3301. <a name="index-_002d_002ddsbt_002dsize"></a>
  3302. </dd>
  3303. <dt><code>--dsbt-size <var>size</var></code></dt>
  3304. <dd><p>This option sets the number of entries in the DSBT of the current executable
  3305. or shared library to <var>size</var>. The default is to create a table with 64
  3306. entries.
  3307. </p>
  3308. <a name="index-_002d_002ddsbt_002dindex"></a>
  3309. </dd>
  3310. <dt><code>--dsbt-index <var>index</var></code></dt>
  3311. <dd><p>This option sets the DSBT index of the current executable or shared library
  3312. to <var>index</var>. The default is 0, which is appropriate for generating
  3313. executables. If a shared library is generated with a DSBT index of 0, the
  3314. <code>R_C6000_DSBT_INDEX</code> relocs are copied into the output file.
  3315. </p>
  3316. <a name="index-_002d_002dno_002dmerge_002dexidx_002dentries"></a>
  3317. <p>The &lsquo;<samp>--no-merge-exidx-entries</samp>&rsquo; switch disables the merging of adjacent
  3318. exidx entries in frame unwind info.
  3319. </p>
  3320. </dd>
  3321. </dl>
  3322. <a name="Options-specific-to-C_002dSKY-targets"></a>
  3323. <h4 class="subsection">2.1.3 Options specific to C-SKY targets</h4>
  3324. <dl compact="compact">
  3325. <dd>
  3326. <a name="index-_002d_002dbranch_002dstub-on-C_002dSKY"></a>
  3327. </dd>
  3328. <dt><code>--branch-stub</code></dt>
  3329. <dd><p>This option enables linker branch relaxation by inserting branch stub
  3330. sections when needed to extend the range of branches. This option is
  3331. usually not required since C-SKY supports branch and call instructions that
  3332. can access the full memory range and branch relaxation is normally handled by
  3333. the compiler or assembler.
  3334. </p>
  3335. <a name="index-_002d_002dstub_002dgroup_002dsize-on-C_002dSKY"></a>
  3336. </dd>
  3337. <dt><code>--stub-group-size=<var>N</var></code></dt>
  3338. <dd><p>This option allows finer control of linker branch stub creation.
  3339. It sets the maximum size of a group of input sections that can
  3340. be handled by one stub section. A negative value of <var>N</var> locates
  3341. stub sections after their branches, while a positive value allows stub
  3342. sections to appear either before or after the branches. Values of
  3343. &lsquo;<samp>1</samp>&rsquo; or &lsquo;<samp>-1</samp>&rsquo; indicate that the
  3344. linker should choose suitable defaults.
  3345. </p>
  3346. </dd>
  3347. </dl>
  3348. <a name="Options-specific-to-Motorola-68HC11-and-68HC12-targets"></a>
  3349. <h4 class="subsection">2.1.4 Options specific to Motorola 68HC11 and 68HC12 targets</h4>
  3350. <p>The 68HC11 and 68HC12 linkers support specific options to control the
  3351. memory bank switching mapping and trampoline code generation.
  3352. </p>
  3353. <dl compact="compact">
  3354. <dd>
  3355. <a name="index-_002d_002dno_002dtrampoline"></a>
  3356. </dd>
  3357. <dt><code>--no-trampoline</code></dt>
  3358. <dd><p>This option disables the generation of trampoline. By default a trampoline
  3359. is generated for each far function which is called using a <code>jsr</code>
  3360. instruction (this happens when a pointer to a far function is taken).
  3361. </p>
  3362. <a name="index-_002d_002dbank_002dwindow"></a>
  3363. </dd>
  3364. <dt><code>--bank-window <var>name</var></code></dt>
  3365. <dd><p>This option indicates to the linker the name of the memory region in
  3366. the &lsquo;<samp>MEMORY</samp>&rsquo; specification that describes the memory bank window.
  3367. The definition of such region is then used by the linker to compute
  3368. paging and addresses within the memory window.
  3369. </p>
  3370. </dd>
  3371. </dl>
  3372. <a name="Options-specific-to-Motorola-68K-target"></a>
  3373. <h4 class="subsection">2.1.5 Options specific to Motorola 68K target</h4>
  3374. <p>The following options are supported to control handling of GOT generation
  3375. when linking for 68K targets.
  3376. </p>
  3377. <dl compact="compact">
  3378. <dd>
  3379. <a name="index-_002d_002dgot"></a>
  3380. </dd>
  3381. <dt><code>--got=<var>type</var></code></dt>
  3382. <dd><p>This option tells the linker which GOT generation scheme to use.
  3383. <var>type</var> should be one of &lsquo;<samp>single</samp>&rsquo;, &lsquo;<samp>negative</samp>&rsquo;,
  3384. &lsquo;<samp>multigot</samp>&rsquo; or &lsquo;<samp>target</samp>&rsquo;. For more information refer to the
  3385. Info entry for <samp>ld</samp>.
  3386. </p>
  3387. </dd>
  3388. </dl>
  3389. <a name="Options-specific-to-MIPS-targets"></a>
  3390. <h4 class="subsection">2.1.6 Options specific to MIPS targets</h4>
  3391. <p>The following options are supported to control microMIPS instruction
  3392. generation and branch relocation checks for ISA mode transitions when
  3393. linking for MIPS targets.
  3394. </p>
  3395. <dl compact="compact">
  3396. <dd>
  3397. <a name="index-_002d_002dinsn32"></a>
  3398. </dd>
  3399. <dt><code>--insn32</code></dt>
  3400. <dd><a name="index-_002d_002dno_002dinsn32"></a>
  3401. </dd>
  3402. <dt><code>--no-insn32</code></dt>
  3403. <dd><p>These options control the choice of microMIPS instructions used in code
  3404. generated by the linker, such as that in the PLT or lazy binding stubs,
  3405. or in relaxation. If &lsquo;<samp>--insn32</samp>&rsquo; is used, then the linker only uses
  3406. 32-bit instruction encodings. By default or if &lsquo;<samp>--no-insn32</samp>&rsquo; is
  3407. used, all instruction encodings are used, including 16-bit ones where
  3408. possible.
  3409. </p>
  3410. <a name="index-_002d_002dignore_002dbranch_002disa"></a>
  3411. </dd>
  3412. <dt><code>--ignore-branch-isa</code></dt>
  3413. <dd><a name="index-_002d_002dno_002dignore_002dbranch_002disa"></a>
  3414. </dd>
  3415. <dt><code>--no-ignore-branch-isa</code></dt>
  3416. <dd><p>These options control branch relocation checks for invalid ISA mode
  3417. transitions. If &lsquo;<samp>--ignore-branch-isa</samp>&rsquo; is used, then the linker
  3418. accepts any branch relocations and any ISA mode transition required
  3419. is lost in relocation calculation, except for some cases of <code>BAL</code>
  3420. instructions which meet relaxation conditions and are converted to
  3421. equivalent <code>JALX</code> instructions as the associated relocation is
  3422. calculated. By default or if &lsquo;<samp>--no-ignore-branch-isa</samp>&rsquo; is used
  3423. a check is made causing the loss of an ISA mode transition to produce
  3424. an error.
  3425. </p>
  3426. <a name="index-_002d_002dcompact_002dbranches"></a>
  3427. </dd>
  3428. <dt><code>--compact-branches</code></dt>
  3429. <dd><a name="index-_002d_002dno_002dcompact_002dbranches"></a>
  3430. </dd>
  3431. <dt><code>--no-compact-branches</code></dt>
  3432. <dd><p>These options control the generation of compact instructions by the linker
  3433. in the PLT entries for MIPS R6.
  3434. </p>
  3435. </dd>
  3436. </dl>
  3437. <a name="Options-specific-to-PDP11-targets"></a>
  3438. <h4 class="subsection">2.1.7 Options specific to PDP11 targets</h4>
  3439. <p>For the pdp11-aout target, three variants of the output format can be
  3440. produced as selected by the following options. The default variant
  3441. for pdp11-aout is the &lsquo;<samp>--omagic</samp>&rsquo; option, whereas for other
  3442. targets &lsquo;<samp>--nmagic</samp>&rsquo; is the default. The &lsquo;<samp>--imagic</samp>&rsquo; option is
  3443. defined only for the pdp11-aout target, while the others are described
  3444. here as they apply to the pdp11-aout target.
  3445. </p>
  3446. <dl compact="compact">
  3447. <dd>
  3448. <a name="index-_002dN-1"></a>
  3449. </dd>
  3450. <dt><code>-N</code></dt>
  3451. <dd><a name="index-_002d_002domagic-1"></a>
  3452. </dd>
  3453. <dt><code>--omagic</code></dt>
  3454. <dd>
  3455. <p>Mark the output as <code>OMAGIC</code> (0407) in the <samp>a.out</samp> header to
  3456. indicate that the text segment is not to be write-protected and
  3457. shared. Since the text and data sections are both readable and
  3458. writable, the data section is allocated immediately contiguous after
  3459. the text segment. This is the oldest format for PDP11 executable
  3460. programs and is the default for <code>ld</code> on PDP11 Unix systems
  3461. from the beginning through 2.11BSD.
  3462. </p>
  3463. <a name="index-_002dn-1"></a>
  3464. </dd>
  3465. <dt><code>-n</code></dt>
  3466. <dd><a name="index-_002d_002dnmagic-1"></a>
  3467. </dd>
  3468. <dt><code>--nmagic</code></dt>
  3469. <dd>
  3470. <p>Mark the output as <code>NMAGIC</code> (0410) in the <samp>a.out</samp> header to
  3471. indicate that when the output file is executed, the text portion will
  3472. be read-only and shareable among all processes executing the same
  3473. file. This involves moving the data areas up to the first possible 8K
  3474. byte page boundary following the end of the text. This option creates
  3475. a <em>pure executable</em> format.
  3476. </p>
  3477. <a name="index-_002dz"></a>
  3478. </dd>
  3479. <dt><code>-z</code></dt>
  3480. <dd><a name="index-_002d_002dimagic"></a>
  3481. </dd>
  3482. <dt><code>--imagic</code></dt>
  3483. <dd>
  3484. <p>Mark the output as <code>IMAGIC</code> (0411) in the <samp>a.out</samp> header to
  3485. indicate that when the output file is executed, the program text and
  3486. data areas will be loaded into separate address spaces using the split
  3487. instruction and data space feature of the memory management unit in
  3488. larger models of the PDP11. This doubles the address space available
  3489. to the program. The text segment is again pure, write-protected, and
  3490. shareable. The only difference in the output format between this
  3491. option and the others, besides the magic number, is that both the text
  3492. and data sections start at location 0. The &lsquo;<samp>-z</samp>&rsquo; option selected
  3493. this format in 2.11BSD. This option creates a <em>separate
  3494. executable</em> format.
  3495. </p>
  3496. <a name="index-_002d_002dno_002domagic-1"></a>
  3497. </dd>
  3498. <dt><code>--no-omagic</code></dt>
  3499. <dd>
  3500. <p>Equivalent to &lsquo;<samp>--nmagic</samp>&rsquo; for pdp11-aout.
  3501. </p>
  3502. </dd>
  3503. </dl>
  3504. <hr>
  3505. <div class="header">
  3506. <p>
  3507. 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>
  3508. </div>
  3509. </body>
  3510. </html>