blob: b67a1253787049fc269d19457760ae0d12fafc21 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This file documents the GNU linker LD
(Linaro_Binutils-2017.01)
version 2.24.0.
Copyright (C) 1991-2013 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled "GNU Free Documentation License". -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>LD: ARM</title>
<meta name="description" content="LD: ARM">
<meta name="keywords" content="LD: ARM">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="LD-Index.html#LD-Index" rel="index" title="LD Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Machine-Dependent.html#Machine-Dependent" rel="up" title="Machine Dependent">
<link href="HPPA-ELF32.html#HPPA-ELF32" rel="next" title="HPPA ELF32">
<link href="M68HC11_002f68HC12.html#M68HC11_002f68HC12" rel="prev" title="M68HC11/68HC12">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="ARM"></a>
<div class="header">
<p>
Next: <a href="HPPA-ELF32.html#HPPA-ELF32" accesskey="n" rel="next">HPPA ELF32</a>, Previous: <a href="M68HC11_002f68HC12.html#M68HC11_002f68HC12" accesskey="p" rel="prev">M68HC11/68HC12</a>, Up: <a href="Machine-Dependent.html#Machine-Dependent" accesskey="u" rel="up">Machine Dependent</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>
</div>
<hr>
<a name="ld-and-the-ARM-family"></a>
<h3 class="section">4.4 <code>ld</code> and the ARM family</h3>
<a name="index-ARM-interworking-support"></a>
<a name="index-_002d_002dsupport_002dold_002dcode"></a>
<p>For the ARM, <code>ld</code> will generate code stubs to allow functions calls
between ARM and Thumb code. These stubs only work with code that has
been compiled and assembled with the &lsquo;<samp>-mthumb-interwork</samp>&rsquo; command
line option. If it is necessary to link with old ARM object files or
libraries, which have not been compiled with the -mthumb-interwork
option then the &lsquo;<samp>--support-old-code</samp>&rsquo; command line switch should be
given to the linker. This will make it generate larger stub functions
which will work with non-interworking aware ARM code. Note, however,
the linker does not support generating stubs for function calls to
non-interworking aware Thumb code.
</p>
<a name="index-thumb-entry-point"></a>
<a name="index-entry-point_002c-thumb"></a>
<a name="index-_002d_002dthumb_002dentry_003dentry"></a>
<p>The &lsquo;<samp>--thumb-entry</samp>&rsquo; switch is a duplicate of the generic
&lsquo;<samp>--entry</samp>&rsquo; switch, in that it sets the program&rsquo;s starting address.
But it also sets the bottom bit of the address, so that it can be
branched to using a BX instruction, and the program will start
executing in Thumb mode straight away.
</p>
<a name="index-PE-import-table-prefixing"></a>
<a name="index-_002d_002duse_002dnul_002dprefixed_002dimport_002dtables"></a>
<p>The &lsquo;<samp>--use-nul-prefixed-import-tables</samp>&rsquo; switch is specifying, that
the import tables idata4 and idata5 have to be generated with a zero
element prefix for import libraries. This is the old style to generate
import tables. By default this option is turned off.
</p>
<a name="index-BE8"></a>
<a name="index-_002d_002dbe8"></a>
<p>The &lsquo;<samp>--be8</samp>&rsquo; switch instructs <code>ld</code> to generate BE8 format
executables. This option is only valid when linking big-endian objects.
The resulting image will contain big-endian data and little-endian code.
</p>
<a name="index-TARGET1"></a>
<a name="index-_002d_002dtarget1_002drel"></a>
<a name="index-_002d_002dtarget1_002dabs"></a>
<p>The &lsquo;<samp>R_ARM_TARGET1</samp>&rsquo; relocation is typically used for entries in the
&lsquo;<samp>.init_array</samp>&rsquo; section. It is interpreted as either &lsquo;<samp>R_ARM_REL32</samp>&rsquo;
or &lsquo;<samp>R_ARM_ABS32</samp>&rsquo;, depending on the target. The &lsquo;<samp>--target1-rel</samp>&rsquo;
and &lsquo;<samp>--target1-abs</samp>&rsquo; switches override the default.
</p>
<a name="index-TARGET2"></a>
<a name="index-_002d_002dtarget2_003dtype"></a>
<p>The &lsquo;<samp>--target2=type</samp>&rsquo; switch overrides the default definition of the
&lsquo;<samp>R_ARM_TARGET2</samp>&rsquo; relocation. Valid values for &lsquo;<samp>type</samp>&rsquo;, their
meanings, and target defaults are as follows:
</p><dl compact="compact">
<dt>&lsquo;<samp>rel</samp>&rsquo;</dt>
<dd><p>&lsquo;<samp>R_ARM_REL32</samp>&rsquo; (arm*-*-elf, arm*-*-eabi)
</p></dd>
<dt>&lsquo;<samp>abs</samp>&rsquo;</dt>
<dd><p>&lsquo;<samp>R_ARM_ABS32</samp>&rsquo; (arm*-*-symbianelf)
</p></dd>
<dt>&lsquo;<samp>got-rel</samp>&rsquo;</dt>
<dd><p>&lsquo;<samp>R_ARM_GOT_PREL</samp>&rsquo; (arm*-*-linux, arm*-*-*bsd)
</p></dd>
</dl>
<a name="index-FIX_005fV4BX"></a>
<a name="index-_002d_002dfix_002dv4bx"></a>
<p>The &lsquo;<samp>R_ARM_V4BX</samp>&rsquo; relocation (defined by the ARM AAELF
specification) enables objects compiled for the ARMv4 architecture to be
interworking-safe when linked with other objects compiled for ARMv4t, but
also allows pure ARMv4 binaries to be built from the same ARMv4 objects.
</p>
<p>In the latter case, the switch <samp>--fix-v4bx</samp> must be passed to the
linker, which causes v4t <code>BX rM</code> instructions to be rewritten as
<code>MOV PC,rM</code>, since v4 processors do not have a <code>BX</code> instruction.
</p>
<p>In the former case, the switch should not be used, and &lsquo;<samp>R_ARM_V4BX</samp>&rsquo;
relocations are ignored.
</p>
<a name="index-FIX_005fV4BX_005fINTERWORKING"></a>
<a name="index-_002d_002dfix_002dv4bx_002dinterworking"></a>
<p>Replace <code>BX rM</code> instructions identified by &lsquo;<samp>R_ARM_V4BX</samp>&rsquo;
relocations with a branch to the following veneer:
</p>
<div class="smallexample">
<pre class="smallexample">TST rM, #1
MOVEQ PC, rM
BX Rn
</pre></div>
<p>This allows generation of libraries/applications that work on ARMv4 cores
and are still interworking safe. Note that the above veneer clobbers the
condition flags, so may cause incorrect program behavior in rare cases.
</p>
<a name="index-USE_005fBLX"></a>
<a name="index-_002d_002duse_002dblx"></a>
<p>The &lsquo;<samp>--use-blx</samp>&rsquo; switch enables the linker to use ARM/Thumb
BLX instructions (available on ARMv5t and above) in various
situations. Currently it is used to perform calls via the PLT from Thumb
code using BLX rather than using BX and a mode-switching stub before
each PLT entry. This should lead to such calls executing slightly faster.
</p>
<p>This option is enabled implicitly for SymbianOS, so there is no need to
specify it if you are using that target.
</p>
<a name="index-VFP11_005fDENORM_005fFIX"></a>
<a name="index-_002d_002dvfp11_002ddenorm_002dfix"></a>
<p>The &lsquo;<samp>--vfp11-denorm-fix</samp>&rsquo; switch enables a link-time workaround for a
bug in certain VFP11 coprocessor hardware, which sometimes allows
instructions with denorm operands (which must be handled by support code)
to have those operands overwritten by subsequent instructions before
the support code can read the intended values.
</p>
<p>The bug may be avoided in scalar mode if you allow at least one
intervening instruction between a VFP11 instruction which uses a register
and another instruction which writes to the same register, or at least two
intervening instructions if vector mode is in use. The bug only affects
full-compliance floating-point mode: you do not need this workaround if
you are using &quot;runfast&quot; mode. Please contact ARM for further details.
</p>
<p>If you know you are using buggy VFP11 hardware, you can
enable this workaround by specifying the linker option
&lsquo;<samp>--vfp-denorm-fix=scalar</samp>&rsquo; if you are using the VFP11 scalar
mode only, or &lsquo;<samp>--vfp-denorm-fix=vector</samp>&rsquo; if you are using
vector mode (the latter also works for scalar code). The default is
&lsquo;<samp>--vfp-denorm-fix=none</samp>&rsquo;.
</p>
<p>If the workaround is enabled, instructions are scanned for
potentially-troublesome sequences, and a veneer is created for each
such sequence which may trigger the erratum. The veneer consists of the
first instruction of the sequence and a branch back to the subsequent
instruction. The original instruction is then replaced with a branch to
the veneer. The extra cycles required to call and return from the veneer
are sufficient to avoid the erratum in both the scalar and vector cases.
</p>
<a name="index-ARM1176-erratum-workaround"></a>
<a name="index-_002d_002dfix_002darm1176"></a>
<a name="index-_002d_002dno_002dfix_002darm1176"></a>
<p>The &lsquo;<samp>--fix-arm1176</samp>&rsquo; switch enables a link-time workaround for an erratum
in certain ARM1176 processors. The workaround is enabled by default if you
are targeting ARM v6 (excluding ARM v6T2) or earlier. It can be disabled
unconditionally by specifying &lsquo;<samp>--no-fix-arm1176</samp>&rsquo;.
</p>
<p>Further information is available in the &ldquo;ARM1176JZ-S and ARM1176JZF-S
Programmer Advice Notice&rdquo; available on the ARM documentation website at:
http://infocenter.arm.com/.
</p>
<a name="index-NO_005fENUM_005fSIZE_005fWARNING"></a>
<a name="index-_002d_002dno_002denum_002dsize_002dwarning"></a>
<p>The <samp>--no-enum-size-warning</samp> switch prevents the linker from
warning when linking object files that specify incompatible EABI
enumeration size attributes. For example, with this switch enabled,
linking of an object file using 32-bit enumeration values with another
using enumeration values fitted into the smallest possible space will
not be diagnosed.
</p>
<a name="index-NO_005fWCHAR_005fSIZE_005fWARNING"></a>
<a name="index-_002d_002dno_002dwchar_002dsize_002dwarning"></a>
<p>The <samp>--no-wchar-size-warning</samp> switch prevents the linker from
warning when linking object files that specify incompatible EABI
<code>wchar_t</code> size attributes. For example, with this switch enabled,
linking of an object file using 32-bit <code>wchar_t</code> values with another
using 16-bit <code>wchar_t</code> values will not be diagnosed.
</p>
<a name="index-PIC_005fVENEER"></a>
<a name="index-_002d_002dpic_002dveneer"></a>
<p>The &lsquo;<samp>--pic-veneer</samp>&rsquo; switch makes the linker use PIC sequences for
ARM/Thumb interworking veneers, even if the rest of the binary
is not PIC. This avoids problems on uClinux targets where
&lsquo;<samp>--emit-relocs</samp>&rsquo; is used to generate relocatable binaries.
</p>
<a name="index-STUB_005fGROUP_005fSIZE"></a>
<a name="index-_002d_002dstub_002dgroup_002dsize_003dN"></a>
<p>The linker will automatically generate and insert small sequences of
code into a linked ARM ELF executable whenever an attempt is made to
perform a function call to a symbol that is too far away. The
placement of these sequences of instructions - called stubs - is
controlled by the command line option <samp>--stub-group-size=N</samp>.
The placement is important because a poor choice can create a need for
duplicate stubs, increasing the code size. The linker will try to
group stubs together in order to reduce interruptions to the flow of
code, but it needs guidance as to how big these groups should be and
where they should be placed.
</p>
<p>The value of &lsquo;<samp>N</samp>&rsquo;, the parameter to the
<samp>--stub-group-size=</samp> option controls where the stub groups are
placed. If it is negative then all stubs are placed after the first
branch that needs them. If it is positive then the stubs can be
placed either before or after the branches that need them. If the
value of &lsquo;<samp>N</samp>&rsquo; is 1 (either +1 or -1) then the linker will choose
exactly where to place groups of stubs, using its built in heuristics.
A value of &lsquo;<samp>N</samp>&rsquo; greater than 1 (or smaller than -1) tells the
linker that a single group of stubs can service at most &lsquo;<samp>N</samp>&rsquo; bytes
from the input sections.
</p>
<p>The default, if <samp>--stub-group-size=</samp> is not specified, is
&lsquo;<samp>N = +1</samp>&rsquo;.
</p>
<p>Farcalls stubs insertion is fully supported for the ARM-EABI target
only, because it relies on object files properties not present
otherwise.
</p>
<hr>
<div class="header">
<p>
Next: <a href="HPPA-ELF32.html#HPPA-ELF32" accesskey="n" rel="next">HPPA ELF32</a>, Previous: <a href="M68HC11_002f68HC12.html#M68HC11_002f68HC12" accesskey="p" rel="prev">M68HC11/68HC12</a>, Up: <a href="Machine-Dependent.html#Machine-Dependent" accesskey="u" rel="up">Machine Dependent</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>
</div>
</body>
</html>