Subject: Fixes for bfd. Too late?
To: None <pk@cs.few.eur.nl>
From: Gordon W. Ross <gwr@mc.com>
List: tech-toolchain
Date: 04/07/1997 16:58:25
Does anyone know if it might be possible to slip these fixes into
the upcoming binutils 2.8 release? If so, where can I send this?
BFD changes for NetBSD based on gdb-4.16:
Use traditional m68k segment size (preferred on some kernels).
diff -cw ./bfd/m68knetbsd.c.orig ./bfd/m68knetbsd.c
*** ./bfd/m68knetbsd.c.orig Fri Oct 27 20:26:50 1995
--- ./bfd/m68knetbsd.c Wed Apr 2 20:52:33 1997
***************
*** 20,27 ****
#define BYTES_IN_WORD 4
#define TARGET_IS_BIG_ENDIAN_P
! #define TARGET_PAGE_SIZE 8192
! #define SEGMENT_SIZE 8192
#define DEFAULT_ARCH bfd_arch_m68k
#define MACHTYPE_OK(mtype) \
--- 20,28 ----
#define BYTES_IN_WORD 4
#define TARGET_IS_BIG_ENDIAN_P
! /* Stick with the traditional m68k values. */
! #define TARGET_PAGE_SIZE 0x2000 /* 8K */
! #define SEGMENT_SIZE 0x20000 /* 128K */
#define DEFAULT_ARCH bfd_arch_m68k
#define MACHTYPE_OK(mtype) \
Get rid of obsolete "minimum alignment" field.
diff -cw ./bfd/netbsd-core.c.orig ./bfd/netbsd-core.c
*** ./bfd/netbsd-core.c.orig Thu Feb 8 14:10:44 1996
--- ./bfd/netbsd-core.c Sat Mar 29 03:58:36 1997
***************
*** 273,279 ****
0, /* symbol prefix */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 3, /* minimum alignment power */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
--- 273,278 ----
Let NetBSD handle a.out with a non-standard link address.
diff -cw ./bfd/netbsd.h.orig ./bfd/netbsd.h
*** ./bfd/netbsd.h.orig Fri Oct 27 20:29:17 1995
--- ./bfd/netbsd.h Wed Apr 2 20:26:58 1997
***************
*** 38,43 ****
--- 38,47 ----
((exec).a_info = \
((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
+ #ifndef SEGMENT_SIZE
+ #define SEGMENT_SIZE TARGET_PAGE_SIZE
+ #endif
+
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
***************
*** 48,58 ****
--- 52,154 ----
#define SWAP_MAGIC(ext) bfd_getb32 (ext)
+ #define MY_callback MY(callback)
+ static const bfd_target * MY(callback) PARAMS ((bfd *abfd));
+
#define MY_write_object_contents MY(write_object_contents)
static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
#define MY_text_includes_header 1
#include "aout-target.h"
+
+ /* Set parameters about this a.out file that are machine-dependent.
+ This routine is called from some_aout_object_p just before it returns. */
+
+ static const bfd_target *
+ MY(callback) (abfd)
+ bfd *abfd;
+ {
+ struct internal_exec *execp = exec_hdr (abfd);
+ unsigned int arch_align_power;
+ unsigned long arch_align;
+ unsigned long vma_fix;
+
+ /* Calculate the file positions of the parts of a newly read aout header */
+ obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
+
+ /* The file offsets of the sections */
+ obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
+ obj_datasec (abfd)->filepos = N_DATOFF (*execp);
+
+ /* The file offsets of the relocation info */
+ obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
+ obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
+
+ /* The file offsets of the string table and symbol table. */
+ obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+ obj_str_filepos (abfd) = N_STROFF (*execp);
+
+ /* The virtual memory addresses of the sections */
+ obj_textsec (abfd)->vma = N_TXTADDR(*execp);
+ obj_datasec (abfd)->vma = N_DATADDR(*execp);
+ obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
+
+ /*
+ * Correct for non-standard entry point (i.e. kernel).
+ * Most a.out files with a non-standard entry point are
+ * using the a_entry field to represent the load address.
+ * XXX - Why does "aout-target.h" not do this?
+ */
+ if ((execp->a_entry & ~(SEGMENT_SIZE-1)) > N_TXTADDR(*execp)) {
+ vma_fix = (execp->a_entry & ~(SEGMENT_SIZE-1)) - N_TXTADDR(*execp);
+ obj_textsec (abfd)->vma += vma_fix;
+ obj_datasec (abfd)->vma += vma_fix;
+ obj_bsssec (abfd)->vma += vma_fix;
+ }
+
+ /* Make the load addresses the same. */
+ obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
+ obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
+ obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
+
+ /* Determine the architecture and machine type of the object file. */
+ #ifdef SET_ARCH_MACH
+ SET_ARCH_MACH(abfd, *execp);
+ #else
+ bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
+ #endif
+
+ /* Now that we know the architecture, set the alignments of the
+ sections. This is normally done by NAME(aout,new_section_hook),
+ but when the initial sections were created the architecture had
+ not yet been set. However, for backward compatibility, we don't
+ set the alignment power any higher than as required by the size
+ of the section. */
+ arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
+ arch_align = 1 << arch_align_power;
+ if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
+ == obj_textsec (abfd)->_raw_size)
+ && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
+ == obj_datasec (abfd)->_raw_size)
+ && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
+ == obj_bsssec (abfd)->_raw_size))
+ {
+ obj_textsec (abfd)->alignment_power = arch_align_power;
+ obj_datasec (abfd)->alignment_power = arch_align_power;
+ obj_bsssec (abfd)->alignment_power = arch_align_power;
+ }
+
+ /* Don't set sizes now -- can't be sure until we know arch & mach.
+ Sizes get set in set_sizes callback, later. */
+ #if 0
+ adata(abfd).page_size = TARGET_PAGE_SIZE;
+ adata(abfd).segment_size = SEGMENT_SIZE;
+ adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
+ #endif
+
+ return abfd->xvec;
+ }
+
/* Write an object file.
Section contents have already been written. We write the
Add a missing target declaration.
diff -cw ./bfd/targets.c.orig ./bfd/targets.c
*** ./bfd/targets.c.orig Tue Apr 23 00:30:04 1996
--- ./bfd/targets.c Sat Mar 29 03:37:00 1997
***************
*** 578,583 ****
--- 578,584 ----
extern const bfd_target hpux_core_vec;
extern const bfd_target hppabsd_core_vec;
extern const bfd_target irix_core_vec;
+ extern const bfd_target netbsd_core_vec;
extern const bfd_target osf_core_vec;
extern const bfd_target sco_core_vec;
extern const bfd_target trad_core_vec;
Add minimal NetBSD/VAX support.
diff -cw ./bfd/vaxnetbsd.c.orig ./bfd/vaxnetbsd.c
*** ./bfd/vaxnetbsd.c.orig Sat Mar 29 04:13:09 1997
--- ./bfd/vaxnetbsd.c Sat Mar 29 04:15:59 1997
***************
*** 0 ****
--- 1,36 ----
+ /* BFD back-end for NetBSD/vax a.out-ish binaries.
+ Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
+
+ 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.
+
+ $Id: netbsdvax.c,v 1.1 1995/06/05 15:22:53 ragge Exp $
+ */
+
+ #define BYTES_IN_WORD 4
+ #undef TARGET_IS_BIG_ENDIAN_P
+
+ #define TARGET_PAGE_SIZE 1024
+ #define SEGMENT_SIZE TARGET_PAGE_SIZE
+
+ #define DEFAULT_ARCH bfd_arch_vax
+ #define MACHTYPE_OK(mtype) ((mtype) == M_VAX || (mtype) == M_UNKNOWN)
+
+ #define MY(OP) CAT(vaxnetbsd_,OP)
+ /* This needs to start with a.out so GDB knows it is an a.out variant. */
+ #define TARGETNAME "a.out-vax-netbsd"
+
+ #include "netbsd.h"