---------------------------------------------------------------------------
Usage: ld65 [options] module ...
Short options:
+ -( Start a library group
+ -) End a library group
-C name Use linker config file
+ -D sym=val Define a symbol
-L path Specify a library search path
-Ln name Create a VICE label file
-S addr Set the default start address
-m name Create a map file
-o name Name the default output file
-t sys Set the target system
+ -u sym Force an import of symbol `sym'
-v Verbose mode
-vm Verbose map file
--cfg-path path Specify a config file search path
--config name Use linker config file
--dbgfile name Generate debug information
+ --define sym=val Define a symbol
--dump-config name Dump a builtin configuration
+ --end-group End a library group
+ --force-import sym Force an import of symbol `sym'
--help Help (this text)
--lib file Link this library
--lib-path path Specify a library search path
--obj file Link this object file
--obj-path path Specify an object file search path
--start-addr addr Set the default start address
+ --start-group Start a library group
--target sys Set the target system
--version Print the linker version
---------------------------------------------------------------------------
<itemize>
<item>none
<item>apple2
+ <item>apple2enh
<item>atari
<item>atmos
<item>c16 (works also for the c116 with memory up to 32K)
<item>lunix
<item>atmos
<item>nes
+ <item>supervision
</itemize>
There are a few more targets defined but neither of them is actually
supported.
+ <tag><tt>-u sym[:addrsize], --force-import sym[:addrsize]</tt></tag>
+
+ Force an import of a symbol. While object files are always linked to the
+ output file, regardless if there are any references, object modules from
+ libraries get only linked in if an import can be satisfied by this module.
+ The <tt/--fore-import/ option may be used to add a reference to a symbol and
+ as a result force linkage of the module that exports the identifier.
+
+ The name of the symbol may optionally be followed by a colon and an address
+ size specifier. If no address size is specified, the default address size
+ for the target machine is used.
+
+ Please note that the symbol name needs to have the internal representation,
+ meaning you have to prepend an underline for C identifiers.
+
+
<label id="option-v">
<tag><tt>-v, --verbose</tt></tag>
id="option-t" name="-t"></tt>.
+ <label id="option-D">
+ <tag><tt>-D sym=value, --define sym=value</tt></tag>
+
+ This option allows to define an external symbol on the command line. Value
+ may start with a '$' sign or with <tt/0x/ for hexadecimal values,
+ otherwise a leading zero denotes octal values. See also the <ref
+ id="SYMBOLS" name="SYMBOLS section"> in the configuration file.
+
+
<label id="option--lib-path">
<tag><tt>-L path, --lib-path path</tt></tag>
Using -S you may define the default starting address. If and how this
address is used depends on the config file in use. For the builtin
- configurations, only the "none" system honors an explicit start address,
- all other builtin config provide their own.
+ configurations, only the "none", "apple2" and "apple2enh" systems honor an
+ explicit start address, all other builtin config provide their own.
<tag><tt>-V, --version</tt></tag>
<item>A compiled in library path which is often <tt>/usr/lib/cc65/lib</tt> on
Linux systems.
<item>The value of the environment variable <tt/LD65_LIB/ if it is defined.
-<item>The value of the environment variable <tt/CC65_LIB/ if it is defined.
- Please note that use of this environment variable is obsolete and may
- get removed in future versions.
+<item>A subdirectory named <tt/lib/ of the directory defined in the environment
+ variable <tt/CC65_HOME/, if it is defined.
<item>Any directory added with the <tt><ref id="option--lib-path"
name="--lib-path"></tt> option on the command line.
</enum>
<enum>
<item>The current directory.
-<item>A compiled in directory which is often <tt>/usr/lib/cc65/lib</tt> on
+<item>A compiled in directory which is often <tt>/usr/lib/cc65/obj</tt> on
Linux systems.
<item>The value of the environment variable <tt/LD65_OBJ/ if it is defined.
-<item>The value of the environment variable <tt/CC65_LIB/ if it is defined.
- Please note that use of this environment variable is obsolete and may
- get removed in future versions.
+<item>A subdirectory named <tt/obj/ of the directory defined in the environment
+ variable <tt/CC65_HOME/, if it is defined.
<item>Any directory added with the <tt><ref id="option--obj-path"
name="--obj-path"></tt> option on the command line.
</enum>
<enum>
<item>The current directory.
-<item>A compiled in directory which is often <tt>/usr/lib/cc65/lib</tt> on
+<item>A compiled in directory which is often <tt>/usr/lib/cc65/cfg</tt> on
Linux systems.
<item>The value of the environment variable <tt/LD65_CFG/ if it is defined.
+<item>A subdirectory named <tt/cfg/ of the directory defined in the environment
+ variable <tt/CC65_HOME/, if it is defined.
<item>Any directory added with the <tt><ref id="option--cfg-path"
name="--cfg-path"></tt> option on the command line.
</enum>
the linker will first write the <tt/CODE/ segment, then the <tt/RODATA/
segment, then the <tt/DATA/ segment - but it will not write the <tt/BSS/
segment. Why? Enter the segment type: For each segment specified, you may also
-specify a segment attribute. There are five possible segment attributes:
+specify a segment attribute. There are four possible segment attributes:
<tscreen><verb>
ro means readonly
- wprot same as ro but will be marked as write protected in
- the VICE label file if -Lp is given
- rw means read/write
- bss means that this is an uninitialized segment
- zp a zeropage segment
+ rw means read/write
+ bss means that this is an uninitialized segment
+ zp a zeropage segment
</verb></tscreen>
So, because we specified that the segment with the name BSS is of type bss,
The "file" attribute (the keyword may also be written as "FILE" if you like
that better) takes a string enclosed in double quotes (`"') that specifies the
-file, where the data is written. You may specifiy the same file several times,
+file, where the data is written. You may specify the same file several times,
in that case the data for all memory areas having this file name is written
into this file, in the order of the memory areas defined in the <tt/MEMORY/
section. Let's specify some file names in the <tt/MEMORY/ section used above:
explicitly assigned a value. And your program will rely on these values on
startup. Since there's no other way to remember the contents of the data
segment, than storing it into one of the ROMs, we have to put it there. But
-unfortunately, ROM is not writeable, so we have to copy it into RAM before
+unfortunately, ROM is not writable, so we have to copy it into RAM before
running the actual code.
The linker cannot help you copying the data from ROM into RAM (this must be
</verb></tscreen>
If an alignment is requested, the linker will add enough space to the output
-file, so that the new segment starts at an address that is divideable by the
+file, so that the new segment starts at an address that is dividable by the
given number without a remainder. All addresses are adjusted accordingly. To
fill the unused space, bytes of zero are used, or, if the memory area has a
"<tt/fillval/" attribute, that value. Alignment is always needed, if you have
-the used the <tt/.ALIGN/ command in the assembler. The alignment of a segment
+used the <tt/.ALIGN/ command in the assembler. The alignment of a segment
must be equal or greater than the alignment used in the <tt/.ALIGN/ command.
The linker will check that, and issue a warning, if the alignment of a segment
-is lower than the alignment requested in a <tt/.ALIGN/ command of one of the
+is lower than the alignment requested in an <tt/.ALIGN/ command of one of the
modules making up this segment.
For a given segment you may also specify a fixed offset into a memory area or
of the segment in the run memory area, because this is what is usually
desired. If load and run memory areas are equal (which is the case if only the
load memory area has been specified), the attributes will also work. There is
-also a "<tt/align_load/" attribute that may be used to align the start of the
+also an "<tt/align_load/" attribute that may be used to align the start of the
segment in the load memory area, in case different load and run areas have
been specified. There are no special attributes to set start or offset for
just the load memory area.
</verb></tscreen>
The only other available output format is the o65 format specified by Andre
-Fachat. It is defined like this:
+Fachat (see the <htmlurl url="http://www.6502.org/users/andre/o65/fileformat.html"
+name="6502 binary relocation format specification">). It is defined like this:
<tscreen><verb>
FILES {
-
-
-<sect1>Features<label id="FEATURES"><p>
+<sect1>The FEATURES section<label id="FEATURES"><p>
In addition to the <tt/MEMORY/ and <tt/SEGMENTS/ sections described above, the
linker has features that may be enabled by an additional section labeled
linker is $200.
<tscreen><verb>
- FEATURES {
+ FEATURES {
# Default start address is $1000
- STARTADDRESS: default = $1000;
- }
+ STARTADDRESS: default = $1000;
+ }
</verb></tscreen>
Please note that order is important: The default start address must be defined
+<sect1>The SYMBOLS section<label id="SYMBOLS"><p>
+
+The configuration file may also be used to define symbols used in the link
+stage. The mandatory attribute for a symbol is its value. A second, boolean
+attribute named <tt/weak/ is available. If a symbol is marked as weak, it may
+be overridden by defining a symbol of the same name from the command line. The
+default for symbols is that they're strong, which means that an attempt to
+define a symbol with the same name from the command line will lead to an
+error.
+
+The following example defines the stack size for an application, but allows
+the programmer to override the value by specifying <tt/--define
+__STACKSIZE__=xxx/ on the command line.
+
+<tscreen><verb>
+ SYMBOLS {
+ # Define the stack size for the application
+ __STACKSIZE__: value = $800, weak = yes;
+ }
+</verb></tscreen>
+
+
+
<sect1>Builtin configurations<p>
-The builtin configurations are part of the linker source. They are also
-distributed together with the machine specific binary packages (usually in the
-doc directory) and don't have a special format. So if you need a special
-configuration, it's a good idea to start with the builtin configuration for
-your system. In a first step, just replace <tt/-t target/ by <tt/-C
-configfile/. The go on and modify the config file to suit your needs.
+The builtin configurations are part of the linker source. They can be retrieved
+with <tt/--dump-config/ and don't have a special format. So if you need a
+special configuration, it's a good idea to start with the builtin configuration
+for your system. In a first step, just replace <tt/-t target/ by <tt/-C
+configfile/. Then go on and modify the config file to suit your needs.
+
+
+
+<sect1>Secondary configurations<p>
+
+Several machine specific binary packages are distributed together with secondary
+configurations (in the cfg directory). These configurations can be used with
+<tt/-C configfile/ too.
+
+
+
+<sect>Special segments<p>
+
+The builtin config files do contain segments that have a special meaning for
+the compiler and the libraries that come with it. If you replace the builtin
+config files, you will need the following information.
+
+<sect1>INIT<p>
+
+The INIT segment is used for initialization code that may be reused once
+execution reaches main() - provided that the program runs in RAM. You
+may for example add the INIT segment to the heap in really memory
+constrained systems.
+
+<sect1>LOWCODE<p>
+
+For the LOWCODE segment, it is guaranteed that it won't be banked out, so it
+is reachable at any time by interrupt handlers or similar.
+
+<sect1>STARTUP<p>
+
+This segment contains the startup code which initializes the C software stack
+and the libraries. It is placed in its own segment because it needs to be
+loaded at the lowest possible program address on several platforms.
+
+<sect1>ZPSAVE<p>
+
+The ZPSAVE segment contains the original values of the zeropage locations used
+by the ZEROPAGE segment. It is placed in its own segment because it must not be
+initialized.
<sect>Copyright<p>
-ld65 (and all cc65 binutils) are (C) Copyright 1998-2001 Ullrich von
+ld65 (and all cc65 binutils) are (C) Copyright 1998-2005 Ullrich von
Bassewitz. For usage of the binaries and/or sources the following
conditions do apply: