]> git.sur5r.net Git - cc65/blobdiff - doc/ld65.sgml
Removed the - now unused - empty builtin configuration (was used for the ace
[cc65] / doc / ld65.sgml
index 02ba5307f48fb0eebd570d36943172dcf0f1fe45..80cfd4421846924bf565627a87cb192da22633cf 100644 (file)
@@ -55,25 +55,41 @@ The linker is called as follows:
 ---------------------------------------------------------------------------
 Usage: ld65 [options] module ...
 Short options:
-  -C name              Use linker config file
-  -Ln name             Create a VICE label file
-  -Lp                  Mark write protected segments as such (VICE)
-  -S addr              Set the default start address
-  -V                   Print the linker version
-  -h                   Help (this text)
-  -m name              Create a map file
-  -o name              Name the default output file
-  -t sys               Set the target system
-  -v                   Verbose mode
-  -vm                  Verbose map file
+  -(                    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
+  -V                    Print the linker version
+  -h                    Help (this text)
+  -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
 
 Long options:
-  --config name                Use linker config file
-  --help               Help (this text)
-  --mapfile name       Create a 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
+  --mapfile name        Create a map file
+  --module-id id        Specify a module id
+  --obj file            Link this object file
+  --obj-path path       Specify an object file search path
   --start-addr addr     Set the default start address
-  --target sys         Set the target system
-  --version            Print the linker version
+  --start-group         Start a library group
+  --target sys          Set the target system
+  --version             Print the linker version
 ---------------------------------------------------------------------------
 </verb></tscreen>
 
@@ -84,6 +100,26 @@ Here is a description of all the command line options:
 
 <descrip>
 
+  <label id="option--start-group">
+  <tag><tt>-(, --start-group</tt></tag>
+
+  Start a library group. The libraries specified within a group are searched
+  multiple times to resolve crossreferences within the libraries. Normally,
+  crossreferences are only resolved within a library, that is the library is
+  searched multiple times. Libraries specified later on the command line
+  cannot reference otherwise unreferenced symbols in libraries specified
+  earlier, because the linker has already handled them. Library groups are
+  a solution for this problem, because the linker will search repeatedly
+  through all libraries specified in the group, until all possible open
+  symbol references have been satisfied.
+
+
+  <tag><tt>-), --end-group</tt></tag>
+
+  End a library group. See the explanation of the <tt><ref
+  id="option--start-group" name="--start-group"></tt> option.
+
+
   <tag><tt>-h, --help</tt></tag>
 
   Print the short option summary shown above.
@@ -118,20 +154,42 @@ Here is a description of all the command line options:
 
   <itemize>
   <item>none
+  <item>apple2
+  <item>apple2enh
   <item>atari
+  <item>atmos
+  <item>c16 (works also for the c116 with memory up to 32K)
   <item>c64
   <item>c128
   <item>plus4
   <item>cbm510 (CBM-II series with 40 column video)
   <item>cbm610 (all CBM series-II computers with 80 column video)
   <item>pet (all CBM PET systems except the 2001)
-  <item>apple2
   <item>geos
+  <item>lunix
+  <item>atmos
+  <item>nes
+  <item>supervision
   </itemize>
 
   There are a few more targets defined but neither of them is actually
-  supported. See <ref id="builtin-configs" name="builtin configurations"> for
-  more information.
+  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">
@@ -159,6 +217,25 @@ Here is a description of all the command line options:
   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 '&dollar;' 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>
+
+  Specify a library search path. This option may be used more than once. It
+  adds a directory to the search path for library files. Libraries specified
+  without a path are searched in current directory, in the directory given in
+  the <tt/LD65_LIB/ environment variable, and in the list of directories
+  specified using <tt/--lib-path/.
+
+
   <tag><tt>-Ln</tt></tag>
 
   This option allows you to create a file that contains all global labels and
@@ -168,18 +245,13 @@ Here is a description of all the command line options:
   version.
 
 
-  <tag><tt>-Lp</tt></tag>
-
-  Deprecated option.
-
-
   <label id="option-S">
   <tag><tt>-S addr, --start-addr addr</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>
@@ -187,12 +259,108 @@ Here is a description of all the command line options:
   This option print the version number of the linker. If you send any
   suggestions or bugfixes, please include this number.
 
+
+  <label id="option--cfg-path">
+  <tag><tt>--cfg-path path</tt></tag>
+
+  Specify a config file search path. This option may be used more than once.
+  It adds a directory to the search path for config files. A config file given
+  with the <tt><ref id="option-C" name="-C"></tt> option that has no path in
+  its name is searched in the current directory, in the directory given in the
+  <tt/LD65_CFG/ environment variable, and in the list of directories specified
+  using <tt/--cfg-path/.
+
+
+  <label id="option--dbgfile">
+  <tag><tt>--dbgfile name</tt></tag>
+
+  Specify an output file for debug information. Available information will be
+  written to this file. Using the <tt/-g/ option for the compiler and assembler
+  will increase the amount of information available. Please note that debug
+  information generation is currently being developed, so the format of the
+  file and it's contents are subject to change without further notice.
+
+
+  <tag><tt>--lib file</tt></tag>
+
+  Links a library to the output. Use this command line option instead of just
+  naming the library file, if the linker is not able to determine the file
+  type because of an unusual extension.
+
+
+  <tag><tt>--obj file</tt></tag>
+
+  Links an object file to the output. Use this command line option instead
+  of just naming the object file, if the linker is not able to determine the
+  file type because of an unusual extension.
+
+
+  <label id="option--obj-path">
+  <tag><tt>--obj-path path</tt></tag>
+
+  Specify an object file search path. This option may be used more than once.
+  It adds a directory to the search path for object files. An object file
+  passed to the linker that has no path in its name is searched in current
+  directory, in the directory given in the <tt/LD65_OBJ/ environment variable,
+  and in the list of directories specified using <tt/--obj-path/.
+
 </descrip>
 
-If one of the modules is not found in the current directory, and the module
-name does not have a path component, the value of the environment variable
-<tt/CC65_LIB/ is prepended to the name, and the linker tries to open the
-module with this new name.
+
+
+<sect>Search paths<p>
+
+Starting with version 2.10 there are now several search paths for files needed
+by the linker: One for libraries, one for object files and one for config
+files.
+
+
+<sect1>Library search path<p>
+
+The library search path contains in this order:
+
+<enum>
+<item>The current directory.
+<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>Any directory added with the <tt><ref id="option--lib-path"
+      name="--lib-path"></tt> option on the command line.
+</enum>
+
+
+<sect1>Object file search path<p>
+
+The object file search path contains in this order:
+
+<enum>
+<item>The current directory.
+<item>A compiled in directory which is often <tt>/usr/lib/cc65/lib</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>Any directory added with the <tt><ref id="option--obj-path"
+      name="--obj-path"></tt> option on the command line.
+</enum>
+
+
+<sect1>Config file search path<p>
+
+The config file search path contains in this order:
+
+<enum>
+<item>The current directory.
+<item>A compiled in directory which is often <tt>/usr/lib/cc65/lib</tt> on
+      Linux systems.
+<item>The value of the environment variable <tt/LD65_CFG/ 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>
 
 
 
@@ -338,16 +506,13 @@ What we are doing here is telling the linker, that all segments go into the
 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
-       empty   will not go in any output file
-       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,
@@ -372,10 +537,10 @@ segment, where this attribute is true, the linker will export three symbols.
 
 <tscreen><verb>
        __NAME_LOAD__   This is set to the address where the
-                       segment is loaded.
+                       segment is loaded.
        __NAME_RUN__    This is set to the run address of the
-                       segment. We will cover run addresses
-                       later.
+                       segment. We will cover run addresses
+                       later.
        __NAME_SIZE__   This is set to the segment size.
 </verb></tscreen>
 
@@ -400,7 +565,7 @@ example above. Let's have a look at it now.
 
 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:
@@ -427,6 +592,12 @@ names here. Segments that go into <tt/ROM1/ will be written to a file named
 "rom1.bin", and segments that go into <tt/ROM2/ will be written to a file
 named "rom2.bin". The name given on the command line is ignored in both cases.
 
+Assigning an empty file name for a memory area will discard the data written
+to it. This is useful, if the a memory area has segments assigned that are
+empty (for example because they are of type bss). In that case, the linker
+will create an empty output file. This may be suppressed by assigning an empty
+file name to that memory area.
+
 
 <sect1>LOAD and RUN addresses (ROMable code)<p>
 
@@ -449,7 +620,7 @@ about <tt/DATA/? <tt/DATA/ contains initialized data, that is, data that was
 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
@@ -485,10 +656,10 @@ external symbols for the data segment that may be accessed from your code:
 
 <tscreen><verb>
                __DATA_LOAD__   This is set to the address where the segment
-                       is loaded, in this case, it is an address in
-                       ROM2.
+                       is loaded, in this case, it is an address in
+                       ROM2.
        __DATA_RUN__    This is set to the run address of the segment,
-                       in this case, it is an address in RAM2.
+                       in this case, it is an address in RAM2.
        __DATA_SIZE__   This is set to the segment size.
 </verb></tscreen>
 
@@ -541,6 +712,11 @@ you don't like this, you may specify a byte value that is used to fill these
 areas with the "<tt/fillval/" attribute. This value is also used to fill unfilled
 areas generated by the assemblers <tt/.ALIGN/ and <tt/.RES/ directives.
 
+The symbol <tt/%S/ may be used to access the default start address (that is,
+the one defined in the <ref id="FEATURES" name="FEATURES"> section, or the
+value given on the command line with the <tt><ref id="option-S" name="-S"></tt>
+option).
+
 
 <sect1>Other SEGMENT attributes<p>
 
@@ -559,14 +735,14 @@ page boundary, use
 </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
@@ -593,24 +769,80 @@ or (for the segment definitions from above)
        }
 </verb></tscreen>
 
-File names may be empty, data from segments assigned to a memory area with
-an empty file name is discarded. This is useful, if the a memory area has
-segments assigned that are empty (for example because they are of type
-bss). In that case, the linker will create an empty output file. This may
-be suppressed by assigning an empty file name to that memory area.
+The "<tt/align/", "<tt/start/" and "<tt/offset/" attributes change placement
+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 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.
 
-The symbol <tt/%S/ may be used to access the default start address (that is,
-$200 or the value given on the command line with the <tt><ref id="option-S"
-name="-S"></tt> option).
+To suppress the warning, the linker issues if it encounters a segment that is
+not found in any of the input files, use "<tt/optional=yes/" as additional
+segment attribute. Be careful when using this attribute, because a missing
+segment may be a sign of a problem, and if you're suppressing the warning,
+there is no one left to tell you about it.
+
+<sect1>The FILES section<p>
+
+The <tt/FILES/ section is used to support other formats than straight binary
+(which is the default, so binary output files do not need an explicit entry
+in the <tt/FILES/ section).
+
+The <tt/FILES/ section lists output files and as only attribute the format of
+each output file. Assigning binary format to the default output file would
+look like this:
+
+<tscreen><verb>
+       FILES {
+           %O: format = bin;
+       }
+</verb></tscreen>
+
+The only other available output format is the o65 format specified by Andre
+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 {
+           %O: format = o65;
+       }
+</verb></tscreen>
+
+The necessary o65 attributes are defined in a special section labeled
+<tt/FORMAT/.
+
+
+
+<sect1>The FORMAT section<p>
+
+The <tt/FORMAT/ section is used to describe file formats. The default (binary)
+format has currently no attributes, so, while it may be listed in this
+section, the attribute list is empty. The second supported format, o65, has
+several attributes that may be defined here.
 
+<tscreen><verb>
+    FORMATS {
+        o65: os = lunix, version = 0, type = small,
+             import = LUNIXKERNEL,
+             export = _main;
+    }
+</verb></tscreen>
 
 
-<sect1>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
-<tt/FEATURES/. Currently, one such feature is available: <tt/CONDES/ is used
-to tell the linker to emit module constructor/destructor tables.
+<tt/FEATURES/.
+
+
+<sect2>The CONDES feature<p>
+
+<tt/CONDES/ is used to tell the linker to emit module constructor/destructor
+tables.
 
 <tscreen><verb>
        FEATURES {
@@ -633,24 +865,23 @@ The <tt/CONDES/ feature has several attributes:
 
   <tag><tt>type</tt></tag>
 
-  Describes the type of the routines to place in the table. Type may be
-  one of the predefined types <tt/constructor/ or <tt/destructor/, or a
-  numeric value between 0 and 6.
+  Describes the type of the routines to place in the table. Type may be one of
+  the predefined types <tt/constructor/, <tt/destructor/, <tt/interruptor/, or
+  numeric value between 0 and 6.
 
 
   <tag><tt>label</tt></tag>
 
-  This specifies the label to use for the table. The label points to the
-  start of the table in memory and may be used from within user written
-  code.
+  This specifies the label to use for the table. The label points to the start
+  of the table in memory and may be used from within user written code.
 
 
   <tag><tt>count</tt></tag>
 
-  This is an optional attribute. If specified, an additional symbol is
-  defined by the linker using the given name. The value of this symbol
-  is the number of entries (<em/not/ bytes) in the table. While this
-  attribute is optional, it is often useful to define it.
+  This is an optional attribute. If specified, an additional symbol is defined
+  by the linker using the given name. The value of this symbol is the number
+  of entries (<em/not/ bytes) in the table. While this attribute is optional,
+  it is often useful to define it.
 
 
   <tag><tt>order</tt></tag>
@@ -659,8 +890,10 @@ The <tt/CONDES/ feature has several attributes:
   <tt/decreasing/ as an argument. Specifies the sorting order of the entries
   within the table. The default is <tt/increasing/, which means that the
   entries are sorted with increasing priority (the first entry has the lowest
-  priority). You may change this behaviour by specifying <tt/decreasing/ as
-  the argument, the order of entries is reversed in this case.
+  priority). "Priority" is the priority specified when declaring a symbol as
+  <tt/.CONDES/ with the assembler, higher values mean higher priority. You may
+  change this behaviour by specifying <tt/decreasing/ as the argument, the
+  order of entries is reversed in this case.
 
   Please note that the order of entries with equal priority is undefined.
 
@@ -673,308 +906,87 @@ For more information see the <tt/.CONDES/ command in the <htmlurl
 url="ca65.html" name="ca65 manual">.
 
 
+<sect2>The STARTADDRESS feature<p>
 
-<sect1>Builtin configurations<label id="builtin-configs"><p>
-
-Here is a list of the builin configurations for the different target
-types:
+<tt/STARTADDRESS/ is used to set the default value for the start address,
+which can be referenced by the <tt/%S/ symbol. The builtin default for the
+linker is &dollar;200.
 
-<descrip>
-<tag><tt>none</tt></tag>
 <tscreen><verb>
-       MEMORY {
-           RAM: start = %S, size = $10000, file = %O;
-       }
-       SEGMENTS {
-           CODE: load = RAM, type = rw;
-           RODATA: load = RAM, type = rw;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
+               FEATURES {
+            # Default start address is $1000
+                   STARTADDRESS:       default = $1000;
+               }
 </verb></tscreen>
 
-<tag><tt>atari</tt></tag>
-<tscreen><verb>
-       MEMORY {
-           ZP: start = $82, size = $7E, type = rw;
-           HEADER: start = $0000, size = $6, file = %O;
-           RAM: start = $1F00, size = $9D1F, file = %O;    # $9D1F: matches upper bound $BC1F
-       }
-       SEGMENTS {
-           EXEHDR: load = HEADER, type = wprot;
-           CODE: load = RAM, type = wprot, define = yes;
-           RODATA: load = RAM, type = wprot;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-           ZEROPAGE: load = ZP, type = zp;
-           AUTOSTRT: load = RAM, type = wprot;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
-</verb></tscreen>
+Please note that order is important: The default start address must be defined
+<em/before/ the <tt/%S/ symbol is used in the config file. This does usually
+mean, that the <tt/FEATURES/ section has to go to the top of the config file.
 
-<tag><tt>c64</tt></tag>
-<tscreen><verb>
-       MEMORY {
-           ZP: start = $02, size = $1A, type = rw;
-           RAM: start = $7FF, size = $c801, define = yes, file = %O;
-       }
-       SEGMENTS {
-           CODE: load = RAM, type = wprot;
-           RODATA: load = RAM, type = wprot;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-           ZEROPAGE: load = ZP, type = zp;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
-</verb></tscreen>
 
-<tag><tt>c128</tt></tag>
-<tscreen><verb>
-       MEMORY {
-           ZP: start = $02, size = $1A, type = rw;
-           RAM: start = $1bff, size = $a401, define = yes, file = %O;
-       }
-       SEGMENTS {
-           CODE: load = RAM, type = wprot;
-           RODATA: load = RAM, type = wprot;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-           ZEROPAGE: load = ZP, type = zp;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = 2,
-                   label = __IRQFUNC_TABLE__,
-                   count = __IRQFUNC_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
-</verb></tscreen>
 
-<tag><tt>plus4</tt></tag>
-<tscreen><verb>
-       MEMORY {
-           ZP: start = $02, size = $1A, type = rw;
-           RAM: start = $0fff, size = $7001, file = %O;
-       }
-       SEGMENTS {
-           CODE: load = RAM, type = wprot;
-           RODATA: load = RAM, type = wprot;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-           ZEROPAGE: load = ZP, type = zp;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
-</verb></tscreen>
+<sect1>The SYMBOLS section<label id="SYMBOLS"><p>
 
-<tag><tt>cbm510</tt></tag>
-<tscreen><verb>
-       MEMORY {
-           ZP: start = $02, size = $1A, type = rw;
-           RAM: start = $0001, size = $F3FF, file = %O;
-           VIDRAM: start = $F400, size = $0400, define = yes, file = "";
-       }
-       SEGMENTS {
-           CODE: load = RAM, type = wprot;
-           RODATA: load = RAM, type = wprot;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-           ZEROPAGE: load = ZP, type = zp;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = 2,
-                   label = __IRQFUNC_TABLE__,
-                   count = __IRQFUNC_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $781;       # ~2K stack
-       }
-</verb></tscreen>
+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.
 
-<tag><tt>cbm610</tt></tag>
-<tscreen><verb>
-       MEMORY {
-           ZP: start = $02, size = $1A, type = rw;
-           RAM: start = $0001, size = $FFF0, file = %O;
-       }
-       SEGMENTS {
-           CODE: load = RAM, type = wprot;
-           RODATA: load = RAM, type = wprot;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-           ZEROPAGE: load = ZP, type = zp;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
-</verb></tscreen>
+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.
 
-<tag><tt>pet</tt></tag>
 <tscreen><verb>
-       MEMORY {
-           ZP: start = $02, size = $1A, type = rw;
-           RAM: start = $03FF, size = $7BFF, file = %O;
-       }
-       SEGMENTS {
-           CODE: load = RAM, type = wprot;
-           RODATA: load = RAM, type = wprot;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-           ZEROPAGE: load = ZP, type = zp;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
+               SYMBOLS {
+            # Define the stack size for the application
+                   __STACKSIZE__:      value = $800, weak = yes;
+               }
 </verb></tscreen>
 
-<tag><tt>apple2</tt></tag>
-<tscreen><verb>
-       MEMORY {
-           ZP: start = $00, size = $1A, type = rw;
-           RAM: start = $800, size = $8E00, file = %O;
-       }
-       SEGMENTS {
-           CODE: load = RAM, type = ro;
-           RODATA: load = RAM, type = ro;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-           ZEROPAGE: load = ZP, type = zp;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
-</verb></tscreen>
 
-<tag><tt>geos</tt></tag>
-<tscreen><verb>
-       MEMORY {
-           HEADER: start = $204, size = 508, file = %O;
-           RAM: start = $400, size = $5C00, file = %O;
-       }
-       SEGMENTS {
-           HEADER: load = HEADER, type = ro;
-           CODE: load = RAM, type = ro;
-           RODATA: load = RAM, type = ro;
-           DATA: load = RAM, type = rw;
-           BSS: load = RAM, type = bss, define = yes;
-       }
-       FEATURES {
-           CONDES: segment = RODATA,
-                   type = constructor,
-                   label = __CONSTRUCTOR_TABLE__,
-                   count = __CONSTRUCTOR_COUNT__;
-           CONDES: segment = RODATA,
-                   type = destructor,
-                   label = __DESTRUCTOR_TABLE__,
-                   count = __DESTRUCTOR_COUNT__;
-       }
-       SYMBOLS {
-           __STACKSIZE__ = $800;       # 2K stack
-       }
-</verb></tscreen>
 
-</descrip>
+<sect1>Builtin configurations<p>
 
-The "<tt/start/" attribute for the <tt/RAM/ memory area of the CBM systems is
-two less than the actual start of the basic RAM to account for the two bytes
-load address that is needed on disk and supplied by the startup code.
+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/. Then go on and modify the config file to suit your needs.
+
+
+
+<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>HEAP<p>
+
+This segment defines the location of the memory heap used by the malloc
+routine.
 
 
 
@@ -989,7 +1001,7 @@ name="uz@cc65.org">).
 
 <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:
 
@@ -1015,4 +1027,3 @@ freely, subject to the following restrictions:
 
 
 </article>
-