aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1996-01-08 23:18:29 +0000
committerIan Lance Taylor <ian@airs.com>1996-01-08 23:18:29 +0000
commitf5818d79ddec0f5cd55bf625e2e8602b09113947 (patch)
tree2e150465428578c44c2d5ecc65f1927ee1a399cf /binutils
parent1a418120d70669361141f1de2bdb490a63df22e1 (diff)
downloadgdb-f5818d79ddec0f5cd55bf625e2e8602b09113947.zip
gdb-f5818d79ddec0f5cd55bf625e2e8602b09113947.tar.gz
gdb-f5818d79ddec0f5cd55bf625e2e8602b09113947.tar.bz2
* objcopy.c: Include budbg.h.
(convert_debugging): New static variable. (OPTION_DEBUGGING): Define. (copy_options): Add "debugging". (copy_usage): Mention --debugging. (is_strip_section): Skip debugging sections if convert_debugging. (setup_section, copy_section): Likewise. (filter_symbols): Skip debugging symbols if convert_debugging. (copy_object): If convert_debugging, read and write debugging information. (write_debugging_info): New static function. (copy_main): Handle --debugging. * Makefile.in (DEBUG_OBJS): New variable. ($(OBJCOPY_PROG)): Depend upon and link against $(DEBUG_OBJS). ($(STRIP_PROG)): Likewise. (OBJDUMP_OBJS): Remove variable. ($(OBJDUMP_PROG)): Use objdump.o $(DEBUG_OBJS) rather than $(OBJDUMP_OBJS). * binutils.texi, objcopy.1: Document --debugging.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/Makefile.in15
-rw-r--r--binutils/binutils.texi12
-rw-r--r--binutils/objcopy.18
-rw-r--r--binutils/objcopy.c78
4 files changed, 91 insertions, 22 deletions
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index 6801d56..b261d67 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -144,6 +144,7 @@ GENERATED_CFILES = \
.c.o:
$(CC) -c $(ALL_CFLAGS) $<
+DEBUG_OBJS = rddbg.o debug.o stabs.o ieee.o prdbg.o
#
## Random definitions
# Hopefully all these may be flushed once we get configuration down pat.
@@ -256,22 +257,20 @@ dvi: binutils.dvi
$(SIZE_PROG): $(ADDL_LIBS) size.o $(BFD)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(SIZE_PROG) size.o $(ADDL_LIBS) $(EXTRALIBS)
-$(OBJCOPY_PROG): $(ADDL_LIBS) objcopy.o not-strip.o $(BFD)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o not-strip.o $(ADDL_LIBS) $(EXTRALIBS)
+$(OBJCOPY_PROG): $(ADDL_LIBS) objcopy.o not-strip.o $(DEBUG_OBJS) $(BFD)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o not-strip.o $(DEBUG_OBJS) $(ADDL_LIBS) $(EXTRALIBS)
$(STRINGS_PROG): $(ADDL_LIBS) strings.o $(BFD)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(STRINGS_PROG) strings.o $(ADDL_LIBS) $(EXTRALIBS)
-$(STRIP_PROG): $(ADDL_LIBS) objcopy.o is-strip.o $(BFD)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(STRIP_PROG) objcopy.o is-strip.o $(ADDL_LIBS) $(EXTRALIBS)
+$(STRIP_PROG): $(ADDL_LIBS) objcopy.o is-strip.o $(DEBUG_OBJS) $(BFD)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $(STRIP_PROG) objcopy.o is-strip.o $(DEBUG_OBJS) $(ADDL_LIBS) $(EXTRALIBS)
$(NM_PROG): $(ADDL_LIBS) nm.o $(BFD)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(NM_PROG) nm.o $(ADDL_LIBS) $(EXTRALIBS)
-OBJDUMP_OBJS = objdump.o rddbg.o debug.o stabs.o ieee.o prdbg.o
-
-$(OBJDUMP_PROG): $(ADDL_LIBS) $(OBJDUMP_OBJS) $(BFD) $(OPCODES)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(OBJDUMP_PROG) $(OBJDUMP_OBJS) $(OPCODES) $(ADDL_LIBS) $(EXTRALIBS)
+$(OBJDUMP_PROG): $(ADDL_LIBS) objdump.o $(DEBUG_OBJS) $(BFD) $(OPCODES)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $(OBJDUMP_PROG) objdump.o $(DEBUG_OBJS) $(OPCODES) $(ADDL_LIBS) $(EXTRALIBS)
underscore.c: stamp-under ; @true
diff --git a/binutils/binutils.texi b/binutils/binutils.texi
index fbec8be..31df7f1 100644
--- a/binutils/binutils.texi
+++ b/binutils/binutils.texi
@@ -13,7 +13,7 @@ END-INFO-DIR-ENTRY
@end ifinfo
@ifinfo
-Copyright @copyright{} 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+Copyright @copyright{} 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -41,7 +41,7 @@ into another language, under the above conditions for modified versions.
@c This file documents the GNU binary utilities "ar", "ld", "objcopy",
@c "objdump", "nm", "size", "strings", "strip", and "ranlib".
@c
-@c Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+@c Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
@c
@c This text may be freely distributed under the terms of the GNU
@c General Public License.
@@ -66,7 +66,7 @@ into another language, under the above conditions for modified versions.
@end tex
@vskip 0pt plus 1filll
-Copyright @copyright{} 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+Copyright @copyright{} 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -763,6 +763,7 @@ objcopy [ -F @var{bfdname} | --target=@var{bfdname} ]
[ -b @var{byte} | --byte=@var{byte} ]
[ -i @var{interleave} | --interleave=@var{interleave} ]
[ -R @var{sectionname} | --remove-section=@var{sectionname} ]
+ [ --debugging ]
[ --gap-fill=@var{val} ] [ --pad-to=@var{address} ]
[ --set-start=@var{val} ] [ --adjust-start=@var{incr} ]
[ --adjust-vma=@var{incr} ]
@@ -879,6 +880,11 @@ copy with the @var{-b} or @samp{--byte} option. The default is 4.
@code{objcopy} ignores this option if you do not specify either @samp{-b} or
@samp{--byte}.
+@item --debugging
+Convert debugging information, if possible. This is not the default
+because only certain debugging formats are supported, and the
+conversion process can be time consuming.
+
@item --gap-fill @var{val}
Fill gaps between sections with @var{val}. This is done by increasing
the size of the section with the lower address, and filling in the extra
diff --git a/binutils/objcopy.1 b/binutils/objcopy.1
index 7694cf4..c2d5c5c 100644
--- a/binutils/objcopy.1
+++ b/binutils/objcopy.1
@@ -28,6 +28,7 @@ objcopy \- copy and translate object files
.RB "[\|" \-X\fR\ |\ \fB\-\-discard\-locals\fR "\|]"
.RB "[\|" \-b\ \fIbyte\fR\ |\ \fB\-\-byte=\fIbyte\fR "\|]"
.RB "[\|" \-i\ \fIinterleave\fR\ |\ \fB\-\-interleave=\fIinterleave\fR "\|]"
+.RB "[\|" \-\-debugging "\|]"
.RB "[\|" \-\-gap\-fill=\fIval\fR "\|]"
.RB "[\|" \-\-pad\-to=\fIaddress\fR "\|]"
.RB "[\|" \-\-set\-start=\fIval\fR "\|]"
@@ -155,6 +156,11 @@ Only copy one out of every \fIinterleave\fP bytes. Which one to copy is
selected by the \fB\-b\fP or \fB\-\-byte\fP option. The default is 4.
The interleave is ignored if neither \fB\-b\fP nor \fB\-\-byte\fP is given.
.TP
+.B \-\-debugging
+Convert debugging information, if possible. This is not the default
+because only certain debugging formats are supported, and the
+conversion process can be time consuming.
+.TP
.B \-\-gap\-fill=\fIval
Fill gaps between sections with \fIval\fP. This is done by increasing
the size of the section with the lower address, and filling in the extra
@@ -236,7 +242,7 @@ The GNU Binary Utilities\c
\&, Roland H. Pesch (June 1993).
.SH COPYING
-Copyright (c) 1993,1994 Free Software Foundation, Inc.
+Copyright (c) 1993, 94, 95, 1996 Free Software Foundation, Inc.
.PP
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index be63d83..e812ac8 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1,5 +1,5 @@
/* objcopy.c -- copy object file from input to output, optionally massaging it.
- Copyright (C) 1991, 92, 93, 94 Free Software Foundation, Inc.
+ Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -20,8 +20,9 @@
#include "bfd.h"
#include "progress.h"
#include "bucomm.h"
-#include <getopt.h>
+#include "getopt.h"
#include "libiberty.h"
+#include "budbg.h"
#include <sys/stat.h>
static flagword parse_flags PARAMS ((const char *));
@@ -36,6 +37,7 @@ static boolean is_strip_section PARAMS ((bfd *, asection *));
static unsigned int filter_symbols
PARAMS ((bfd *, asymbol **, asymbol **, long));
static void mark_symbols_used_in_relocations PARAMS ((bfd *, asection *, PTR));
+static boolean write_debugging_info PARAMS ((bfd *, PTR, long *, asymbol ***));
#define nonfatal(s) {bfd_nonfatal(s); status = 1; return;}
@@ -132,6 +134,10 @@ struct section_add
static struct section_add *add_sections;
+/* Whether to convert debugging information. */
+
+static boolean convert_debugging = false;
+
/* 150 isn't special; it's just an arbitrary non-ASCII char value. */
#define OPTION_ADD_SECTION 150
@@ -139,7 +145,8 @@ static struct section_add *add_sections;
#define OPTION_ADJUST_VMA (OPTION_ADJUST_START + 1)
#define OPTION_ADJUST_SECTION_VMA (OPTION_ADJUST_VMA + 1)
#define OPTION_ADJUST_WARNINGS (OPTION_ADJUST_SECTION_VMA + 1)
-#define OPTION_GAP_FILL (OPTION_ADJUST_WARNINGS + 1)
+#define OPTION_DEBUGGING (OPTION_ADJUST_WARNINGS + 1)
+#define OPTION_GAP_FILL (OPTION_DEBUGGING + 1)
#define OPTION_NO_ADJUST_WARNINGS (OPTION_GAP_FILL + 1)
#define OPTION_PAD_TO (OPTION_NO_ADJUST_WARNINGS + 1)
#define OPTION_SET_SECTION_FLAGS (OPTION_PAD_TO + 1)
@@ -180,6 +187,7 @@ static struct option copy_options[] =
{"adjust-section-vma", required_argument, 0, OPTION_ADJUST_SECTION_VMA},
{"adjust-warnings", no_argument, 0, OPTION_ADJUST_WARNINGS},
{"byte", required_argument, 0, 'b'},
+ {"debugging", no_argument, 0, OPTION_DEBUGGING},
{"discard-all", no_argument, 0, 'x'},
{"discard-locals", no_argument, 0, 'X'},
{"format", required_argument, 0, 'F'}, /* Obsolete */
@@ -226,10 +234,11 @@ Usage: %s [-vVSgxX] [-I bfdname] [-O bfdname] [-F bfdname] [-b byte]\n\
[-R section] [-i interleave] [--interleave=interleave] [--byte=byte]\n\
[--input-target=bfdname] [--output-target=bfdname] [--target=bfdname]\n\
[--strip-all] [--strip-debug] [--strip-unneeded] [--discard-all]\n\
- [--discard-locals] [--remove-section=section] [--gap-fill=val]\n",
+ [--discard-locals] [--debugging] [--remove-section=section]\n",
program_name);
fprintf (stream, "\
- [--pad-to=address] [--set-start=val] [--adjust-start=incr]\n\
+ [--gap-fill=val] [--pad-to=address]\n\
+ [--set-start=val] [--adjust-start=incr]\n\
[--adjust-vma=incr] [--adjust-section-vma=section{=,+,-}val]\n\
[--adjust-warnings] [--no-adjust-warnings]\n\
[--set-section-flags=section=flags] [--add-section=sectionname=filename]\n\
@@ -392,7 +401,8 @@ is_strip_section (abfd, sec)
&& (strip_symbols == strip_debug
|| strip_symbols == strip_unneeded
|| strip_symbols == strip_all
- || discard_locals == locals_all))
+ || discard_locals == locals_all
+ || convert_debugging))
return true;
if (! sections_removed)
@@ -428,7 +438,8 @@ filter_symbols (abfd, osyms, isyms, symcount)
keep = strip_symbols != strip_unneeded;
else if ((flags & BSF_DEBUGGING) != 0) /* Debugging symbol. */
keep = (strip_symbols != strip_debug
- && strip_symbols != strip_unneeded);
+ && strip_symbols != strip_unneeded
+ && ! convert_debugging);
else /* Local symbol. */
keep = (strip_symbols != strip_unneeded
&& (discard_locals != locals_all
@@ -660,6 +671,7 @@ copy_object (ibfd, obfd)
else
{
long symsize;
+ PTR dhandle = NULL;
symsize = bfd_get_symtab_upper_bound (ibfd);
if (symsize < 0)
@@ -674,11 +686,15 @@ copy_object (ibfd, obfd)
nonfatal (bfd_get_filename (ibfd));
}
+ if (convert_debugging)
+ dhandle = read_debugging_info (ibfd, isympp, symcount);
+
if (strip_symbols == strip_debug
|| strip_symbols == strip_unneeded
|| discard_locals != locals_undef
|| strip_specific_list != NULL
- || sections_removed)
+ || sections_removed
+ || convert_debugging)
{
/* Mark symbols used in output relocations so that they
are kept, even if they are local labels or static symbols.
@@ -694,6 +710,15 @@ copy_object (ibfd, obfd)
osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *));
symcount = filter_symbols (ibfd, osympp, isympp, symcount);
}
+
+ if (convert_debugging && dhandle != NULL)
+ {
+ if (! write_debugging_info (obfd, dhandle, &symcount, &osympp))
+ {
+ status = 1;
+ return;
+ }
+ }
}
bfd_set_symtab (obfd, osympp, symcount);
@@ -968,6 +993,7 @@ setup_section (ibfd, isection, obfdarg)
struct section_list *p;
sec_ptr osection;
bfd_vma vma;
+ bfd_vma lma;
flagword flags;
char *err;
@@ -975,7 +1001,8 @@ setup_section (ibfd, isection, obfdarg)
&& (strip_symbols == strip_debug
|| strip_symbols == strip_unneeded
|| strip_symbols == strip_all
- || discard_locals == locals_all))
+ || discard_locals == locals_all
+ || convert_debugging))
return;
p = find_section_list (bfd_section_name (ibfd, isection), false);
@@ -1013,6 +1040,15 @@ setup_section (ibfd, isection, obfdarg)
goto loser;
}
+ lma = isection->lma;
+ if (p != NULL && p->adjust == adjust_vma)
+ lma += p->val;
+ else if (p != NULL && p->adjust == set_vma)
+ lma = p->val;
+ else
+ lma += adjust_section_vma;
+ osection->lma = lma;
+
if (bfd_set_section_alignment (obfd,
osection,
bfd_section_alignment (ibfd, isection))
@@ -1077,7 +1113,8 @@ copy_section (ibfd, isection, obfdarg)
&& (strip_symbols == strip_debug
|| strip_symbols == strip_unneeded
|| strip_symbols == strip_all
- || discard_locals == locals_all))
+ || discard_locals == locals_all
+ || convert_debugging))
{
return;
}
@@ -1254,6 +1291,24 @@ mark_symbols_used_in_relocations (ibfd, isection, symbolsarg)
free (relpp);
}
+/* Write out debugging information. */
+
+static boolean
+write_debugging_info (obfd, dhandle, symcountp, symppp)
+ bfd *obfd;
+ PTR dhandle;
+ long *symcountp;
+ asymbol ***symppp;
+{
+ if (bfd_get_flavour (obfd) == bfd_target_ieee_flavour)
+ return write_ieee_debugging_info (obfd, dhandle);
+
+ fprintf (stderr,
+ "%s: don't know how to write debugging information for %s\n",
+ bfd_get_filename (obfd), bfd_get_target (obfd));
+ return false;
+}
+
/* The number of bytes to copy at once. */
#define COPY_BUF 8192
@@ -1679,6 +1734,9 @@ copy_main (argc, argv)
case OPTION_ADJUST_WARNINGS:
adjust_warn = true;
break;
+ case OPTION_DEBUGGING:
+ convert_debugging = true;
+ break;
case OPTION_GAP_FILL:
{
bfd_vma gap_fill_vma;