]> git.sur5r.net Git - cc65/blobdiff - doc/ld65.sgml
ld65.sgml: document '--allow-multiple-definition' switch
[cc65] / doc / ld65.sgml
index 48821797a9de852c92d2ce6986d652dbbd71c34e..36489b0c60e286b86eff8d91d5095c5a58a54f61 100644 (file)
@@ -3,7 +3,6 @@
 <article>
 <title>ld65 Users Guide
 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
-<date>2014-04-20
 
 <abstract>
 The ld65 linker combines object files into an executable file. ld65 is highly
@@ -25,21 +24,21 @@ It complements the features that are built into the ca65 macroassembler:
 
 <itemize>
 
-<item> Accept any number of segments to form an executable module.
+<item>  Accept any number of segments to form an executable module.
 
-<item> Resolve arbitrary expressions stored in the object files.
+<item>  Resolve arbitrary expressions stored in the object files.
 
-<item> In case of errors, use the meta information stored in the object files
-       to produce helpful error messages. In case of undefined symbols,
-       expression range errors, or symbol type mismatches, ld65 is able to
-       tell you the exact location in the original assembler source, where
-       the symbol was referenced.
+<item>  In case of errors, use the meta information stored in the object files
+        to produce helpful error messages. In case of undefined symbols,
+        expression range errors, or symbol type mismatches, ld65 is able to
+        tell you the exact location in the original assembler source, where
+        the symbol was referenced.
 
-<item> Flexible output. The output of ld65 is highly configurable by a config
-       file. Some more-common platforms are supported by default configurations
-       that may be activated by naming the target system. The output
-       generation was designed with different output formats in mind, so
-       adding other formats shouldn't be a great problem.
+<item>  Flexible output. The output of ld65 is highly configurable by a config
+        file. Some more-common platforms are supported by default configurations
+        that may be activated by naming the target system. The output
+        generation was designed with different output formats in mind, so
+        adding other formats shouldn't be a great problem.
 
 </itemize>
 
@@ -67,28 +66,29 @@ Short options:
   -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'
+  -u sym                Force an import of symbol 'sym'
   -v                    Verbose mode
   -vm                   Verbose map file
 
 Long options:
-  --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
-  --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
-  --start-group         Start a library group
-  --target sys          Set the target system
-  --version             Print the linker version
+  --allow-multiple-definition   Allow multiple definitions
+  --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
+  --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
+  --start-group                 Start a library group
+  --target sys                  Set the target system
+  --version                     Print the linker version
 ---------------------------------------------------------------------------
 </verb></tscreen>
 
@@ -99,6 +99,14 @@ Here is a description of all of the command-line options:
 
 <descrip>
 
+  <tag><tt>--allow-multiple-definition</tt></tag>
+
+  Normally when a global symbol is defined multiple times, ld65 will
+  issue an error and not create the output file. This option lets it
+  silently ignore this fact and continue. The first definition of a
+  symbol will be used.
+
+
   <label id="option--start-group">
   <tag><tt>-(, --start-group</tt></tag>
 
@@ -175,6 +183,7 @@ Here is a description of all of the command-line options:
   <item>sim6502
   <item>sim65c02
   <item>supervision
+  <item>telestrat
   <item>vic20
   </itemize>
 
@@ -487,7 +496,7 @@ There are of course more attributes for a memory section than just start and
 size. Start and size are mandatory attributes, that means, each memory area
 defined <em/must/ have these attributes given (the linker will check that). I
 will cover other attributes later. As you may have noticed, I've used a
-comment in the example above. Comments start with a hash mark (`#'), the
+comment in the example above. Comments start with a hash mark ('#'), the
 remainder of the line is ignored if this character is found.
 
 
@@ -519,7 +528,7 @@ specify a segment attribute. There are five possible segment attributes:
         rw          means read/write
         bss         means that this is an uninitialized segment
         zp          a zeropage segment
-        overwrite   a segment that overwrites another one
+        overwrite   a segment that overwrites (parts of) another one
 
 </verb></tscreen>
 
@@ -572,7 +581,7 @@ default behaviour is OK for our purposes, I did not use the attribute in the
 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 (`&dquot;') that specifies the
+that better) takes a string enclosed in double quotes ('&dquot;') that specifies the
 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/
@@ -635,8 +644,8 @@ Here is an example:
 
 <tscreen><verb>
 MEMORY {
-    RAM: file = "", start = $6000, size = $2000, type=bss;
-    ROM:  file = %O, start = $8000, size = $8000, type=ro;
+    RAM: file = "", start = $6000, size = $2000, type=rw;
+    ROM: file = %O, start = $8000, size = $8000, type=ro;
 }
 </verb></tscreen>
 
@@ -655,14 +664,15 @@ SEGMENTS {
 </verb></tscreen>
 
 Segment named ORIGINAL contains the original code, disassembled or provided in
-a binary form. Subsequent four segments will be relocated to addresses
-specified by their "start" attributes ("offset" can also be used) and then will
-overwrite whatever was at these locations in the ORIGINAL segment. In the end,
-resulting binary output file will thus contain original data with the exception
-of four sequences starting at $9000, $f7e8, $8000 and $e5b7, which will sport
-code from their respective segments. How long these sequences will be depends
-on the lengths of corresponding segments - they can even overlap, so think what
-you're doing.
+a binary form (i.e. using <tt/.INCBIN/ directive; see the <tt/ca65/ assembler
+document).  Subsequent four segments will be relocated to addresses specified
+by their "start" attributes ("offset" can also be used) and then will overwrite
+whatever was at these locations in the ORIGINAL segment. In the end, resulting
+binary output file will thus contain original data with the exception of four
+sequences starting at $9000, $f7e8, $8000 and $e5b7, which will sport code from
+their respective segments. How long these sequences will be depends on the
+lengths of corresponding segments - they can even overlap, so think what you're
+doing.
 
 Finally, note that OVERWRITE segments should be the final segments loaded to a
 particular memory area, and that they need at least one of "start" or "offset"
@@ -807,8 +817,7 @@ segment.
 <sect1>Other SEGMENT attributes<p>
 
 Segments may be aligned to some memory boundary. Specify "<tt/align = num/" to
-request this feature. Num must be a power of two. To align all segments on a
-page boundary, use
+request this feature. To align all segments on a page boundary, use
 
 <tscreen><verb>
         SEGMENTS {
@@ -893,7 +902,7 @@ look like this:
         }
 </verb></tscreen>
 
-The only other available output format is the o65 format specified by Andre
+There are two other available formats, one is the o65 format specified by Andre
 Fachat (see the <url url="http://www.6502.org/users/andre/o65/fileformat.html"
 name="6502 binary relocation format specification">). It is defined like this:
 
@@ -903,7 +912,20 @@ name="6502 binary relocation format specification">). It is defined like this:
         }
 </verb></tscreen>
 
-The necessary o65 attributes are defined in a special section labeled
+The other format available is the Atari (xex) segmented file format, this is
+the standard format used by Atari DOS 2.0 and upward file managers in the Atari
+8-bit computers, and it is defined like this:
+
+<tscreen><verb>
+        FILES {
+            %O: format = atari;
+        }
+</verb></tscreen>
+
+In the Atari segmented file format, the linker will write each <tt/MEMORY/ area
+as a new segment, including a header with the start and end address.
+
+The necessary o65 or Atari attributes are defined in a special section labeled
 <ref id="FORMAT" name="FORMAT">.
 
 
@@ -924,6 +946,30 @@ has several attributes that may be defined here.
     }
 </verb></tscreen>
 
+The Atari file format has two attributes:
+
+<descrip>
+
+  <tag><tt>RUNAD = symbol</tt></tag>
+
+  Specify a symbol as the run address of the binary, the loader will call this
+  address after all the file is loaded in memory. If the attribute is omitted,
+  no run address is included in the file.
+
+  <tag><tt>INITAD = memory_area : symbol</tt></tag>
+
+  Specify a symbol as the initialization address for the given memory area.
+  The binary loader will call this address just after the memory area is loaded
+  into memory, before continuing loading the rest of the file.
+
+</descrip>
+
+
+<tscreen><verb>
+    FORMATS {
+        atari: runad = _start;
+    }
+</verb></tscreen>
 
 
 <sect1>The FEATURES section<label id="FEATURES"><p>
@@ -1125,14 +1171,14 @@ including commercial applications, and to alter it and redistribute it
 freely, subject to the following restrictions:
 
 <enum>
-<item>         The origin of this software must not be misrepresented; you must not
-               claim that you wrote the original software. If you use this software
-               in a product, an acknowledgment in the product documentation would be
-       appreciated but is not required.
-<item> Altered source versions must be plainly marked as such, and must not
-       be misrepresented as being the original software.
-<item> This notice may not be removed or altered from any source
-       distribution.
+<item>  The origin of this software must not be misrepresented; you must not
+        claim that you wrote the original software. If you use this software
+        in a product, an acknowledgment in the product documentation would be
+        appreciated but is not required.
+<item>  Altered source versions must be plainly marked as such, and must not
+        be misrepresented as being the original software.
+<item>  This notice may not be removed or altered from any source
+        distribution.
 </enum>