Analog Devices, Inc. reserves the right to change this product without
prior notice. Information furnished by Analog Devices is believed to be
accurate and reliable. However, no responsibility is assumed by Analog
Devices for its use; nor for any infringement of patents or other rights of
third parties which may result from its use. No license is granted by implication or otherwise under the patent rights of Analog Devices, Inc.
Trademark and Service Mark Notice
The Analog Devices logo, the CROSSCORE logo, VisualDSP++,
Blackfin, SHARC, TigerSHARC, and EZ-KIT Lite are registered trademarks of Analog Devices, Inc.
All other brand and product names are trademarks or service marks of
their respective owners.
CONTENTS
PREFACE
Purpose of This Manual ................................................................. xix
Intended Audience ......................................................................... xix
Manual Contents ............................................................................ xx
What’s New in This Manual ........................................................... xxi
Technical or Customer Support ..................................................... xxii
Linking for Overlay Memory ...................................................... D-13
LDF PROGRAMMING EXAMPLES FOR BLACKFIN
VisualDSP++ 4.0 Linker and Utilities Manual xvii
PROCESSORS
Linking for a Single-Processor System ........................................... E-2
Linking Large Uninitialized or Zero-initialized Variables ................ E-4
Linking for Assembly Source File .................................................. E-6
Linking for C Source File – Example 1 .......................................... E-8
Linking for Complex C Source File – Example 2 ......................... E-11
Linking for Overlay Memory ...................................................... E-17
INDEX
xviiiVisualDSP++ 4.0 Linker and Utilities Manual
PREFACE
Thank you for purchasing Analog Devices development software for digital signal processors (DSPs).
Purpose of This Manual
The VisualDSP++ 4.0 Linker and Utilities Manual contains information
about the linker and utilities programs for 16-bit fixed-point Blackfin®
(ADSP-BFxxx) processors, and 32-bit (floating-point and fixed-point)
TigerSHARC® (ADSP-TSxxx) and SHARC® (ADSP-21xxx) processors
which set a new standard of performance for digital signal processors,
combining multiple computation units for floating-point and fixed-point
processing as well as wide word width.
This manual provides information on the linking process and describes
the syntax for the linker’s command language—a scripting language that
the linker reads from the linker description file. The manual leads you
through using the linker, archiver, and utilities to produce DSP programs
and provides reference information on the file utility software.
Intended Audience
The primary audience for this manual is a programmer who is familiar
with Analog Devices processors. This manual assumes that the audience
has a working knowledge of the appropriate processor architecture and
instruction set. Programmers who are unfamiliar with Analog Devices
VisualDSP++ 4.0 Linker and Utilities Manual xix
Manual Contents
processors can use this manual, but should supplement it with other texts
(such as the appropriate hardware reference and programming reference
manuals) that describe your target architecture.
Manual Contents
The manual contains:
•Chapter 1, “Introduction”
This chapter provides an overview of the linker and utilities.
•Chapter 2, “Linker”
This chapter describes how to combine object files into reusable
library files to link routines referenced by other object files.
•Chapter 3, “Linker Description File”
This chapter describes how to write an .LDF file to define the
target.
•Chapter 4, “Expert Linker”
This chapter describes Expert Linker, which is an interactive
graphical tool to set up and map processor memory.
•Chapter 5, “Memory Overlays and Advanced LDF Commands”
This chapter describes how overlays and advanced LDF commands
are used for memory management.
•Chapter 6 “Archiver”
This chapter describes the
object files into library files, which serve as reusable resources for
code development.
•Chapter 7 “Memory Initializer”
This chapter describes the Memory Initializer utility that is used to
generate a single initialization stream and save it in a section in the
output executable file.
xxVisualDSP++ 4.0 Linker and Utilities Manual
elfar archiver utility used to combine
Preface
•Appendix A, “File Formats”
This appendix lists and describes the file formats that the development tools use as inputs or produce as outputs.
•Appendix B, “Utilities”
This appendix describes the utilities that provide legacy and file
conversion support.
•Appendix C, “LDF Programming Examples for TigerSHARC Pro-
cessors”
This appendix provides code examples of .LDF files used with
TigerSHARC processors.
• Appendix D, “LDF Programming Examples for SHARC Proces-
sors”
This appendix provides code examples of .LDF files used with
SHARC processors.
• Appendix E, “LDF Programming Examples for Blackfin Proces-
sors”
This appendix provides code examples of .LDF files used with
Blackfin processors.
What’s New in This Manual
This is a new manual that documents linking support for all currently
available Analog Devices 32-bit floating-point and fixed-point SHARC
and TigerSHARC
processors.
Loader/splitter information is now available in a separate Loader manual.
Refer to VisualDSP++ 4.0 Product Bulletin for information on all new and
updated features and other release information.
VisualDSP++ 4.0 Linker and Utilities Manual xxi
processors, as well as 16-bit fixed-point Blackfin
Technical or Customer Support
Technical or Customer Support
You can reach Analog Devices, Inc. Customer Support in the following
ways:
•Visit the Embedded Processing and DSP products Web site at
http://www.analog.com/processors/technicalSupport
•E-mail tools questions to
dsptools.support@analog.com
•E-mail processor questions to
dsp.support@analog.com
•Phone questions to 1-800-ANALOGD
•Contact your Analog Devices, Inc. local sales office or authorized
distributor
•Send questions by mail to:
Analog Devices, Inc.
One Technology Way
P.O. Box 9106
Norwood, MA 02062-9106
USA
xxiiVisualDSP++ 4.0 Linker and Utilities Manual
Preface
Supported Processors
The following is the list of Analog Devices, Inc. processors supported in
VisualDSP++ 4.0.
TigerSHARC (ADSP-TSxxx) Processors
The name “TigerSHARC” refers to a family of floating-point and
fixed-point [8-bit, 16-bit, and 32-bit] processors. VisualDSP++ currently
supports the following TigerSHARC processors:
ADSP-TS101 ADSP-TS201ADSP-TS202ADSP-TS203
SHARC (ADSP-21xxx) Processors
The name “SHARC” refers to a family of high-performance, 32-bit,
floating-point processors that can be used in speech, sound, graphics, and
imaging applications. VisualDSP++ currently supports the following
SHARC processors:
ADSP-21020ADSP-21060ADSP-21061ADSP-21062
ADSP-21065LADSP-21160ADSP-21161ADSP-21261
ADSP-21262ADSP-21266ADSP-21267ADSP-21363
ADSP-21364ADSP-21365ADSP-21366ADSP-21367
ADSP-21368ADSP-21369
VisualDSP++ 4.0 Linker and Utilities Manual xxiii
Product Information
Blackfin (ADSP-BFxxx) Processors
The name “Blackfin” refers to a family of 16-bit, embedded processors.
VisualDSP++ currently supports the following Blackfin processors:
ADSP-BF531ADSP-BF532 (formerly ADSP-21532)
ADSP-BF533ADSP-BF535 (formerly ADSP-21535)
ADSP-BF536ADSP-BF537
ADSP-BF538ADSP-BF539
ADSP-BF561ADSP-BF566
AD6532
Product Information
You can obtain product information from the Analog Devices Web site,
from the product CD-ROM, or from the printed publications (manuals).
Analog Devices is online at www.analog.com. Our Web site provides information about a broad range of products—analog integrated circuits,
amplifiers, converters, and digital signal processors.
MyAnalog.com
MyAnalog.com is a free feature of the Analog Devices Web site that allows
customization of a Web page to display only the latest information on
products you are interested in. You can also choose to receive weekly
e-mail notifications containing updates to the Web pages that meet your
interests. MyAnalog.com provides access to books, application notes, data
sheets, code examples, and more.
xxivVisualDSP++ 4.0 Linker and Utilities Manual
Preface
Registration
Visit www.myanalog.com to sign up. Click Register to use MyAnalog.com.
Registration takes about five minutes and serves as a means to select the
information you want to receive.
If you are already a registered user, just log on. Your user name is your
e-mail address.
Processor Product Information
For information on embedded processors and DSPs, visit our Web site at
www.analog.com/processors, which provides access to technical publica-
tions, data sheets, application notes, product overviews, and product
announcements.
You may also obtain additional information about Analog Devices and its
products in any of the following ways.
•E-mail questions or requests for information to
dsp.support@analog.com
•Fax questions or requests for information to
1-781-461-3010 (North America)
089/76 903-557 (Europe)
•Access the FTP Web site at
ftp ftp.analog.com or ftp 137.71.23.21
ftp://ftp.analog.com
VisualDSP++ 4.0 Linker and Utilities Manual xxv
Product Information
Related Documents
For information on product related development software, see these
publications:
•VisualDSP++ 4.0 Getting Started Guide
•VisualDSP++ 4.0 User’s Guide
•VisualDSP++ 4.0 C/C++ Compiler and Library Manual for SHARC
Processors
•VisualDSP++ 4.0 C/C++ Compiler and Library Manual for
TigerSHARC Processors
•VisualDSP++ 4.0 C/C++ Compiler and Library Manual for Blackfin
Processors
•VisualDSP++ 4.0 Assembler and Preprocessor Manual
•VisualDSP++ 4.0 Linker and Utilities Manual
•VisualDSP++ 4.0 Product Release Bulletin
•VisualDSP++ Kernel (VDK) User’s Guide
•Quick Installation Reference Card
For hardware information, refer to your processors’s hardware reference,
programming reference, or data sheet. All documentation is available
online. Most documentation is available in printed form.
Visit the Technical Library Web site to access all processor and tools manuals and data sheets:
Online documentation includes the VisualDSP++ Help system, software
tools manuals, hardware tools manuals, processor manuals, Dinkum
Abridged C++ library, and Flexible License Manager (FlexLM) network
license manager software documentation. You can easily search across the
entire VisualDSP++ documentation set for any topic of interest using the
Search function of VisualDSP++ Help system. For easy printing, supplementary .PDF files of most manuals are also provided.
Each documentation file type is described as follows.
File Description
.CHMHelp system files and manuals in Help format
.HTM or
.HTML
.PDFVisualDSP++ and processor manuals in Portable Documentation Format (PDF).
Dinkum Abridged C++ library and FlexLM network license manager software documentation. Viewing and printing the .HTML files requires a browser, such as
Internet Explorer 4.0 (or higher).
Viewing and printing the .PDF files requires a PDF reader, such as Adobe Acrobat
Reader (4.0 or higher).
Access the online documentation from the VisualDSP++ environment,
Windows® Explorer, or the Analog Devices Web site.
Accessing Documentation From VisualDSP++
From the VisualDSP++ environment:
•Access VisualDSP++ online Help from the Help menu’s Contents, Search, and Index commands.
•Open online Help from context-sensitive user interface items (toolbar buttons, menu commands, and windows).
VisualDSP++ 4.0 Linker and Utilities Manual xxvii
Product Information
Accessing Documentation From Windows
In addition to any shortcuts you may have constructed, there are many
ways to open VisualDSP++ online Help or the supplementary documentation from Windows.
Help system files (.CHM) are located in the Help folder of VisualDSP++
environment. The .PDF files are located in the Docs folder of your
VisualDSP++ installation CD-ROM. The Docs folder also contains the
Dinkum Abridged C++ library and the FlexLM network license manager
software documentation.
Using Windows Explorer
•Double-click the vdsp-help.chm file, which is the master Help system, to access all the other .CHM files.
•Open your VisualDSP++ installation CD-ROM and double-click
any file that is part of the VisualDSP++ documentation set.
Using the Windows Start Button
•Access VisualDSP++ online Help by clicking the Start button and
choosing Programs, Analog Devices, VisualDSP++, and
VisualDSP++ Documentation.
Accessing Documentation From the Web
Download manuals in PDF format at the following Web site:
Select a processor family and book title. Download archive (.ZIP) files, one
for each manual. Use any archive management software, such as WinZip,
to decompress downloaded files.
xxviiiVisualDSP++ 4.0 Linker and Utilities Manual
Preface
Printed Manuals
For general questions regarding literature ordering, call the Literature
Center at 1-800-ANALOGD (1-800-262-5643) and follow the prompts.
VisualDSP++ Documentation Set
To purchase VisualDSP++ manuals, call 1-603-883-2430. The manuals
may be purchased only as a kit.
If you do not have an account with Analog Devices, you are referred to
Analog Devices distributors. For information on our distributors, log onto
http://www.analog.com/salesdir/continent.asp.
Hardware Tools Manuals
To purchase EZ-KIT Lite® and In-Circuit Emulator (ICE) manuals, call
1-603-883-2430. The manuals may be ordered by title or by product
number located on the back cover of each manual.
Processor Manuals
Hardware reference and instruction set reference manuals may be ordered
through the Literature Center at 1-800-ANALOGD (1-800-262-5643),
or downloaded from the Analog Devices Web site. Manuals may be
ordered by title or by product number located on the back cover of each
manual.
Data Sheets
All data sheets (preliminary and production) may be downloaded from the
Analog Devices Web site. Only production (final) data sheets (Rev. 0, A,
B, C, and so on) can be obtained from the Literature Center at
1-800-ANALOGD (1-800-262-5643); they also can be downloaded from
the Web site.
VisualDSP++ 4.0 Linker and Utilities Manual xxix
Notation Conventions
To have a data sheet faxed to you, call the Analog Devices Faxback System
at 1-800-446-6212. Follow the prompts and a list of data sheet code
numbers will be faxed to you. If the data sheet you want is not listed,
check for it on the Web site.
Notation Conventions
Text conventions used in this manual are identified and described as
follows.
L
ExampleDescription
Close command
(File menu)
{this | that}Alternative required items in syntax descriptions appear within curly
[this | that]Optional items in syntax descriptions appear within brackets and sepa-
[this,…]Optional item lists in syntax descriptions appear within brackets
.SECTIONCommands, directives, keywords, and feature names are in text with
filenameNon-keyword placeholders appear in text with italic style format.
appear throughout this document.
Titles in reference sections indicate the location of an item within the
VisualDSP++ environment’s menu system (for example, the Close
command appears on the File menu).
brackets and separated by vertical bars; read the example as this or
that. One or the other is required.
rated by vertical bars; read the example as an optional this or that.
delimited by commas and terminated with an ellipse; read the example
as an optional comma-separated list of
letter gothic font.
this.
Additional conventions, which apply only to specific chapters, may
xxxVisualDSP++ 4.0 Linker and Utilities Manual
ExampleDescription
Note: For correct operation, ...
A Note provides supplementary information on a related topic. In the
L
a
[
online version of this book, the word Note appears instead of this
symbol.
Caution: Incorrect device operation may result if ...
Caution: Device damage may result if ...
A Caution identifies conditions or inappropriate usage of the product
that could lead to undesirable results or product damage. In the online
version of this book, the word Caution appears instead of this symbol.
Warn in g: Injury to device users may result if ...
A Warning identifies conditions or inappropriate usage of the product
that could lead to conditions that are potentially hazardous for devices
users. In the online version of this book, the word Wa rnin g appears
instead of this symbol.
Preface
VisualDSP++ 4.0 Linker and Utilities Manual xxxi
Notation Conventions
xxxiiVisualDSP++ 4.0 Linker and Utilities Manual
1INTRODUCTION
This chapter provides an overview of VisualDSP++ development tools and
their use in the [DSP] project development process.
L
This chapter includes:
The code examples in this manual have been compiled using
VisualDSP++ 4.0. The examples compiled with other versions of
VisualDSP++ may result in build errors or different output
although the highlighted algorithms stand and should continue to
stand in future releases of VisualDSP++.
•“Software Development Flow” on page 1-2
Shows how linking, loading, and splitting fit into the project development process.
•“Compiling and Assembling” on page 1-3
Shows how compiling and assembling the code fits into the project
development process.
•“Linking” on page 1-7
Shows how linking fits into the project development process.
•“Loading and Splitting” on page 1-10
Shows how loading and splitting fit into the project development
process.
VisualDSP++ 4.0 Linker and Utilities Manual 1-1
Software Development Flow
Software Development Flow
The majority of this manual describes linking, a critical stage in the
program development process for embedded applications.
The linker tool (linker.exe) consumes object and library files to produce
executable files, which can be loaded onto a simulator or target processor.
The linker also produces map files and other output that contain information used by the debugger. Debug information is embedded in the
executable file.
After running the linker, you test the output with a simulator or emulator.
Refer to the VisualDSP++ 4.0 User’s Guide and online Help for information about debugging.
Finally, you process the debugged executable file(s) through the loader or
splitter to create output for use on the actual processor. The output file
may reside on another processor (host) or may be burned into a PROM.
The VisualDSP++ 4.0 Loader Manual describes loader/splitter functionality for the target processors.
The processor software development flow can be split into three phases:
1. Compiling and Assembling – Input source files C (.C), C++ (.CPP),
and assembly (.ASM) yield object files (.DOJ)
2. Linking – Under the direction of the Linker Description File
.LDF), a linker command line, and VisualDSP++ Project Options
(
dialog box settings, the linker utility consumes object files (.DOJ)
to yield an executable (.DXE) file. If specified, shared memory (.SM)
and overlay (
3. Loading or Splitting – The executable (.DXE) file, as well as shared
memory (.SM) and overlay (.OVL) files, are processed to yield
output file(s). For TigerSHARC and Blackfin processors, these are
boot-loadable (LDR) files or non-bootable PROM image files, which
execute from the processor’s external memory.
1-2VisualDSP++ 4.0 Linker and Utilities Manual
.OVL) files are also produced.
Introduction
Compiling and Assembling
The process starts with source files written in C, C++, or assembly. The
compiler (or a code developer who writes assembly code) organizes each
distinct sequence of instructions or data into named sections, which
become the main components acted upon by the linker.
Inputs – C/C++ and Assembly Sources
The first step towards producing an executable file is to compile or assemble C, C++, or assembly source files into object files. The VisualDSP++
development software assigns a .DOJ extension to object files (Figure 1-1).
Figure 1-1. Compiling and Assembling
Object files produced by the compiler (via the assembler) and by the
assembler itself consist of input sections. Each input section contains
a particular type of compiled/assembled source code. For example, an
input section may consist of program opcodes or data, such as variables
of various widths.
Some input sections may contain information to enable source-level
debugging and other VisualDSP++ features. The linker maps each input
section (via a corresponding output section in the executable) to a memory segment, a contiguous range of memory addresses on the target system.
VisualDSP++ 4.0 Linker and Utilities Manual 1-3
Compiling and Assembling
Each input section in the .LDF file requires a unique name, as specified in
the source code. Depending on whether the source is C, C++, or assembly,
different conventions are used to name an input section (see Chapter 3,
“Linker Description File”).
Input Section Directives in Assembly Code
A .SECTION directive defines a section in assembly source. This directive
must precede its code or data.
SHARC Code Example
.SECTION/DM asmdata;// Declares section asmdata
.VAR input[3];// Declares data buffer in asmdata
.SECTION/PM asmcode;// Declares section asmcode
R0 = 0x1234;// Three lines of code in asmcode
R1 = 0x4567;
R3 = R1 + R2;
In this example, the /dm asmdata input section contains the array input,
and the /pm asmcode input section contains the three line of code.
R0 = ABS R0;/* Take absolute value of input */
RTS;
_abc.end
In this example, the assembler places the global symbol/label _abs and the
code after the label into the input section Library_Code_Space, as it processes this file into object code.
1-4VisualDSP++ 4.0 Linker and Utilities Manual
Introduction
Input Section Directives in C/C++ Source Files
Typically, C/C++ code does not specify an input section name, so the
compiler uses a default name. By default, the input section names program
(for code) and data1 (for data) are used. Additional input section names
are defined in .LDF files (see “Specifying the Memory Map” on page 2-17
for more information on memory mapping).
In C/C++ source files, you can use the optional section(“name”) C language extension to define sections.
Example 1
While processing the following code, the compiler stores the temp variable
in the ext_data input section of the .DOJ file and also stores the code generated from func1 in an input section named extern.
...
section ("ext_data") int temp;/* Section directive */
section ("extern")void func1(void) { int x = 1; }
...
Example 2
In the following example, section ("extern") is optional. Note the new
function (funct2) does not require section ("extern"). For more information on LDF sections, refer to “Specifying the Memory Map” on
page 2-17.
section ("ext_data") int temp;
section ("extern")void func1(void) { int x = 1; }
intfunc2(void) { return 13; }/* New */
VisualDSP++ 4.0 Linker and Utilities Manual 1-5
Compiling and Assembling
For information on compiler default section names, refer to the
VisualDSP++ 4.0 C/C++ Compiler and Library Manual for appropriate
target processors and “Placing Code on the Target” on page 2-40.
L
Identify the difference between input section names, output section names, and memory segment names because these types of
names appear in the .LDF file. Usually, default names are used.
However, in some situations you may want to use non-default
names. One such situation is when various functions or variables
(in the same source file) are to be placed into different memory
segments.
1-6VisualDSP++ 4.0 Linker and Utilities Manual
Introduction
Linking
After you have (compiled and) assembled source files into object files, use
the linker to combine the object files into an executable file. By default,
the development software gives executable files a .DXE extension
(Figure 1-2).
Figure 1-2. Linking Diagram
Linking enables your code to run efficiently in the target environment.
Linking is described in detail in Chapter 2, “Linker”.
L
VisualDSP++ 4.0 Linker and Utilities Manual 1-7
When developing a new project, use the Expert Linker to generate
the project’s
information.
.LDF file. See Chapter 4, “Expert Linker” for more
Linking
Linker and Assembler Preprocessor
The linker and assembler preprocessor program (pp.exe) evaluates and
processes preprocessor commands in source files. With these commands,
you direct the preprocessor to define macros and symbolic constants,
include header files, test for errors, and control conditional assembly and
compilation.
The pp preprocessor is run by the assembler or linker from the operating
system’s command line or within the VisualDSP++ environment. These
tools accept and pass this command information to the preprocessor. The
preprocessor can also operate from the command line using its own command-line switches.
Assembler/Linker Preprocessor treats the character “.” as part of an
identifier
The preprocessor matches the assembler which uses “.” as part of assembler directives and as a legal character in labels. This behavior does create a
possible problem for users that have written preprocessor macros that rely
on identifiers to break when encountering the “.” character, usually seen
when processing register names. For example,
The preprocessor supports ANSI C standard preprocessing with
extensions but differs from the ANSI C standard preprocessor in
several ways. For more information on the pp preprocessor, see the
VisualDSP++ 4.0 Assembler and Preprocessor Manual.
The compiler has it own preprocessor that allows you to use preprocessor commands within your C/C++ source. The compiler
preprocessor automatically runs before the compiler. For more
information, see the VisualDSP++ 4.0 C/C++ Compiler and Library Manual for the appropriate target archtecture.
VisualDSP++ 4.0 Linker and Utilities Manual 1-9
Loading and Splitting
Loading and Splitting
After debugging the .DXE file, you process it through a loader or splitter to
create output files used by the actual processor. The file(s) may reside on
another processor (host) or may be burned into a PROM.
For more information, refer to the VisualDSP++ 4.0 Loader Manual
which provides detailed descriptions of the processes and options used to
generate boot-loadable .LDR (loader) files for the approprate target processors. This manual also describes the splitting utility, which (when used)
creates the non-bootloadable files that execute from the processor’s external memory.
In general:
•The SHARC ADSP-2106x/ADSP-21160 processors use the loader
(elfloader.exe) to yield a boot-loadable image (.LDR file), which
resides in memory external to the processor (PROM or host processor). Use the splitter utility (elfspl21k.exe) to generate
non-bootable PROM image files, which execute from the processor’s external memory (often used with the ADSP-21065L
processors).
•The SHARC ADSP-2116x/2126x/2136x processors use the loader
(elfloader.exe) to yield a boot-loadable image (.LDR file), which
transported to (and run from) processor memory. To make a loadable file, the loader processes data from a boot-kernel file (.
and one or more other executable files (.
DXE).
DXE)
•The TigerSHARC processors use the loader (elfloader.exe) to
yield a boot-loadable image (
.LDR file), which transported to (and
run from) processor memory. To make a loadable file, the loader
processes data from a boot-kernel file (.
executable files (.
DXE).
DXE) and one or more other
1-10VisualDSP++ 4.0 Linker and Utilities Manual
Introduction
•Both TigerSHARC and SHARC processors use the splitter utility
(elfspl21k.exe) to generate non-bootable PROM image files,
which execute from the processor’s external memory.
•The Blackfin processors use the loader (elfloader.exe) to yield a
boot-loadable image (.LDR file), which resides in memory external
to the processor (PROM or host processor. To make a loadable file,
the loader processes data from a boot-kernel file (.DXE) and one or
more other executable files (.DXE).
Figure 1-3 shows a simple application of the loader. In this example, the
loader’s input is a single executable (.DXE) file. The loader can accommodate up to two .DXE files as input plus one boot kernel file (.DXE).
Figure 1-3. Loading Diagram
VisualDSP++ 4.0 Linker and Utilities Manual 1-11
Loading and Splitting
For example, when a TigerSHARC processor is reset, the boot kernel portion of the image is transferred to the processor’s core. Then, the
instruction and data portion of the image are loaded into the processor’s
internal RAM (as shown in Figure 1-4) by the boot kernel.
Figure 1-4. Booting from a Bootloadable (.LDR) File
VisualDSP++ includes boot kernel files (.DXE), which are automatically
used when you run the loader. You can also customize boot kernel source
files (included with VisualDSP++) by modifying and rebuilding them.
Figure 1-5 shows how multiple input files—in this case, two executable
(.DXE) files, a shared memory (.SM) file, and overlay (.OVL) files—are
consumed by the loader to create a single image file (
illustrate the generation of a loader file for a multiprocessor architecture.
L
This example has two executable files that share memory. Overlays are also
included. The resulting output is a compilation of all the inputs.
1-12VisualDSP++ 4.0 Linker and Utilities Manual
The .SM and .OVL files must reside in the same directory that contains the input
your system does not use shared memory or overlays, .SM and .OVL
files are not required.
.DXE file(s) or in the current working directory. If
.LDR). This example
Introduction
Figure 1-5. Input Files for a Multiprocessor System
VisualDSP++ 4.0 Linker and Utilities Manual 1-13
Loading and Splitting
1-14VisualDSP++ 4.0 Linker and Utilities Manual
2LINKER
Linking assigns code and data to processor memory. For a simple single
processor architecture, a single .DXE file is generated. A single invocation
of the linker may create multiple executable (.DXE) files for multiprocessor
(MP) architectures. Linking can also produce a shared memory (.SM) file
for an MP system. A large executable file can be split into a smaller executable file and overlays (.OVL) files, which contain code that is called in
(swapped into internal processor memory) as needed. The linker
(linker.exe) performs this task.
You can run the linker from a command line or from the VisualDSP++
Integrated Development and Debugging Environment (IDDE).
You can load the link output into the VisualDSP++ debugger for simulation, testing, and profiling.
This chapter includes:
•“Linker Operation” on page 2-2
•“Linking Environment” on page 2-6
•“Link Target Description” on page 2-16
•“Linker Command-Line Reference” on page 2-47
VisualDSP++ 4.0 Linker and Utilities Manual 2-1
Linker Operation
Linker Operation
Figure 2-1 illustrates a basic linking operation. The figure shows several
object (.DOJ) files being linked into a single executable (.DXE) file. The
Linker Description File (.LDF) directs the linking process.
Figure 2-1. Linking Object Files to Produce an Executable File
L
In a multiprocessor system, a .DXE file for each processor is generated. For
example, for a two-processor system, you must generate two
The processors in a multiprocessor architecture may share memory. When
directed by statements in the
ory (.SM) executable file, whose code is used by multiple processors.
Overlay files, another linker output, support applications that require
more program instructions and data than the processor’s internal memory
can accommodate. Refer to “Memory Management Using Overlays” on
page 5-4 for more information.
2-2VisualDSP++ 4.0 Linker and Utilities Manual
When developing a new project, use the Expert Linker to generate
the project’s .LDF file. See Chapter 4, “Expert Linker” for more
information.
.DXE files.
.LDF file, the linker produce a shared mem-
Linker
Similar to object files, executable files are partitioned into output sections
with unique names. Output sections are defined by the Executable and
Linking Format (ELF) file standard to which VisualDSP++ conforms.
L
The executable file(s) (.DXE) and auxiliary files (.SM and .OVL) are not
loaded into the processor or burned onto an EPROM. These files are used
to debug the system.
The executable’s input section names and output section names
occupy different namespaces. Because the namespaces are independent, the same section names may be used. The linker uses input
section names as labels to locate corresponding input sections
within object files.
Directing Linker Operation
Linker operations are directed by these options and commands:
•Linker (linker.exe) command-line switches (options). Refer to
“Linker Command-Line Reference” on page 2-47.
•Settings (options) on the Link page of the Project Options dialog
box. See “Project Builds” on page 2-6.
•LDF commands. Refer to “LDF Commands” on page 3-29 for a
detailed description.
Linker options control how the linker processes object files and library
files. These options specify various criteria such as search directories, map
file output, and dead code elimination. You select linker options via linker
command-line switches or by settings on the Link page of the Project Options dialog box within the VisualDSP++ environment.
LDF commands in a Linker Description File (.LDF) define the target
memory map and the placement of program sections within processor
memory. The text of these commands provides the information needed to
link your code.
VisualDSP++ 4.0 Linker and Utilities Manual 2-3
Linker Operation
L
Using directives in the .LDF file, the linker:
The VisualDSP++ Project window displays the .LDF file as a source
file, though the file provides linker command input.
•Reads input sections in the object files and maps them to output
sections in the executable file. More than one input section may be
placed in an output section.
•Maps each output section in the executable to a memory segment,
a contiguous range of memory addresses on the target processor.
More than one output section may be placed in a single memory
segment.
Linking Process Rules
The linking process observes these rules:
•Each source file produces one object file.
•Source files may specify one or more input sections as destinations
for compiled/assembled object(s).
•The compiler and assembler produce object code with labels that
direct one or more portions to particular output sections.
•As directed by the .LDF file, the linker maps each input section
in the object code to an output section in the
•As directed by the .LDF file, the linker maps each output section
to a memory segment.
•Each input section may contain multiple code items, but a code
item may appear in one input section only.
•More than one input section may be placed in an output section.
•Each memory segment must have a specified width.
2-4VisualDSP++ 4.0 Linker and Utilities Manual
.DXE file.
•Contiguous addresses on different-width hardware must reside in
different memory segments.
•More than one output section may map to a memory segment if
the output sections fit completely within the memory segment.
Linker Description File Overview
Whether you are linking C/C++ functions or assembly routines, the mechanism is the same. After converting the source files into object files, the
linker uses directives in an
able (.DXE) file, which may be loaded into a simulator for testing.
.LDF file to combine the objects into an execut-
Linker
L
Each project must include one .LDF file that specifies the linking process
by defining the target memory and mapping the code and data into that
memory. You can write your own .LDF file, or you can modify an existing
file; modification is often the easier alternative when there are few changes
in your system’s hardware or software. VisualDSP++ provides an .LDF file
that supports the default mapping of each processor type.
L
Similar to an object (.DOJ) file, an executable (.DXE) file consists of
different segments, called output sections. Input section names are independent of output section names. Because they exist in different
namespaces, input section names can be the same as output section names.
Refer to Chapter 3, “Linker Description File” for further information.
Executable file structure conforms to the Executable and Linkable
Format (ELF) standard.
When developing a new project, use the Expert Linker to generate
the project’s .LDF file, as described in Chapter 4, “Expert Linker”.
VisualDSP++ 4.0 Linker and Utilities Manual 2-5
Linking Environment
Linking Environment
The linking environment refers to Windows command-prompt windows
and the VisualDSP++ IDDE. At a minimum, run development tools (such
as the linker) via a command line and view output in standard output.
VisualDSP++ provides an environment that simplifies the processor program build process. From VisualDSP++, you specify build options from
the Project Options dialog box and modify files, including the Linker
Description File (.LDF). The Project Options dialog box’s Type option
allows you to choose whether to build a library (.DLB) file, an executable
(.DXE) file, or an image file (.LDR or others). Error and warning messages
appear in the Output window.
Project Builds
The linker runs from an operating system command line, issued from the
VisualDSP++ IDDE, or a command prompt window. Figure 2-2 shows
the VisualDSP++ environment with the Project window and an .LDF file
open in an Editor window.
The VisualDSP++ IDDE provides an intuitive interface for processor programming. When you open VisualDSP++, a work area contains everything
needed to build, manage, and debug a DSP project. You can easily create
or edit an .
on the target.
L
2-6VisualDSP++ 4.0 Linker and Utilities Manual
LDF file, which maps code or data to specific memory segments
For information about the VisualDSP++ environment, refer to the
VisualDSP++ User’s Guide for the appropriate target architecture or
online Help. Online Help provides powerful search capabilities. To
obtain information on a code item, parameter, or error, select text
in an VisualDSP++ IDDE Editor window or Output window and
press the keyboard’s F1 key.
Linker
Figure 2-2. VisualDSP++ Environment
Within VisualDSP++, specify tool settings for project builds. Use the
Project menu to open Project Options dialog box.
Figure 2-3, Figure 2-4, and Figure 2-5 show the project option selections
for SHARC, TigerSHARC, and Blackfin processors, respectively.
These dialog boxes allow you to select the target processor, type and and
name of the executable file, as well as VisualDSP++ tools available for use
with the selected processor.
When using the VisualDSP++ IDDE, use the Link option from the
Project Options dialog box (Figure 2-6) to select and/or set linker func-
tional options.
There are four subpages you can access—General, LDF Preprocessing, Elimination, and Processor. Almost every setting option has a corresponding compiler command-line switch described in “Linker
Command-Line Switches” on page 2-51.
The Additional options field in each sub-page is used to enter the appropriate file names and options that do not have corresponding controls on
the Link sub-page but are available as compiler switches.
Due to different processor architectures, the processors may provide different Link tab selection options. For example, Figure 2-7 shows Blackfin
processor options page.
Figure 2-8 shows SHARC processor options page.
VisualDSP++ 4.0 Linker and Utilities Manual 2-9
Linking Environment
Figure 2-6. Project Options – Link Page
2-10VisualDSP++ 4.0 Linker and Utilities Manual
Linker
Figure 2-7. Project Options – Link (Processor) Blackfin Page
VisualDSP++ 4.0 Linker and Utilities Manual 2-11
Linking Environment
Figure 2-8. Project Options – Link (Processor) SHARC Page
Figure 2-9. Project Options – Link (Processor) TigerSHARC Page
Use the VisualDSP++ context-sensitive online Help for each target architecture to obtain information on linker options you can specify in
VisualDSP++. To do that, click on the ? button and then click in a field or
box you need information about.
VisualDSP++ 4.0 Linker and Utilities Manual 2-13
Linking Environment
Expert Linker
The VisualDSP++ IDDE features an interactive tool, Expert Linker,
to map code or data to specific memory segments. When developing
a new project, use the Expert Linker to generate the .LDF file.
Expert Linker graphically displays the .LDF information (object files, LDF
macros, libraries, and a target memory description). With Expert Linker,
use drag-and-drop operations to arrange the object files in a graphical
memory mapping representation. When you are satisfied with the memory
layout, generate the executable (
Figure 2-10 shows the Expert Linker window, which comprises two panes:
Input Sections and Memory Map (output sections). Refer to Chapter 4,
“Expert Linker”, for detailed information.
.DXE) file.
Figure 2-10. Expert Linker Window
2-14VisualDSP++ 4.0 Linker and Utilities Manual
Linker Warning and Error Messages
Linker messages are written to the VisualDSP++ Output window
(standard output when the linker is run from a command line). Messages
describe problems the linker encountered while processing the .LDF file.
Warnings indicate processing errors that do not prevent the linker from
producing a valid output file, such as unused symbols in your code. Errors
are issued when the linker encounters situations that prevent the production of a valid output file.
Typically, these messages include the name of the .LDF file, the line number containing the message, a six-character code, and a brief description of
the condition.
Example
>linker -proc ADSP-unknown a.doj
Linker
[Error li1010] The processor ‘ADSP-unknown’ is
unknown or unsuppported.
Interpreting Linker Messages
Within VisualDSP++, the Output window’s Build tab displays project
build status and error messages. In most cases, double-clicking a message
displays the line in the source file causing the problem. You can access
descriptions of linker messages from VisualDSP++ online Help by selecting a six-character code (for example, li1010) and pressing the F1 key.
Some build errors, such as a reference to an undefined symbol, do not correlate directly to source files. These errors often stem from omissions in
the .LDF file.
For example, if an input section from the object file is not placed by the
.
LDF file, a cross-reference error occurs at every object that refers to labels
in the missing section. Fix this problem by reviewing the .
LDF file and
specifying all sections that need placement. For more information, refer to
the VisualDSP++ 4.0 User’s Manual or online Help.
VisualDSP++ 4.0 Linker and Utilities Manual 2-15
Link Target Description
Link Target Description
Before defining the system’s memory and program placement with linker
commands, analyze the target system to ensure you can describe the target
in terms the linker can process. Then, produce an .LDF file for your project
to specify these system attributes:
•Physical memory map
•Program placement within the system’s memory map
L
Be sure to understand the processor’s memory architecture, which is
described in the appropriate processor’s hardware reference manual and in
its data sheet.
This section contains:
If the project does not include an .LDF file, the linker uses a default
.LDF file for the processor that matches the -proc <processor>
switch on the linker’s command line (or the Processor selection
specified on the Project page of the Project Options dialog box in
the VisualDSP++ IDDE).
•“Representing Memory Architecture” on page 2-17
•“Specifying the Memory Map” on page 2-17
•“Placing Code on the Target” on page 2-40
•“Profile-Guided Optimization Support” on page 2-45
•“Passing Arguments for Simulation or Emulation” on page 2-46
2-16VisualDSP++ 4.0 Linker and Utilities Manual
Representing Memory Architecture
The .LDF file’s MEMORY{} command is used to represent the memory architecture of your processor system. The linker uses this information to place
the executable file into the system’s memory.
Perform the following tasks to write a MEMORY{} command:
•Memory Usage. List the ways your program uses memory in your
system. Typical uses for memory segments include interrupt tables,
initialization data, program code, data, heap space, and stack space.
Refer to “Specifying the Memory Map” on page 2-17.
•Memory Characteristics. List the types of memory in your processor system and the address ranges and word width associated with
each memory type. Memory type is defined as RAM or ROM.
•MEMORY{} Command. Construct a MEMORY{} command to combine the information from the previous two lists and to declare
your system’s memory segments.
Linker
For complete information, refer to “MEMORY{}” on page 3-35.
Specifying the Memory Map
A DSP program must conform to the constraints imposed by the processor’s data path (bus) widths and addressing capabilities. The following
information describes an
specifies several memory segments that support the
as shown in “SECTIONS{}” on page 3-48.
The three topics are important when allocating memory:
•“Memory Usage and Default Memory Sections” on page 2-18
•“Memory Characteristics Overview” on page 2-31
•“Linker MEMORY{} Command in .LDF File” on page 2-38
VisualDSP++ 4.0 Linker and Utilities Manual 2-17
.LDF file for a hypothetical project. This file
SECTIONS{} command,
Link Target Description
Memory Usage and Default Memory Sections
Input section names are generated automatically by the compiler or are
specified in the assembly source code. The .LDF file defines memory section names and output section names. The default .LDF file handles all
compiler-generated input sections (refer to the “Input Section” column in
Table 2-1, Table 2-2, and Table 2-3). The produced .DXE file has a corre-
sponding output section for each input section. Although programmers
typically do not use output section labels, the labels are used by downstream tools.
Use the ELF file dumper utility (elfdump.exe) to dump contents of an
output section (for example, data1) of an executable file. See “elfdump –
ELF File Dumper” on page B-1 for information about this utility.
The following sections show how input sections, output sections, and
memory segments correspond in the default .LDF files for appropriate target processor architectures.
L
Typical uses for memory segments include interrupt tables, initialization
data, program code, data, heap space, and stack space, etc. For detailed
processor-specific information, refer to:
2-18VisualDSP++ 4.0 Linker and Utilities Manual
Refer to your processor’s default .LDF file and to the hardware reference manual for details.
•“Default Memory Sections for SHARC Processors”
•“Default Memory Sections for TigerSHARC Processors”
•“Default Memory Sections for Blackfin Processors”
•“Special “Table” Memory Sections”
Default Memory Sections for SHARC Processors
Table 2-1 shows section mapping in the default .LDF file for ADSP-21161
processor (as an example for SHARC processors)
Table 2-1. Section Mapping in the Default SHARC LDF
Input SectionOutput SectionMemory Section
seg_pmcodxe_pmcoseg_pmco
seg_dmdadxe_dmdaseg_dmda
seg_pmdadxe_pmdaseg_pmda
heapdxe_heapseg_heap
seg_stakdxe_stakseg_stak
sec_rthdxe_rthseg_rth
seg_initseg_initseg_init
Linker
seg_init_codeseg_init_codeseg_init_code
seg_argvseg_argvseg_argv
seg_ctdmseg_ctdmseg_ctdm
seg_vtblseg_vtblseg_vtbl
There are several input/memory sections used in the default .LDF files for
ADSP-210xx/211xx/212xx/213xx processors, which must be present in
user’s own
.LDF files. These sections are described in detail below.
seg_rth
This section contains the interrupt vector table (by default, this is located
in the start-up file (for example, 060_hdr.doj).
VisualDSP++ 4.0 Linker and Utilities Manual 2-19
Link Target Description
seg_init
This section contains location and size information about the stack and
heap; also contains compressed data created by the memory initialization
tool (see “-meminit” on page 2-62 for more information).
seg_int_code
Code that modifies interrupt latch registers must not be executed from
external memory. To minimize the impact of this restriction, the library
functions that modify the latch registers are located in the seg_init_code
section, which should be located in internal memory.
seg_pmco
This section is the default location for program code.
seg_pmda
This section is the default location for global program data that is qualified with the “pm” keyword. For example,
int pm xyz[100];// Located in seg_pmda
seg_argv
This section contains the command-line arguments that are used as part of
Profile-Guided Optimization (PGO).
seg_ctdm
This section (see also seg_ctdmlon page 2-21) contains the addresses of
constructors that are called before the start of a C++ program (such as constructors for global and static objects). This section must be terminated
with the symbol “___ctor_NULL_marker” (the default .ldf files ensure
this). It is required if compiling with C++ code.
2-20VisualDSP++ 4.0 Linker and Utilities Manual
seg_dmda
This section is the default location for global data, and also for data that is
qualified with the “dm” keyword. For example,
int abc[100];// Located in seg_dmda
int dm def[100];// Located in seg_dmda
seg_heap
This section is the area from which memory allocation functions and
operators (new, malloc(), and so on) allocate memory.
seg_stak
This section is the area where the run-time stack is located. Local variables, function parameters, and so on are stored here.
Linker
seg_vtbl
This section contains C++ virtual function tables. The default .LDF files
place the virtual function tables into the default data memory area but this
can be re-mapped as required. You can also direct the compiler to use a
different section for C+ virtual function tables, by using the -section
compiler switch.
Other Memory Sections
The compiler and libraries also use other data sections that are linked into
one of the above memory sections. These data sections include:
seg_ctdml
The symbol “___ctor_NULL_marker” (located in the C++ run-time library)
marks the end of the list of global and static constructors and is placed in
this data section. The linker ensures that the contents of this data section
are the last items in
seg_ctdm.
VisualDSP++ 4.0 Linker and Utilities Manual 2-21
Link Target Description
.gdt .gdtl .frt .frtl .cht .chtl .edt .edtl
These data sections are used to hold data used during the handling of
exceptions. The linker places the contents of these data sections in
seg_dmda. See “Special “Table” Memory Sections” on page 2-30.
Default Memory Sections for TigerSHARC Processors
Table 2-2 shows section mapping in the default .LDF file for ADSP-TS101
processor (as an example for TigerSHARC processors)
Table 2-2. Section Mapping in the Default TigerSHARC LDF
Input SectionOutput SectionMemory Section
programcodeM0Code
data1data1M1Data
data2data2M2Data
heaptabheaptabM1Data
mem_argvmem_argvM1Data
bsz_initbszM1Data
bszbsz_initM1Data
jstacksegM1Stack
kstacksegM2Stack
defheapsegM1Heap
ctorctorM1Data
ctor0ctorM1Data
ctor1ctorM1Data
ctor2ctorM1Data
ctor3ctorM1Data
2-22VisualDSP++ 4.0 Linker and Utilities Manual
Table 2-2. Section Mapping in the Default TigerSHARC LDF (Cont’d)
Input SectionOutput SectionMemory Section
ctor4ctorM1Data
vtblvtblvtbl
There are several input/memory sections used in the default .LDF files for
ADSP-TSxxx processors, which must be present in user’s own .LDF files.
These sections are described in detail below.
program
This section is the default location for program code.
data1
This section is the default location for global program data.
Linker
data2
This section is the default location for global program data specified with
the pm memory qualifier.
mem_argv
This section contains the command-line arguments that are used as part of
Profile-Guided Optimization (PGO).
ctor
This section contains the addresses of constructors that are called before
the start of a C++ program (such as constructors for global and static
objects). This section must be terminated with the symbol
“___ctor_NULL_marker” (the default .ldf files ensure this). It is required if
compiling with C++ code.
VisualDSP++ 4.0 Linker and Utilities Manual 2-23
Link Target Description
When all ctor sections are merged, they form a table containing a list of
all constructors for all global C++ objects. The table is only used at startup
and can be placed in ROM. When linking, it is important that all ctor
sections are merged in sequence (no other sections in between) and the
run-time library or the VDK run-time library is placed with the first ctor
section. Note that the default LDF’s “___ctor_NULL_marker” symbol is
placed in a section named “ctorl” which must the the last of the ctor sections to be used as input. The final letter in this name is a lower-case “L”.
heaptab
This section is the area from which memory allocation functions and
operators (new, malloc(), etc.) allocate memory.
bsz
This section is a BSS-style section for global zero-initialized data.
bsz_init
This section contains run-time initialization data (see “-meminit” on
page 2-62 for more information).
M1Stack
This section is the area where the run-time stack is located. Local variables, function parameters, and so on are stored here.
M2Stack
This section is the second area where the run-time stack is located.
M1Heap
This section is the area where the heap is located. Dynamically allocated
data is placed here.
2-24VisualDSP++ 4.0 Linker and Utilities Manual
vtbl
This section contains C++ virtual function tables. The default .LDF files
place the virtual function tables into the default data memory area but this
can be re-mapped as required. You can also direct the compiler to use a
different section for C+ virtual function tables, by using the -section
compiler switch.
Default Memory Sections for Blackfin Processors
Table 2-2 shows section mapping in the default .LDF file for ADSP-BF535
processor (as an example for Blackfin processors)
Table 2-3. Section Mapping in the Default ADSP-BF535 LDF
Input SectionOutput SectionMemory Section
programprogramMEM_PROGRAM
Linker
data1data1MEM_PROGRAM
cplb_codecplb_codeMEM_PROGRAM
L1_codeL1_codeMEM_L1_CODE
constdataconstdataMEM_PROGRAM
cplb_datacplb_dataMEM_PROGRAM
L1_DATA_AL1_DATA_AMEM_L1_DATA_A
L1_DATA_BL1_DATA_BMEM_L1_DATA_A
voldatavoldataMEM_PROGRAM
bszbszMEM_L1_CODE
bsz_initbsz_initMEM_PROGRAM
heap heapMEM_HEAP
stackstack MEM_STACK
ctor program MEM_PROGRAM
argvargvMEM_ARGV
VisualDSP++ 4.0 Linker and Utilities Manual 2-25
Link Target Description
Table 2-3. Section Mapping in the Default ADSP-BF535 LDF (Cont’d)
Input SectionOutput SectionMemory Section
noncache_codenoncache_codenoncache_code
sdramsdramMEM_SDRAM
vtblsdramvtbl
L
There are several input/memory sections used in the default .LDF files for
ADSP-BFxxx processors, which must be present in user’s own .LDF files.
These sections are described in detail below.
program
This section is the default location for program code. Code in this section
is mapped into L1 Instruction memory if possible, but will spill into
slower memory if there is not enough space.
data1
This section is the default location for global program data.
cplb_code
This section stores the run-time library’s CPLB management routines. It
is usually mapped into L1 Instruction SRAM. In particular, if
CPLB-replacement is a possibility, this section must be mapped to memory that is guaranteed to always available; this means that it must be
addressed by a locked CPLB.
For Blackfin processors, you can modify your .LDF file to place
objects into L1 memories when they are configured as SRAM.
2-26VisualDSP++ 4.0 Linker and Utilities Manual
constdata
This section is used for global data which is declared as constant, and for
literal constants such as strings and array initializers. The compiler’s
default behavior is to assume that “const” data remains constant, and
therefore can be mapped into read-only memory (although the default
LDFs do not do this). Refer to the -const-read-write switch in the
VisualDSP++ 4.0 C/C++ Compiler and Library Manual for Blackfin Processors for more details.
cplb_data
This section stores CPLB configuration tables In particular, the cplbtabx.doj files (where x indicates the target) mapped by the LDFs are
placed into this section. It must be mapped to a data area that is always
available. If CPLB replacement is a possibility, this section must be
mapped into memory that is covered by a locked CPLB.
Linker
L1_DATA_A
This section is used to allow data to be mapped explicitly into L1 Data A
SRAM using the SECTION directive. By default, the compiler does not generate data here. This section is analogous to L1_code.
L1_DATA_B
This section is similar to L1_DATA_A, except that it is used to map data into
L1 Data B SRAM.
voldata
This section is used for data that may change due to external influences
(such as DMA), and should not be placed into cached data areas.
VisualDSP++ 4.0 Linker and Utilities Manual 2-27
Link Target Description
argv
This section contains the command-line arguments that are used as part of
Profile-Guided Optimization (PGO).
ctor
This section contains the addresses of constructors that are called before
the start of a C++ program (such as constructors for global and static
objects). This section must be terminated with the symbol
“___ctor_NULL_marker” (default .LDF files ensure this). It is required if
compiling with C++ code.
When all ctor sections are merged, they form a table containing a list of
all constructors for all global C++ objects. The table is only used at startup
and can be placed in ROM. When linking, it is important that all ctor
sections are merged in sequence (no other sections in between) and the
run-time library or the VDK run-time library is placed with the first ctor
section. Note that the default LDF’s “___ctor_NULL_marker” symbol is
placed in a section named “ctorl” which must the the last of the ctor sections to be used as input. The final letter in this name is a lower-case “L”.
bsz
This section is a BSS-style section for global zero-initialized data. This section does not actually contain data; it is zero-filled upon loading via the
VisualDSP++ IDDE, or when processed by the loader.
bsz_init
This section contains run-time initialization data (see “-meminit” on
page 2-62 for more information). It is expected that this section is mapped
into read-only memory. When a .DXE file has been processed by the Memory Initializer utility and the program starts running, other data sections
(such as
data1 and constdata) are initialized by data copied from this
section.
2-28VisualDSP++ 4.0 Linker and Utilities Manual
stack
This section is the area where the run-time stack is located. Local variables, function parameters, and so on are stored here.
heap
This section is the area where the heap is located. Dynamically allocated
data is placed here.
noncache_code
This section is mapped to areas of memory that cannot be cache and take
program code. This section would be used if you have a function that
turns on the cache to ensure that the function itself does not reside in
cache (as executing code from a cache memory address causes a hardware
exception).
Linker
sdram0
This section allows code or data to be mapped explicitly into external
memory by using the SECTION directive. This can be used to place large,
infrequently-used data or functions into external memory to free up valuable internal memory.
vtbl
This section contains C++ virtual function tables. The default .LDF files
place the virtual function tables into the default data memory area but this
can be re-mapped as required. You can also direct the compiler to use a
different section for C+ virtual function tables, by using the
-section
compiler switch.
VisualDSP++ 4.0 Linker and Utilities Manual 2-29
Link Target Description
Other Memory Sections
The compiler and libraries also use other data sections that are linked into
one of the above memory sections. These data sections include:
ctorl
This section contains the terminator for the ctor table section. It must be
mapped immediately after the ctor section.
.gdt .gdtl .frt .frtl .cht .chtl .edt .edtl
These data sections are used to hold data used during the handling of
exceptions. See “Special “Table” Memory Sections” on page 2-30.
Special “Table” Memory Sections
The following “table” data sections are used to hold data used during the
handling of exceptions. The linker is generally mapping these sections into
read-only memory.
.gdt
This section (Global Dispatch Table) is used by the C++ Exception
Library to determine which area of code to which a particular address
belongs. This section must be contiguous in memory.
.gdtl
This section contains the terminator for the .gdt table section. It must be
mapped immediately after the
.gdt section.
.edt
This section (Exception Dispatch Table) is used by the C++ Exception
Library to map from try blocks to catch blocks.
2-30VisualDSP++ 4.0 Linker and Utilities Manual
.edtl
This section contains the terminator for the .edt table section. It must be
mapped immediately after the .edt section.
.cht
This section (Catch Handler Types Table) is used to map to the RTTI
type information. The C++ Exception Library uses it to determine the
types that correspond to catch entries for a try block.
.chtl
This section contains the terminator for the .cht table section. It must be
mapped immediately after the .cht section.
.frt
Linker
This section (Function Range Table) is used by the C++ Exception
Library during exception processing to unwind the stack of active
functions.
.frtl
This section contains the terminator for the .frt table section. It must be
mapped immediately after the
Memory Characteristics Overview
This section provides an overview of basic memory information (including
addresses and ranges) for sample target architectures.
L
VisualDSP++ 4.0 Linker and Utilities Manual 2-31
Some portions of the processor memory are reserved. Refer to the
hardware reference manual for target processor for more
information.
.frt section.
Link Target Description
SHARC Memory Characteristics
As an example of the SHARC memory architecture, the ADSP-21161
processor contains a large, dual-ported internal memory for single-cycle,
simultaneous, independent accesses by the core processor and I/O processor. The dual-ported memory in combination with three separate on-chip
buses allow two data transfers from the core and one transfer from the I/O
processor in a single cycle. Using the IO bus, the I/O processor provides
data transfers between internal memory and the processor’s communication ports (link ports, serial ports, and external port) without hindering
the processor core’s access to memory. The processor provides access to
external memory through the processor’s external port.
The processor contains one megabit of on-chip SRAM, organized as two
blocks of 0.5 Mbits. Each block can be configured for different combinations of code and data storage. All of the memory can be accessed as
16-bit, 32-bit, 48-bit, or 64-bit words. The memory can be configured in
each block as a maximum of 16 Kwords of 32-bit data, 8 Kwords of 64-bit
data, 32K words of 16-bit data, 10.67 Kwords of 48-bit instructions (or
40-bit data), or combinations of different word sizes up to 0.5 Mbit. This
gives a total for the complete internal memory: a maximum of 32 Kwords
of 32-bit data, 16 Kwords of 64-bit data, 64 Kwords of 16-bit data, and
21 Kwords of 48-bit instructions (or 40-bit data).
The processor features a 16-bit floating-point storage format that effectively doubles the amount of data that may be stored on-chip. A single
instruction converts the format from 32-bit floating-point to 16-bit
floating-point.
While each memory block can store combinations of code and data,
accesses are most efficient when one block stores data using the DM bus,
(typically, Block 1) for transfers, and the other block (typically, Block 0)
stores instructions and data using the PM bus. Using the DM bus and PM
bus with one dedicated to each memory block assures single-cycle execution with two data transfers. In this case, the instruction must be available
in the cache.
2-32VisualDSP++ 4.0 Linker and Utilities Manual
Linker
Internal Memory
The ADSP-21161 processor has 2 MBits of internal memory space; 1
Mbit is addressable. The 1 Mbit of memory is divided into two 0.5 Mbit
blocks: Block 0 and Block 1. The additional 1 MBit of the memory space
is reserved on the ADSP-21161 processor. Table 2-4 shows the maximum
number of data or instruction words that can fit in each 0.5 MBit internal
memory block.
Table 2-4. Words Per 0.5 MBit Internal Memory Block
Word TypeBits Per WordMaximum Number of
Words Per 0.5 Mbit Block
Instruction48-bits10.67 Kwords
Long Word Data64-bits8 Kwords
Extended Precision Normal Word Data40-bits10.67 Kwords
Normal Word Data32-bits16 Kwords
Short Word Data16-bits32 Kwords
External Memory
While the processor’s internal memory is divided into blocks, the processor’s external memory spaces are divided into banks. The internal memory
blocks and the external memory spaces may be addressed by either data
address generator. External memory banks are fixed sizes that can be configured for various waitstate and access configurations.
There are 254 Mwords of external memory space that the processor can
address. External memory connects to the processor’s external port, which
extends the processor’s 24-bit address and 32-bit data buses off the processor. The processor can make 8, 16, 32, or 48-bit accesses to external
memory for instructions and 8,16, or 32-bit accesses for data. Table 2-5
shows the access types and words for processor’s external memory accesses.
The processor’s DMA controller automatically packs external data into
the appropriate word width during data transfer.
VisualDSP++ 4.0 Linker and Utilities Manual 2-33
Link Target Description
L
Table 2-5. Internal-to-External Memory Word Transfers
Word Ty p eTr a ns fe r Typ e
Packed Instruction32, 16, or 8- to 48-bit packing
Normal Word Data32-bit word in 32-bit transfer
Short Word DataNot supported
The total addressable space for the fixed external memory bank sizes
depends on whether SDRAM or Non-SDRAM (such as SRAM,
SBSRAM) is used. Each external memory bank for SDRAM can address
64 Mwords. For Non-SDRAM memory, each bank can address up to 16
Mwords. The remaining 48 Mwords are reserved. These reserved
addresses for non-SDRAM accesses are aliased to the first 16 Mspaces
within the bank.
The external data bus can be expanded to 48-bits if the link ports
are disabled and the corresponding full width instruction packing
mode (IPACK) is enabled in the SYSCON register. Ensure that link
ports are disabled when executing code from external 48-bit
memory.
TigerSHARC Memory Characteristics
As an example of the TigerSHARC memory architecture, the
ADSP-TS101 processor has three internal memory blocks: M0, M1, and
M2. Each memory block consists of 2 Mbits of memory space, and is configured as 64 kwords each 32 bits in width. There are three separate
internal 128-bit data buses, each connected to one of the memory blocks.
Memory blocks can store instructions and data interchangeably, with one
access per memory block per cycle. If the programmer ensures that program and data are in different memory blocks, then data access can occur
at the same time as program fetch. Therefore, in one cycle, up to three
128-bit transfers can occur within the core (two data transfers and one
program instruction transfer).
2-34VisualDSP++ 4.0 Linker and Utilities Manual
Linker
The I/O Processor can use only one internal bus at a time, and the I/O
Processor competes with the core for use of the internal bus. Therefore, in
one cycle, the processor can fetch four 32-bit instructions, and load or
store 256 bits of data (four 64-bit words or eight 32-bit words or sixteen
16-bit words or thirty-two 8-bit words).
The TigerSHARC processor 32-bit address bus provides an address space
of four gigawords. This address space is common to a cluster of TigerSHARC processors that share the same cluster bus.
The zones in the memory space are made up of the following regions.
•External memory bank space—the region for standard addressing
of off-chip memory (including SDRAM, MB0, MB1, and Host)
•External multiprocessor space—the on-chip memory of all other
TigerSHARC processors connected in a multiprocessor system
•Internal address space—the region for standard internal addressing
In the example system, the ADSP-TS101 processor has internal memory
addresses from 0x0 to 0x17FFFF. Refer to Table 2-6.
Internal registers0x0018 0000 - 0x0018 07FFControl, status, and I/O registers.
This cannot be used in .LDF files.
Internal registers are memory
accessible in MP space only.
0x0018 0800 - 0x01BF FFFFReserved
0x01C0 0000 - 0x03FF FFFFBroadcast and multiprocessor (not
used in .LDF file)
SDRAM0x0400 0000 - 0x07FF FFFF32-bit instructions
Blackfin Processor Memory Characteristics
As an example, this section describes the Blackfin ADSP-BF535 memory
architecture and memory map organization.
L
ADSP-BF532, ADSP-BF533 and ADSP-BF561 processors) have
very different memory architectures. Refer to hardware reference
manuals of target processors for appropriate information.
The ADSP-BF535 processor includes the L1 memory subsystem with a
16Kbyte instruction SRAM/cache, a dedicated 4Kbyte data scratchpad,
and a 32Kbyte data SRAM/cache configured as two independent 16Kbyte
banks (memories). Each independent bank can be configured as SRAM or
cache.
The ADSP-BF535 processor also has an L2 SRAM memory that provides
2 Mbits (256 Kbytes) of memory. The L2 memory is unified; that is, it is
directly accessible by the instruction and data ports of the ADSP-BF535
processor. The L2 memory is organized as a multi-bank architecture of
single-ported SRAMs (there are eight sub-banks in L2), such that simultaneous accesses by the core and the DMA controller to different banks can
occur in parallel.
2-36VisualDSP++ 4.0 Linker and Utilities Manual
Other processors in the Blackfin processor family (ADSP-BF531,
Linker
The device has two ports to the L2 memory: one dedicated to core
requests, and the other dedicated to system DMA and PCI requests. The
processor units can process 8-, 16-, 32-, or 40-bit data, depending on the
type of function being performed.
Table 2-7 lists memory ranges for the ADSP-BF535 processors. Blackfin
processors have a 32-bit address range to support memory addresses from
0x0 to 0xFFFF FFFF. Address ranges that are not listed are reserved.
0xFF900000 –0xFF903FFFData Memory Bank 2 SRAM (16K)
0xFF800000 –0xFF803FFFData Memory Bank 1 SRAM (16K)
0xF0040000 –0xFF7FFFFFReserved
0xF0000000 –0xF003FFFFL2 Memory Bank SRAM (256K)
0xEF000400 –0xEFFFFFFFReserved
0xEF000000 –0xEF0003FFBoot ROM (1K)
0x00000000 –0xEEFFFFFFExternal memory
The MEMORY section in Listing 2-1 on page 2-38 assumes that only L1 and
L2 SRAMs are available and that L1 is unused. Refer to the VisualDSP++ C/C++ Compiler and Library Manual for Blackfin Processors and the appropriate hardware reference for information about cache configuration.
See the Memory chapter in an appropriate hardware reference for
L
information about your target processor’s memory organization.
VisualDSP++ 4.0 Linker and Utilities Manual 2-37
Link Target Description
Linker MEMORY{} Command in .LDF File
Referring to information in sections “Memory Usage and Default Mem-
ory Sections” and “Memory Characteristics Overview”, you can specify
the target’s memory with the MEMORY{} command for any of target processor architectures (Listing 2-1, Listing 2-2, and Listing 2-3 provide code
examples for specific processors).
write a MEMORY{} command and to the following discussion of the
SECTIONS{} command. The SECTIONS{} command is not atomic; it
can be interspersed with other directives, including location
The above examples apply to the preceding discussion of how to
counter information. You can define new symbols within the
.LDF
file. These examples define the starting stack address, the highest
possible stack address, and the heap’s starting location and size.
These newly-created symbols are entered in the executable’s symbol
table.
VisualDSP++ 4.0 Linker and Utilities Manual 2-39
Link Target Description
Placing Code on the Target
Use the SECTIONS{} command to map code and data to the physical memory of a processor in a processor system.
To write a SECTIONS{} command:
1. List all input sections defined in the source files.
•Assembly files. List each assembly code .SECTION directive,
identify its memory type (PM or CODE, or DM or DATA), and note
when location is critical to its operation. These .SECTIONS portions include interrupt tables, data buffers, and on-chip code or
data. (see “Specifying Two Buffers in Different Memory Seg-
ments” on page 2-44 for TigerSHARC-specific information.)
•C/C++ source files. The compiler generates sections with the
name “program” or “code” for code, and the names “data1” and
“data2” for data. These sections correspond to your source
when you do not specify a section by means of the optional
section() extension.
2. Compare the input sections list to the memory segments specified
in the MEMORY{} command. Identify the memory segment into
which each .SECTION must be placed.
3. Combine the information from these two lists to write one or more
SECTIONS{} commands in the .LDF file.
L
Listing 2-4 presents a SECTIONS{} command that would work with the
MEMORY{} command in Listing 2-1.
2-40VisualDSP++ 4.0 Linker and Utilities Manual
SECTIONS{} commands must appear within the context of
the PROCESSOR{} or SHARED_MEMORY() command.
Linker
Listing 2-4. ADSP-21161 SECTIONS{} Command in the .LDF File
Specifying Two Buffers in Different Memory Segments
On TigerSHARC processors, the linker is enhanced to support efficient
programming using the .SEPARATE_MEM_SEGMENTS assembler directive.
•The .SEPARATE_MEM_SEGMENTS assembler directive (or the compiler
pragma #pragma separate_mem_segments) specifies two buffers
directing the linker to place the buffers into different memory segments. For example,
•The set of available memory segments for each buffer is defined by
using the linker’s “one-to-many” feature—mapping the input section(s) that contain the buffer into multiple memory segments. For
example,
data2 {
INPUT_SECTIONS( $OBJECTS(data1) )
} >M2DataA
data4 {
INPUT_SECTIONS( $OBJECTS(data1) )
} >M4DataA
•Linker tries to satisfy placement constraint requirements by allocating the buffers to different memory segments.
a. If the linker fails to satisfy some or all of the requirements,
the linker produces a warning.
b. All symbols mentioned in .SEPARATE_MEM_SEGMENTS are
mapped before anything else by the linker (with the exception of absolute placement).
2-44VisualDSP++ 4.0 Linker and Utilities Manual
Linker
c. Reference to symbol in .SEPARATE_MEM_SEGMENTS is a weak
reference. If such symbol is defined in a library, linker does
NOT bring the symbol from the library (unless the symbol
is referenced directly or indirectly from an object file.
d. The linker ignores the cases where the symbol is mentioned
in .SEPARATE_MEM_SEGMENTS assembler directive is undefined or is not defined in an input section (for example, as
an LDF symbol).
L
See “Pragmas” in Chapter 1 of the VisualDSP++ 4.0 C/C++ Compiler and Library Manual for TigerSHARC Processors for more
information.
Profile-Guided Optimization Support
The SHARC, TigerSHARC and Blackfin processor architectures support
Profile-Guided Optimization (PGO). PGO is the process of gathering
information about a running application over many invocations of the
executable with different input data, and then re-optimizing it using that
gathered information.
The process relies upon the same application being run with different data
sets, which often means that the application acts upon sample data sets
stored in files. More specifically, it means that the application is instructed
to process each file via command-line options passed to
The .LDF files and the VisualDSP++ IDDE collaborate to provide support
for command-line arguments. Under normal circumstances, a typical
embedded program is not interested in command-line arguments, and
receives none. In these normal cases, the run-time header invokes a function to parse a global string __argv_string[] and finds it empty.
main().
To support PGO, the LDF option IDDE_ARGS can be used to define a
memory section called
to the start of this section. The VisualDSP++ IDDE follows the conven-
VisualDSP++ 4.0 Linker and Utilities Manual 2-45
MEM_ARGV, and __argv_string[] is mapped directly
Link Target Description
tion that command-line arguments can be passed to an application by
writing the argument string into memory starting at the beginning of
MEM_ARGV.
L
Refer to VisualDSP++ 4.0 C/C++ Compiler and Library Manual for
the appropriate processor architecture for more information on
Profile-Guided Optimization.
Passing Arguments for Simulation or Emulation
L
This feature applies to Blackfin processors ONLY.
To support simulation and emulation in Blackfin processors, the linker
should obtain the start address and buffer length of the argument list from
the ARGV memory segment of the .LDF file (refer to “Example 1 – Basic
.LDF File for Blackfin Processors” on page 3-6).
To set the address:
1. In the MEMORY{} section, add a line to define the MEM_ARGV section.
2. Add a command to define the ARGV section and the values for
ldf_argv_space, ldf_argv_length, and ldf_argv_end.
Refer to the VisualDSP++ 4.0 User's Manual or the online Help for infor-
mation about the simulator and command-line arguments.
L
2-46VisualDSP++ 4.0 Linker and Utilities Manual
Do not use command-line arguments for linked programs without
first modifying the .LDF file to allocate a buffer suitable for your
application.
Linker Command-Line Reference
This section provides reference information, including:
•“Linker Command-Line Syntax” on page 2-47
•“Linker Command-Line Switches” on page 2-51
Linker
L
When you use the linker via the VisualDSP++ IDDE, the settings
on the Link tab of the Project Options dialog box correspond
to linker command-line switches. VisualDSP++ calls the linker
with these switches when linking your code. For more information,
refer to the VisualDSP++ 4.0 User’s Manual and the VisualDSP++
online Help.
Linker Command-Line Syntax
Run the linker by using one of the following normalized formats of the
linker command line.
When using the linker’s command line, be familiar with the following
topics:
Command-Line Object Files
The command line must list at least one (typically more) object file(s)
to be linked together. These files may be of several different types.
The linker command line (except for file names) is case sensitive.
For example, linker -t differs from linker -T.
•“Command-Line Object Files” on page 2-48
•“Command-Line File Names” on page 2-49
•“Object File Types” on page 2-51
•Standard object (.DOJ) files produced by the assembler
•One or more libraries (archives), each with a .DLB extension.
Examples include the C run-time libraries and math libraries
included with VisualDSP++. You may create libraries of common
or specialized objects. Special libraries are available from DSP algorithm vendors. For more information, see Chapter 6, “Archiver”.
•An executable (.DXE) file to be linked against. Refer to
$COMMAND_LINE_LINK_AGAINST in “Built-In LDF Macros” on
page 3-27.
2-48VisualDSP++ 4.0 Linker and Utilities Manual
Object File Names
Object file names are not case sensitive. An object file name may include:
•The drive, directory path, file name, and file extension
•The directory path may be an absolute path or a path relative to the
directory where the linker is invoked
•Long file names enclosed within straight quotes
If the file exists before the link begins, the linker opens the file to verify its
type before processing the file. Table 2-8 lists valid file extensions used by
the linker.
Command-Line File Names
Some linker switches take a file name as a parameter. Table 2-8 lists the
types of files, names, and extensions that the linker expects on file name
arguments. The linker follows the conventions for file extensions in
Table 2-8.
Linker
Table 2-8. File Extension Conventions
ExtensionFile Description
.DLBLibrary (archive) file
.DOJObject file
.DXEExecutable file
.LDFLinker Description File
.OVLOverlay file
.SMShared memory file
VisualDSP++ 4.0 Linker and Utilities Manual 2-49
Linker Command-Line Reference
The linker supports relative and absolute directory names, default directories, and user-selected directories for file search paths. File searches occur
in the following order.
1. Specified path – If the command line includes relative or absolute
path information, the linker searches that location for the file.
2. Specified directories – If you do not include path information
on the command line and the file is not in the default directory,
the linker searches for the file in the search directories specified
with the -L (path) command-line switch, and then searches directories specified by SEARCH_DIR commands in the .LDF file.
Directories are searched in order of appearance on the command
line or in the .LDF file.
3. Default directory – If you do not include path information in the
.LDF file named by the -T switch, the linker searches for the .LDF
file in the current working directory. If you use a default .LDF file
(by omitting LDF information in the command line and instead
specifying -proc <processor>), the linker searches in the processor-specific LDF directory; for example, ...\$ADI_DSP\21161\ldf.
For more information on file searches, see “Built-In LDF Macros” on
page 3-27.
When providing input or output file names as command-line parameters:
•Use a space to delimit file names in a list of input files.
•Enclose file names that contain spaces within straight quotes; for
example, “
long file name”.
•Include the appropriate extension to each file. The linker opens
existing files and verifies their type before processing. When the
linker creates a file, it uses the file extension to determine the type
of file to create.
2-50VisualDSP++ 4.0 Linker and Utilities Manual
Object File Types
The linker handles an object (file) by its file type. File type is determined
by the following rules.
•Existing files are opened and examined to determine their type.
Their names can be anything.
•Files created during the link are named with an appropriate extension and are formatted accordingly. A map file is generated in XML
format only and is given an .XML extension. An executable is written in the ELF format and is given a .DXE extension.
The linker treats object (.DOJ) and library (.DLB) files that appear on the
command line as object files to be linked. The linker treats executable
(.DXE) and shared memory (.SM) files on the command line as executables
to be linked against.
Linker
For more information on objects, see the $COMMAND_LINE_OBJECTS macro.
For information on executables, see the $COMMAND_LINE_LINK_AGAINST
macro. Both are described in “Built-In LDF Macros” on page 3-27.
If link objects are not specified on the command line or in the .LDF file,
the linker generates appropriate informational or error messages.
Linker Command-Line Switches
This section describes the linker’s command-line switches. Table 2-9 on
page 2-53 briefly describes each switch with regard to case sensitivity,
equivalent switches, switches overridden or contradicted by the one
described, and naming and spacing constraints for parameters.
The linker provides switches to select operations and modes. The standard
switch syntax is:
-switch [argument]
VisualDSP++ 4.0 Linker and Utilities Manual 2-51
Linker Command-Line Reference
Rules
•Switches may be used in any order on the command line. Items in
brackets [] are optional. Items in italics are user-definable and are
described with each switch.
•Path names may be relative or absolute.
•File names containing white space or colons must be enclosed by
double quotation marks, though relative path names such as
..\..\test.dxe do not require double quotation marks.