06.02.2013 Views

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9.2 Typical use cases for using ld scripts with armlink<br />

9.2.1 See also<br />

The following are typical use cases for using ld scripts with armlink:<br />

GNU ld script support in armlink<br />

Wrapping libraries<br />

Some libraries have a dynamic and static part. An ld script loads both libraries in<br />

<strong>the</strong> correct order with <strong>the</strong> INPUT command, for example:<br />

INPUT(libstatic.a)<br />

INPUT(libdynamic.so)<br />

This script instructs <strong>the</strong> linker to load libstatic.a <strong>the</strong>n libdynamic.so<br />

Partial linking with <strong>the</strong> --ldpartial option<br />

An ld script can be given to control how <strong>the</strong> linker combines sections, for<br />

example:<br />

SECTIONS<br />

{<br />

.text :0<br />

{<br />

*(.text)<br />

*(mysection)<br />

}<br />

}<br />

This script instructs <strong>the</strong> linker to combine mysection and all <strong>the</strong> .text sections into<br />

a single .text output section.<br />

Fine control over an <strong>ARM</strong> linux link<br />

You might want to combine sections toge<strong>the</strong>r in a different order to that given by<br />

<strong>the</strong> default linker script. Also, you might want <strong>the</strong> linker to define symbols at<br />

specific addresses. This information can be given by a custom linker script.<br />

Note<br />

To successfully produce a file that can be run on <strong>ARM</strong> Linux your image must<br />

include some output sections to contain <strong>the</strong> meta-data that <strong>the</strong> dynamic loader can<br />

use to load <strong>the</strong> file. It is recommended that you start with one of <strong>the</strong> example<br />

scripts and modify it to suit your purpose.<br />

Concepts<br />

• Example GNU ld script for linking an <strong>ARM</strong> Linux executable on page 9-12<br />

• Example GNU ld script for linking an <strong>ARM</strong> Linux shared object on page 9-14<br />

• Example GNU ld script for linking ld --ldpartial object on page 9-16.<br />

Reference<br />

<strong>Linker</strong> Reference:<br />

• --ldpartial on page 2-94<br />

• --linker_script=ld_script on page 2-100<br />

• --sysroot=path on page 2-169.<br />

<strong>ARM</strong> DUI 0474C Copyright © 2010-2011 <strong>ARM</strong>. All rights reserved. 9-3<br />

ID080411 Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!