blob: d8099129ba61b0e27f08854dd8e13e4ad545fd4d [file] [log] [blame]
<html lang="en">
<head>
<title>Format Commands - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Simple-Commands.html#Simple-Commands" title="Simple Commands">
<link rel="prev" href="File-Commands.html#File-Commands" title="File Commands">
<link rel="next" href="REGION_005fALIAS.html#REGION_005fALIAS" title="REGION_ALIAS">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU linker LD
(Sourcery G++ Lite 2011.03-41)
version 2.20.51.
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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''.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
<link rel="stylesheet" type="text/css" href="../cs.css">
</head>
<body>
<div class="node">
<a name="Format-Commands"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="REGION_005fALIAS.html#REGION_005fALIAS">REGION_ALIAS</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="File-Commands.html#File-Commands">File Commands</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Simple-Commands.html#Simple-Commands">Simple Commands</a>
<hr>
</div>
<h4 class="subsection">3.4.3 Commands Dealing with Object File Formats</h4>
<p>A couple of linker script commands deal with object file formats.
<dl>
<dt><code>OUTPUT_FORMAT(</code><var>bfdname</var><code>)</code><dt><code>OUTPUT_FORMAT(</code><var>default</var><code>, </code><var>big</var><code>, </code><var>little</var><code>)</code><dd><a name="index-OUTPUT_005fFORMAT_0028_0040var_007bbfdname_007d_0029-364"></a><a name="index-output-file-format-in-linker-script-365"></a>The <code>OUTPUT_FORMAT</code> command names the BFD format to use for the
output file (see <a href="BFD.html#BFD">BFD</a>). Using <code>OUTPUT_FORMAT(</code><var>bfdname</var><code>)</code> is
exactly like using &lsquo;<samp><span class="samp">--oformat </span><var>bfdname</var></samp>&rsquo; on the command line
(see <a href="Options.html#Options">Command Line Options</a>). If both are used, the command
line option takes precedence.
<p>You can use <code>OUTPUT_FORMAT</code> with three arguments to use different
formats based on the &lsquo;<samp><span class="samp">-EB</span></samp>&rsquo; and &lsquo;<samp><span class="samp">-EL</span></samp>&rsquo; command line options.
This permits the linker script to set the output format based on the
desired endianness.
<p>If neither &lsquo;<samp><span class="samp">-EB</span></samp>&rsquo; nor &lsquo;<samp><span class="samp">-EL</span></samp>&rsquo; are used, then the output format
will be the first argument, <var>default</var>. If &lsquo;<samp><span class="samp">-EB</span></samp>&rsquo; is used, the
output format will be the second argument, <var>big</var>. If &lsquo;<samp><span class="samp">-EL</span></samp>&rsquo; is
used, the output format will be the third argument, <var>little</var>.
<p>For example, the default linker script for the MIPS ELF target uses this
command:
<pre class="smallexample"> OUTPUT_FORMAT(elf32-bigmips, elf32-bigmips, elf32-littlemips)
</pre>
<p>This says that the default format for the output file is
&lsquo;<samp><span class="samp">elf32-bigmips</span></samp>&rsquo;, but if the user uses the &lsquo;<samp><span class="samp">-EL</span></samp>&rsquo; command line
option, the output file will be created in the &lsquo;<samp><span class="samp">elf32-littlemips</span></samp>&rsquo;
format.
<br><dt><code>TARGET(</code><var>bfdname</var><code>)</code><dd><a name="index-TARGET_0028_0040var_007bbfdname_007d_0029-366"></a><a name="index-input-file-format-in-linker-script-367"></a>The <code>TARGET</code> command names the BFD format to use when reading input
files. It affects subsequent <code>INPUT</code> and <code>GROUP</code> commands.
This command is like using &lsquo;<samp><span class="samp">-b </span><var>bfdname</var></samp>&rsquo; on the command line
(see <a href="Options.html#Options">Command Line Options</a>). If the <code>TARGET</code> command
is used but <code>OUTPUT_FORMAT</code> is not, then the last <code>TARGET</code>
command is also used to set the format for the output file. See <a href="BFD.html#BFD">BFD</a>.
</dl>
</body></html>