* objcopy.c (copy_object): If the output file format is `binary',
authorIan Lance Taylor <ian@airs.com>
Tue, 18 Oct 1994 19:20:58 +0000 (19:20 +0000)
committerIan Lance Taylor <ian@airs.com>
Tue, 18 Oct 1994 19:20:58 +0000 (19:20 +0000)
and the start address was not set using --set-start, default the
start address to zero.  This hack is because the `binary' output
file format uses the start address to set the virtual address of
the first byte in the file.
* binutils.texi, objcopy.1: Add some notes on generating S-records
and binary files.

binutils/ChangeLog
binutils/binutils.texi
binutils/objcopy.1
binutils/objcopy.c

index 7c89df890811d449c4635e00fef265cbdcbb20ce..5300fbb76bad5ea433a63594346317a05c77dfb2 100644 (file)
@@ -1,5 +1,13 @@
 Tue Oct 18 11:12:01 1994  Ian Lance Taylor  <ian@sanguine.cygnus.com>
 
+       * objcopy.c (copy_object): If the output file format is `binary',
+       and the start address was not set using --set-start, default the
+       start address to zero.  This hack is because the `binary' output
+       file format uses the start address to set the virtual address of
+       the first byte in the file.
+       * binutils.texi, objcopy.1: Add some notes on generating S-records
+       and binary files.
+
        * nm.c (print_symdef_entry): Call print_symname to print the
        symbol name, so that --demangle works.
 
index daa177768b03bba8bd64e52a14787f7426f247af..5e2f2c7e4ab4102f66adcb21dd1fa7f1aaffe083 100644 (file)
@@ -767,6 +767,22 @@ translation work; it has access to all the formats described in @sc{bfd}
 and thus is able to recognize most formats without being told
 explicitly.  @xref{BFD,,BFD,ld.info,Using LD}.
 
+@code{objcopy} can be used to generate S-records by using an output
+target of @samp{srec} (e.g., use @samp{-O srec}).
+
+@code{objcopy} can be used to generate a raw binary file by using an
+output target of @samp{binary} (e.g., use @samp{-O binary}).  When
+@code{objcopy} generates a raw binary file, it will essentially produce
+a memory dump of the contents of the input object file.  All symbols and
+relocation information will be discarded.  By default, the memory dump
+will start at virtual address zero; the @samp{--set-start} option may be
+used to specify a different starting point.
+
+When generating an S-record or a raw binary file, it may be helpful to
+use @samp{-S} to remove sections containing debugging information.  In
+some cases @samp{-R} will be useful to remove sections which contain
+information which is not needed by the binary file.
+
 @table @code
 @item @var{infile}
 @itemx @var{outfile}
@@ -833,7 +849,9 @@ copy with the @var{-b} or @samp{--byte} option.  The default is 4.
 
 @item --set-start @var{val}
 Set the address of the new file to @var{val}.  Not all object file
-formats support setting the start address.
+formats support setting the start address.  When using the @samp{binary}
+output file format, the start address sets the virtual address of the
+first byte in the binary output file.
 
 @item --adjust-start @var{incr}
 Adjust the start address by adding @var{incr}.  Not all object file
index 365c11a6cf8a61cae334f7b522939f5b6ebb3d54..ca863ffd37efe87e130c55d23efdbf1d95f94c9e 100644 (file)
@@ -55,6 +55,34 @@ uses BFD to do all its translation work; it knows about all the
 formats BFD knows about, and thus is able to recognize most formats
 without being told explicitly.
 .PP
+.B objcopy
+can be used to generate S-records by using an output target of
+.B srec
+(e.g., use
+.B -O srec).
+.PP
+.B objcopy
+can be used to generate a raw binary file by using an output target of
+.B binary
+(e.g., use
+.B -O binary).
+When
+.B objcopy
+generates a raw binary file, it will essentially produce a memory dump
+of the contents of the input object file.  All symbols and relocation
+information will be discarded.  By default, the memory dump will start
+at virtual address zero; the
+.B --set-start
+option may be used to specify a different starting point.
+.PP
+When generating an S-record or a raw binary file, it may be helpful to
+use
+.B -S
+to remove sections containing debugging information.  In some cases
+.B -R
+will be useful to remove sections which contain information which is
+not needed by the binary file.
+.PP
 .I infile
 and
 .I outfile
@@ -112,7 +140,9 @@ The interleave is ignored if neither \fB\-b\fP nor \fB\-\-byte\fP is given.
 .TP
 .B \fB\-\-set\-start=\fIval
 Set the start address of the new file to \fIval\fP.  Not all object
-file formats support setting the start address.
+file formats support setting the start address.  When using the
+\fBbinary\fP output file format, the start address sets the virtual
+address of the first byte in the binary output file.
 .TP
 .B \fB\-\-adjust\-start=\fIincr
 Adjust the start address by adding \fIincr\fP.  Not all object file
index 70d118e03c919fe784d39168b6dc30b847231cf0..eff90c51750b7208da569e72d7b2bdf737630b7b 100644 (file)
@@ -316,7 +316,15 @@ copy_object (ibfd, obfd)
   if (set_start_set)
     start = set_start;
   else
-    start = bfd_get_start_address (ibfd);
+    {
+      /* As a special hack make it easier to generate a raw binary
+         file, we default the starting address to zero for the binary
+         output format.  */
+      if (strcmp (bfd_get_target (obfd), "binary") == 0)
+       start = 0;
+      else
+       start = bfd_get_start_address (ibfd);
+    }
   start += adjust_start;
 
   if (!bfd_set_start_address (obfd, start)
This page took 0.032021 seconds and 4 git commands to generate.