aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1994-10-18 18:51:01 +0000
committerIan Lance Taylor <ian@airs.com>1994-10-18 18:51:01 +0000
commitc768bd3f2da5eaa0a1a458a3104670da1c0d531f (patch)
tree30c30c4cca99d7b2b825a1d34785d8b9a78fa4a1
parentd7785845ff5fbcdf50d56d944b2695bb5d3caf79 (diff)
downloadgdb-c768bd3f2da5eaa0a1a458a3104670da1c0d531f.zip
gdb-c768bd3f2da5eaa0a1a458a3104670da1c0d531f.tar.gz
gdb-c768bd3f2da5eaa0a1a458a3104670da1c0d531f.tar.bz2
* binary.c: New file for raw binary output format.
* Makefile.in (BFD_LIBS): Add binary.o. (CFILES): Add binary.c. * targets.c (binary_vec): Declare. (bfd_target_vector): Include binary_vec.
-rw-r--r--bfd/.Sanitize1
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/Makefile.in16
-rw-r--r--bfd/binary.c157
-rw-r--r--bfd/targets.c10
5 files changed, 187 insertions, 6 deletions
diff --git a/bfd/.Sanitize b/bfd/.Sanitize
index da3d301..7e997b5 100644
--- a/bfd/.Sanitize
+++ b/bfd/.Sanitize
@@ -53,6 +53,7 @@ archures.c
bfd-in.h
bfd-in2.h
bfd.c
+binary.c
bout.c
cache.c
cf-i386lynx.c
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 01e6603..84c6f1e 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,14 @@
Tue Oct 18 12:56:43 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+ * aout-target.h (MY_bfd_copy_private_section_data): Only copy
+ subformat to another bfd_target_aout_flavour file.
+
+ * binary.c: New file for raw binary output format.
+ * Makefile.in (BFD_LIBS): Add binary.o.
+ (CFILES): Add binary.c.
+ * targets.c (binary_vec): Declare.
+ (bfd_target_vector): Include binary_vec.
+
* srec.c (tdata_type): Add field tail.
(srec_mkobject): Initialize tail.
(srec_set_section_contents): Sort S record list by address.
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 6e3cdad..bdce852 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -44,7 +44,7 @@ docdir = doc
SHELL = /bin/sh
-INSTALL = install -c
+INSTALL = `cd $(srcdir)/..; pwd`/install.sh -c
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL)
@@ -86,7 +86,7 @@ BFD_LIBS = \
archive.o archures.o bfd.o cache.o coffgen.o core.o \
format.o init.o libbfd.o opncls.o reloc.o \
section.o syms.o targets.o hash.o linker.o \
- elf.o srec.o
+ elf.o srec.o binary.o
# This list is alphabetized to make it easier to keep in sync
# with the decls and initializer in archures.c.
@@ -175,6 +175,7 @@ BFD32_BACKENDS = \
pc532-mach.o \
reloc16.o \
sparclynx.o \
+ sparcnetbsd.o \
stab-syms.o \
sunos.o
@@ -232,7 +233,7 @@ ALL_CFLAGS=$(CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES)
# C source files that correspond to .o's.
CFILES = libbfd.c opncls.c bfd.c archive.c targets.c cache.c \
archures.c coff-i386.c coff-go32.c aout64.c aout32.c sunos.c demo64.c \
- coff-i960.c srec.c tekhex.c oasys.c ieee.c aout0.c \
+ coff-i960.c srec.c binary.c tekhex.c oasys.c ieee.c aout0.c \
ecoff.c ecofflink.c coff-m68k.c coff-u68k.c coff-apollo.c \
coff-a29k.c coff-rs6000.c coff-sparc.c coffgen.c format.c \
section.c core.c syms.c stab-syms.c reloc.c init.c \
@@ -251,7 +252,8 @@ CFILES = libbfd.c opncls.c bfd.c archive.c targets.c cache.c \
hp300bsd.c hp300hpux.c \
i386lynx.c cf-i386lynx.c m68klynx.c cf-m68klynx.c \
sparclynx.c cf-sparclynx.c aix386-core.c hpux-core.c \
- irix-core.c lynx-core.c osf-core.c hash.c linker.c cofflink.c
+ irix-core.c lynx-core.c osf-core.c hash.c linker.c cofflink.c \
+ ns32knetbsd.c sparcnetbsd.c
HFILES = aout-target.h aoutf1.h aoutx.h coffcode.h \
coffswap.h ecoffswap.h elf32-hppa.h elf32-target.h elf64-target.h \
@@ -758,5 +760,11 @@ hash.o: hash.c
linker.o: linker.c $(INCDIR)/bfdlink.h genlink.h
cofflink.o: cofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
libcoff.h
+ns32knetbsd.o: ns32knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+sparcnetbsd.o: sparcnetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
+ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/bfd/binary.c b/bfd/binary.c
new file mode 100644
index 0000000..a429889
--- /dev/null
+++ b/bfd/binary.c
@@ -0,0 +1,157 @@
+/* BFD back-end for binary objects.
+ Copyright 1994 Free Software Foundation, Inc.
+ Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* This is a BFD backend which may be used to write binary objects.
+ It may only be used for output, not input. The intention is that
+ this may be used as an output format for objcopy in order to
+ generate raw binary data.
+
+ This is very simple. The only complication is that the real data
+ will start at some address X, and in some cases we will not want to
+ include X zeroes just to get to that point. Since the start
+ address is not meaningful for this object file format, we use it
+ instead to indicate the number of zeroes to skip at the start of
+ the file. objcopy cooperates by specially setting the start
+ address to zero by default. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+static boolean binary_mkobject PARAMS ((bfd *));
+static asymbol *binary_make_empty_symbol PARAMS ((bfd *));
+static boolean binary_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+
+/* Create a binary object. Invoked via bfd_set_format. */
+
+static boolean
+binary_mkobject (abfd)
+ bfd *abfd;
+{
+ return true;
+}
+
+/* Most of the symbol routines can just return an error. */
+#define binary_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
+#define binary_get_symtab _bfd_nosymbols_get_symtab
+#define binary_print_symbol _bfd_nosymbols_print_symbol
+#define binary_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define binary_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
+#define binary_get_lineno _bfd_nosymbols_get_lineno
+#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+
+/* We do have to provide a routine to make an empty symbol. */
+
+static asymbol *
+binary_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *ret;
+
+ ret = (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
+ if (ret == NULL)
+ bfd_set_error (bfd_error_no_memory);
+ return ret;
+}
+
+/* Set the architecture of a binary file. */
+#define binary_set_arch_mach _bfd_generic_set_arch_mach
+
+/* Write section contents of a binary file. */
+
+static boolean
+binary_set_section_contents (abfd, sec, data, offset, size)
+ bfd *abfd;
+ asection *sec;
+ PTR data;
+ file_ptr offset;
+ bfd_size_type size;
+{
+ /* In a binary file, the file position of a section is just the VMA
+ minus the start address. */
+ sec->filepos = bfd_section_vma (abfd, sec) - bfd_get_start_address (abfd);
+
+ if (sec->filepos + offset < 0)
+ {
+ file_ptr adjust;
+
+ adjust = - (sec->filepos + offset);
+ if (size <= adjust)
+ return true;
+ size -= adjust;
+ data = (PTR) ((bfd_byte *) data + adjust);
+ offset += adjust;
+ }
+
+ return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
+}
+
+const bfd_target binary_vec =
+{
+ "binary", /* name */
+ bfd_target_unknown_flavour, /* flavour */
+ true, /* byteorder_big_p */
+ true, /* header_byteorder_big_p */
+ EXEC_P, /* object_flags */
+ (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
+ | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
+ 0, /* symbol_leading_char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ 1, /* align_power_min */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ { /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ { /* bfd_set_format */
+ bfd_false,
+ binary_mkobject,
+ bfd_false,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ bfd_true,
+ bfd_false,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (binary),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (binary),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ NULL
+};
diff --git a/bfd/targets.c b/bfd/targets.c
index f73b3ce..085028d 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -476,7 +476,7 @@ extern const bfd_target nlm32_i386_vec;
extern const bfd_target nlm32_sparc_vec;
extern const bfd_target nlm32_alpha_vec;
extern const bfd_target nlm32_powerpc_vec;
-extern const bfd_target ns32knetbsd_vec;
+extern const bfd_target pc532netbsd_vec;
extern const bfd_target oasys_vec;
extern const bfd_target pc532machaout_vec;
extern const bfd_target riscix_vec;
@@ -495,6 +495,9 @@ extern const bfd_target z8kcoff_vec;
extern const bfd_target srec_vec;
extern const bfd_target symbolsrec_vec;
+/* binary is always included. */
+extern const bfd_target binary_vec;
+
/* All of the xvecs for core files. */
extern const bfd_target aix386_core_vec;
extern const bfd_target cisco_core_vec;
@@ -611,7 +614,7 @@ const bfd_target * const bfd_target_vector[] = {
#ifdef BFD64
&nlm32_alpha_vec,
#endif
- &ns32knetbsd_vec,
+ &pc532netbsd_vec,
#if 0
/* We have no oasys tools anymore, so we can't test any of this
anymore. If you want to test the stuff yourself, go ahead...
@@ -644,6 +647,9 @@ const bfd_target * const bfd_target_vector[] = {
&srec_vec,
&symbolsrec_vec,
+/* Likewise for binary output. */
+ &binary_vec,
+
/* Add any required traditional-core-file-handler. */
#ifdef AIX386_CORE