.c.o:
$(CC) -c $(ALL_CFLAGS) $<
+DEBUG_OBJS = rddbg.o debug.o stabs.o ieee.o prdbg.o
#\f
## Random definitions
# Hopefully all these may be flushed once we get configuration down pat.
$(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
@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
@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.
@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
[ -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} ]
@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
.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 "\|]"
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
\&, 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
/* 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.
#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 *));
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;}
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
#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)
{"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 */
[-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\
&& (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)
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
else
{
long symsize;
+ PTR dhandle = NULL;
symsize = bfd_get_symtab_upper_bound (ibfd);
if (symsize < 0)
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.
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);
struct section_list *p;
sec_ptr osection;
bfd_vma vma;
+ bfd_vma lma;
flagword flags;
char *err;
&& (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);
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))
&& (strip_symbols == strip_debug
|| strip_symbols == strip_unneeded
|| strip_symbols == strip_all
- || discard_locals == locals_all))
+ || discard_locals == locals_all
+ || convert_debugging))
{
return;
}
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
case OPTION_ADJUST_WARNINGS:
adjust_warn = true;
break;
+ case OPTION_DEBUGGING:
+ convert_debugging = true;
+ break;
case OPTION_GAP_FILL:
{
bfd_vma gap_fill_vma;