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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8.34 <strong>Using</strong> preprocessing commands in a scatter file<br />

8.34.1 See also<br />

<strong>Using</strong> scatter files<br />

You can pass a scatter file through a C preprocessor. This permits access to all <strong>the</strong> features of<br />

<strong>the</strong> C preprocessor.<br />

Use <strong>the</strong> first line in <strong>the</strong> scatter file to specify a preprocessor command that <strong>the</strong> linker invokes to<br />

process <strong>the</strong> file. The command is of <strong>the</strong> form:<br />

#! preprocessor [pre_processor_flags]<br />

Most typically <strong>the</strong> command is #! armcc -E. This passes <strong>the</strong> scatter file through <strong>the</strong> armcc<br />

preprocessor.<br />

You can:<br />

• add preprocessing directives to <strong>the</strong> top of <strong>the</strong> scatter file<br />

• use simple expression evaluation in <strong>the</strong> scatter file.<br />

For example, a scatter file, file.scat, might contain:<br />

#! armcc -E<br />

#define ADDRESS 0x20000000<br />

#include "include_file_1.h"<br />

lr1 ADDRESS<br />

{<br />

...<br />

}<br />

The linker parses <strong>the</strong> preprocessed scatter file and treats <strong>the</strong> directives as comments.<br />

You can also use preprocessing of a scatter file in conjunction with <strong>the</strong> --predefine<br />

command-line option. For this example:<br />

1. Modify file.scat to delete <strong>the</strong> directive #define ADDRESS 0x20000000.<br />

2. Specify <strong>the</strong> command:<br />

armlink --predefine="-DADDRESS=0x20000000" --scatter=file.scat<br />

Concepts<br />

• Expression evaluation in scatter files on page 8-58.<br />

Reference<br />

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

• --predefine="string" on page 2-123.<br />

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

ID080411 Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!