Mon Jun 20 11:06:27 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+ * Many files: change all bfd_target vectors to be const. Change
+ all uses of bfd_target * to be const bfd_target *. Change
+ bfd_target_vector and bfd_default_vector arrays to be const
+ bfd_target * const *.
+
* ecoff.c, libecoff.h, ecoffswap.h, coff-alpha.c, coff-mips.c,
elf32-mips.c: Renamed all externally visible ECOFF routines which
are local to BFD to start with _bfd_ecoff instead of just ecoff.
#include "aout/ar.h"
#include "libaout.h" /* BFD a.out internal data structures */
-bfd_target *encap_real_callback ();
+const bfd_target *encap_real_callback ();
-bfd_target *
+const bfd_target *
encap_object_p (abfd)
bfd *abfd;
{
}
/* Finish up the reading of a encapsulated-coff a.out file header */
-bfd_target *
+const bfd_target *
encap_real_callback (abfd)
bfd *abfd;
{
aout_@var{size}_some_aout_object_p
SYNOPSIS
- bfd_target *aout_@var{size}_some_aout_object_p
+ const bfd_target *aout_@var{size}_some_aout_object_p
(bfd *abfd,
- bfd_target *(*callback_to_real_object_p)());
+ const bfd_target *(*callback_to_real_object_p)());
DESCRIPTION
Some a.out variant thinks that the file open in @var{abfd}
handle any last-minute setup.
*/
-bfd_target *
+const bfd_target *
NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
bfd *abfd;
struct internal_exec *execp;
- bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
+ const bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
{
struct aout_data_struct *rawptr, *oldrawptr;
- bfd_target *result;
+ const bfd_target *result;
rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
if (rawptr == NULL) {
}
-bfd_target *
+const bfd_target *
bfd_generic_archive_p (abfd)
bfd *abfd;
{
CONST char *filename;
/* A pointer to the target jump table. */
- struct bfd_target *xvec;
+ const struct bfd_target *xvec;
/* To avoid dragging too many header files into every file that
includes `<<bfd.h>>', IOSTREAM has been declared as a "char
bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
- struct bfd_target * (*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
+ const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
PTR backend_data;
} bfd_target;
-bfd_target *
+const bfd_target *
bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd));
-CONST char **
+const char **
bfd_target_list PARAMS ((void));
boolean
static void perform_slip PARAMS ((bfd *abfd, unsigned int slip,
asection *input_section, bfd_vma value));
static boolean b_out_squirt_out_relocs PARAMS ((bfd *abfd, asection *section));
-static bfd_target *b_out_callback PARAMS ((bfd *));
+static const bfd_target *b_out_callback PARAMS ((bfd *));
static bfd_reloc_status_type calljx_callback
PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR src, PTR dst,
asection *));
}
-static bfd_target *
+static const bfd_target *
b_out_object_p (abfd)
bfd *abfd;
{
/* Finish up the opening of a b.out file for reading. Fill in all the
fields that are not handled by common code. */
-static bfd_target *
+static const bfd_target *
b_out_callback (abfd)
bfd *abfd;
{
abfd->tdata.bout_data = rawptr;
exec_hdr (abfd) = &rawptr->e;
- /* For simplicity's sake we just make all the sections right here. */
obj_textsec (abfd) = (asection *)NULL;
obj_datasec (abfd) = (asection *)NULL;
obj_bsssec (abfd) = (asection *)NULL;
- bfd_make_section (abfd, ".text");
- bfd_make_section (abfd, ".data");
- bfd_make_section (abfd, ".bss");
-
return true;
}
{
struct external_exec swapped_hdr;
+ if (! aout_32_make_sections (abfd))
+ return false;
+
exec_hdr (abfd)->a_info = BMAGIC;
exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
case BFD_RELOC_I960_CALLJ:
return &howto_reloc_callj;
case BFD_RELOC_32:
+ case BFD_RELOC_CTOR:
return &howto_reloc_abs32;
case BFD_RELOC_24_PCREL:
return &howto_reloc_pcrel24;
{
if (abfd->output_has_begun == false) { /* set by bfd.c handler */
- if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL) /*||
- (obj_textsec (abfd)->_cooked_size == 0) || (obj_datasec (abfd)->_cooked_size == 0)*/) {
- bfd_set_error (bfd_error_invalid_operation);
+ if (! aout_32_make_sections (abfd))
return false;
- }
obj_textsec (abfd)->filepos = sizeof(struct internal_exec);
obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos
#define b_out_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define b_out_bfd_final_link _bfd_generic_final_link
-bfd_target b_out_vec_big_host =
+const bfd_target b_out_vec_big_host =
{
"b.out.big", /* name */
bfd_target_aout_flavour,
};
-bfd_target b_out_vec_little_host =
+const bfd_target b_out_vec_little_host =
{
"b.out.little", /* name */
bfd_target_aout_flavour,
#include "coffcode.h"
-bfd_target a29kcoff_big_vec =
+const bfd_target a29kcoff_big_vec =
{
"coff-a29k-big", /* name */
bfd_target_coff_flavour,
\f
/* Prototypes for static functions. */
-static bfd_target *alpha_ecoff_object_p PARAMS ((bfd *));
+static const bfd_target *alpha_ecoff_object_p PARAMS ((bfd *));
static boolean alpha_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr));
static void alpha_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
struct internal_reloc *));
\f
/* Recognize an Alpha ECOFF file. */
-static bfd_target *
+static const bfd_target *
alpha_ecoff_object_p (abfd)
bfd *abfd;
{
- static bfd_target *ret;
+ static const bfd_target *ret;
ret = coff_object_p (abfd);
- if (ret != (bfd_target *) NULL)
+ if (ret != NULL)
{
asection *sec;
/* Relaxing sections is generic. */
#define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
-bfd_target ecoffalpha_little_vec =
+const bfd_target ecoffalpha_little_vec =
{
"ecoff-littlealpha", /* name */
bfd_target_ecoff_flavour,
--- /dev/null
+/* BFD back-end for Intel 386 COFF files (go32 variant).
+ Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+ Written by DJ Delorie.
+
+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. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "obstack.h"
+#include "coff/i386.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+static bfd_reloc_status_type coff_go32_reloc PARAMS ((bfd *abfd,
+ arelent *reloc_entry,
+ asymbol *symbol,
+ PTR data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message));
+
+/* For some reason when using i386 COFF the value stored in the .text
+ section for a reference to a common symbol is the value itself plus
+ any desired offset. Ian Taylor, Cygnus Support. */
+
+/* If we are producing relocateable output, we need to do some
+ adjustments to the object file that are not done by the
+ bfd_perform_relocation function. This function is called by every
+ reloc type to make any required adjustments. */
+
+static bfd_reloc_status_type
+coff_go32_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ symvalue diff;
+
+ if (output_bfd == (bfd *) NULL)
+ return bfd_reloc_continue;
+
+ if (bfd_is_com_section (symbol->section))
+ {
+ /* We are relocating a common symbol. The current value in the
+ object file is ORIG + OFFSET, where ORIG is the value of the
+ common symbol as seen by the object file when it was compiled
+ (this may be zero if the symbol was undefined) and OFFSET is
+ the offset into the common symbol (normally zero, but may be
+ non-zero when referring to a field in a common structure).
+ ORIG is the negative of reloc_entry->addend, which is set by
+ the CALC_ADDEND macro below. We want to replace the value in
+ the object file with NEW + OFFSET, where NEW is the value of
+ the common symbol which we are going to put in the final
+ object file. NEW is symbol->value. */
+ diff = symbol->value + reloc_entry->addend;
+ }
+ else
+ {
+ /* For some reason bfd_perform_relocation always effectively
+ ignores the addend for a COFF target when producing
+ relocateable output. This seems to be always wrong for 386
+ COFF, so we handle the addend here instead. */
+ diff = reloc_entry->addend;
+ }
+
+#define DOIT(x) \
+ x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
+
+ if (diff != 0)
+ {
+ const reloc_howto_type *howto = reloc_entry->howto;
+ unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = bfd_get_8 (abfd, addr);
+ DOIT (x);
+ bfd_put_8 (abfd, x, addr);
+ }
+ break;
+
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, addr);
+ DOIT (x);
+ bfd_put_16 (abfd, x, addr);
+ }
+ break;
+
+ case 2:
+ {
+ long x = bfd_get_32 (abfd, addr);
+ DOIT (x);
+ bfd_put_32 (abfd, x, addr);
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ /* Now let bfd_perform_relocation finish everything up. */
+ return bfd_reloc_continue;
+}
+
+static reloc_howto_type howto_table[] =
+{
+ {0},
+ {1},
+ {2},
+ {3},
+ {4},
+ {5},
+ HOWTO (R_DIR32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_go32_reloc, /* special_function */
+ "dir32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+ {7},
+ {010},
+ {011},
+ {012},
+ {013},
+ {014},
+ {015},
+ {016},
+ HOWTO (R_RELBYTE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_go32_reloc, /* special_function */
+ "8", /* name */
+ true, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ false), /* pcrel_offset */
+ HOWTO (R_RELWORD, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_go32_reloc, /* special_function */
+ "16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+ HOWTO (R_RELLONG, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_go32_reloc, /* special_function */
+ "32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+ HOWTO (R_PCRBYTE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_go32_reloc, /* special_function */
+ "DISP8", /* name */
+ true, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ false), /* pcrel_offset */
+ HOWTO (R_PCRWORD, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_go32_reloc, /* special_function */
+ "DISP16", /* name */
+ true, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ false), /* pcrel_offset */
+ HOWTO (R_PCRLONG, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ coff_go32_reloc, /* special_function */
+ "DISP32", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false) /* pcrel_offset */
+};
+
+/* Turn a howto into a reloc nunmber */
+
+#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
+#define BADMAG(x) I386BADMAG(x)
+#define I386 1 /* Customize coffcode.h */
+
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ cache_ptr->howto = howto_table + (dst)->r_type;
+
+/* On SCO Unix 3.2.2 the native assembler generates two .data
+ sections. We handle that by renaming the second one to .data2. It
+ does no harm to do this for any 386 COFF target. */
+#define TWO_DATA_SECS
+
+/* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
+ library. On some other COFF targets STYP_BSS is normally
+ STYP_NOLOAD. */
+#define BSS_NOLOAD_IS_SHARED_LIBRARY
+
+/* Compute the addend of a reloc. If the reloc is to a common symbol,
+ the object file contains the value of the common symbol. By the
+ time this is called, the linker may be using a different symbol
+ from a different object file with a different value. Therefore, we
+ hack wildly to locate the original symbol from this file so that we
+ can make the correct adjustment. This macro sets coffsym to the
+ symbol from the original file, and uses it to set the addend value
+ correctly. If this is not a common symbol, the usual addend
+ calculation is done, except that an additional tweak is needed for
+ PC relative relocs.
+ FIXME: This macro refers to symbols and asect; these are from the
+ calling function, not the macro arguments. */
+
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ { \
+ coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
+ if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
+ coffsym = (obj_symbols (abfd) \
+ + (cache_ptr->sym_ptr_ptr - symbols)); \
+ else if (ptr) \
+ coffsym = coff_symbol_from (abfd, ptr); \
+ if (coffsym != (coff_symbol_type *) NULL \
+ && coffsym->native->u.syment.n_scnum == 0) \
+ cache_ptr->addend = - coffsym->native->u.syment.n_value; \
+ else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
+ && ptr->section != (asection *) NULL) \
+ cache_ptr->addend = - (ptr->section->vma + ptr->value); \
+ else \
+ cache_ptr->addend = 0; \
+ if (ptr && howto_table[reloc.r_type].pc_relative) \
+ cache_ptr->addend += asect->vma; \
+ }
+
+#include "coffcode.h"
+
+static const bfd_target *
+go32coff_object_p(a)
+ bfd *a;
+{
+ return coff_object_p(a);
+}
+
+static const bfd_target *
+go32coff_archive_p(a)
+ bfd *a;
+{
+ return 0;
+}
+
+const bfd_target
+#ifdef TARGET_SYM
+ TARGET_SYM =
+#else
+ go32coff_vec =
+#endif
+{
+#ifdef TARGET_NAME
+ TARGET_NAME,
+#else
+ "coff-go32", /* name */
+#endif
+ bfd_target_coff_flavour,
+ false, /* data byte order is little */
+ false, /* header byte order is little */
+
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ '_', /* leading underscore */
+ '/', /* ar_pad_char */
+ 15, /* ar_max_namelen */
+
+ 2, /* minimum alignment power */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+/* Note that we allow an object file to be treated as a core file as well. */
+ {_bfd_dummy_target, go32coff_object_p, /* bfd_check_format */
+ bfd_generic_archive_p, go32coff_object_p},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
+ bfd_false},
+ {bfd_false, coff_write_object_contents, /* bfd_write_contents */
+ _bfd_write_archive_contents, bfd_false},
+
+ BFD_JUMP_TABLE_GENERIC (coff),
+ BFD_JUMP_TABLE_COPY (coff),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+ BFD_JUMP_TABLE_SYMBOLS (coff),
+ BFD_JUMP_TABLE_RELOCS (coff),
+ BFD_JUMP_TABLE_WRITE (coff),
+ BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ COFF_SWAP_TABLE,
+};
HOWTO (R_JMP2, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "pcrecl/16", true, 0x000000ff, 0x000000ff, false),
- HOWTO (R_JMPL1, 0, 1, 32, false, 0, complain_overflow_bitfield, 0, "24/pcrell", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO (R_JMPL1, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "24/pcrell", true, 0x00ffffff, 0x00ffffff, false),
HOWTO (R_JMPL_B8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "pc8/24", true, 0x000000ff, 0x000000ff, false),
HOWTO (R_MOVLB1, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "24/8", true, 0x0000ffff, 0x0000ffff, false),
+ dst_address
+ link_order->u.indirect.section->output_section->vma;
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
- - dot) + 1;
+ - dot) - 1;
if (gap > 32767 || gap < -32768)
{
if (! ((*link_info->callbacks->reloc_overflow)
-bfd_target h8300coff_vec =
+const bfd_target h8300coff_vec =
{
"coff-h8300", /* name */
bfd_target_coff_flavour,
BFD_JUMP_TABLE_RELOCS (coff),
BFD_JUMP_TABLE_WRITE (coff),
BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
COFF_SWAP_TABLE,
};
bfd_coff_reloc16_get_relocated_section_contents
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
-bfd_target h8500coff_vec =
+const bfd_target h8500coff_vec =
{
"coff-h8500", /* name */
bfd_target_coff_flavour,
BFD_JUMP_TABLE_RELOCS (coff),
BFD_JUMP_TABLE_WRITE (coff),
BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
COFF_SWAP_TABLE,
};
/* Relaxing sections is MIPS specific. */
#define _bfd_ecoff_bfd_relax_section mips_relax_section
-bfd_target ecoff_little_vec =
+const bfd_target ecoff_little_vec =
{
"ecoff-littlemips", /* name */
bfd_target_ecoff_flavour,
(PTR) &mips_ecoff_backend_data
};
-bfd_target ecoff_big_vec =
+const bfd_target ecoff_big_vec =
{
"ecoff-bigmips", /* name */
bfd_target_ecoff_flavour,
bfd_coff_reloc16_get_relocated_section_contents
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
-bfd_target shcoff_vec =
+const bfd_target shcoff_vec =
{
"coff-sh", /* name */
bfd_target_coff_flavour,
BFD_JUMP_TABLE_RELOCS (coff),
BFD_JUMP_TABLE_WRITE (coff),
BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
COFF_SWAP_TABLE,
};
bfd_coff_reloc16_get_relocated_section_contents
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
-bfd_target z8kcoff_vec =
+const bfd_target z8kcoff_vec =
{
"coff-z8k", /* name */
bfd_target_coff_flavour,
BFD_JUMP_TABLE_RELOCS (coff),
BFD_JUMP_TABLE_WRITE (coff),
BFD_JUMP_TABLE_LINK (coff),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
COFF_SWAP_TABLE,
};
/* Read in a COFF object and make it into a BFD. This is used by
ECOFF as well. */
-static
-bfd_target *
+static const bfd_target *
coff_real_object_p (abfd, nscns, internal_f, internal_a)
bfd *abfd;
unsigned nscns;
if (!(internal_f->f_flags & F_LSYMS))
abfd->flags |= HAS_LOCALS;
+ /* FIXME: How can we set D_PAGED correctly? */
+ if ((internal_f->f_flags & F_EXEC) != 0)
+ abfd->flags |= D_PAGED;
bfd_get_symcount(abfd) = internal_f->f_nsyms;
if (internal_f->f_nsyms)
return abfd->xvec;
fail:
bfd_release(abfd, tdata);
- return (bfd_target *)NULL;
+ return (const bfd_target *)NULL;
}
/* Turn a COFF file into a BFD, but fail with bfd_error_wrong_format if it is
not a COFF file. This is also used by ECOFF. */
-bfd_target *
+const bfd_target *
coff_object_p (abfd)
bfd *abfd;
{
/* See whether this BFD is an archive. If it is, read in the armap
and the extended name table. */
-bfd_target *
+const bfd_target *
_bfd_ecoff_archive_p (abfd)
bfd *abfd;
{
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
/* We are setting bfd_ardata(abfd) here, but since bfd_ardata
if (bfd_ardata (abfd) == (struct artdata *) NULL)
{
bfd_set_error (bfd_error_no_memory);
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
bfd_ardata (abfd)->first_file_filepos = SARMAG;
{
bfd_release (abfd, bfd_ardata (abfd));
abfd->tdata.aout_ar_data = (struct artdata *) NULL;
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
return abfd->xvec;
};
#ifdef TARGET_BIG_SYM
-bfd_target TARGET_BIG_SYM =
+const bfd_target TARGET_BIG_SYM =
{
/* name: identify kind of target */
TARGET_BIG_NAME,
#endif
#ifdef TARGET_LITTLE_SYM
-bfd_target TARGET_LITTLE_SYM =
+const bfd_target TARGET_LITTLE_SYM =
{
/* name: identify kind of target */
TARGET_LITTLE_NAME,
};
#ifdef TARGET_BIG_SYM
-bfd_target TARGET_BIG_SYM =
+const bfd_target TARGET_BIG_SYM =
{
/* name: identify kind of target */
TARGET_BIG_NAME,
#endif
#ifdef TARGET_LITTLE_SYM
-bfd_target TARGET_LITTLE_SYM =
+const bfd_target TARGET_LITTLE_SYM =
{
/* name: identify kind of target */
TARGET_LITTLE_NAME,
any side effects in ABFD, or any data it points to (like tdata), if the
file does not match the target vector. */
-bfd_target *
+const bfd_target *
elf_object_p (abfd)
bfd *abfd;
{
BFD format expects. */
if (ebd->elf_machine_code != i_ehdrp->e_machine)
{
- bfd_target **target_ptr;
+ const bfd_target * const *target_ptr;
if (ebd->elf_machine_code != EM_NONE)
goto got_wrong_format_error;
*/
-bfd_target *
+const bfd_target *
elf_core_file_p (abfd)
bfd *abfd;
{
BFD format expects. */
if (ebd->elf_machine_code != i_ehdrp->e_machine)
{
- bfd_target **target_ptr;
+ const bfd_target * const *target_ptr;
if (ebd->elf_machine_code != EM_NONE)
goto wrong;
char *lynx_core_file_failing_command ();
int lynx_core_file_failing_signal ();
boolean lynx_core_file_matches_executable_p ();
-bfd_target *lynx_core_file_p ();
+const bfd_target *lynx_core_file_p ();
#define MY_core_file_failing_command lynx_core_file_failing_command
#define MY_core_file_failing_signal lynx_core_file_failing_signal
/* Output standard relocation information to a file in target byte order. */
void
-NAME (lynx, swap_std_reloc_out) (abfd, g, natptr)
+NAME(lynx,swap_std_reloc_out) (abfd, g, natptr)
bfd *abfd;
arelent *g;
struct reloc_std_external *natptr;
/* Output extended relocation information to a file in target byte order. */
void
-NAME (lynx, swap_ext_reloc_out) (abfd, g, natptr)
+NAME(lynx,swap_ext_reloc_out) (abfd, g, natptr)
bfd *abfd;
arelent *g;
register struct reloc_ext_external *natptr;
} \
void
-NAME (lynx, swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols)
+NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols)
bfd *abfd;
struct reloc_ext_external *bytes;
arelent *cache_ptr;
}
void
-NAME (lynx, swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
+NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
bfd *abfd;
struct reloc_std_external *bytes;
arelent *cache_ptr;
for (; counter < count; counter++, rptr++, cache_ptr++)
{
- NAME (lynx, swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols);
+ NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols);
}
}
else
for (; counter < count; counter++, rptr++, cache_ptr++)
{
- NAME (lynx, swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols);
+ NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols);
}
}
/* Write out a relocation section into an object file. */
boolean
-NAME (lynx, squirt_out_relocs) (abfd, section)
+NAME(lynx,squirt_out_relocs) (abfd, section)
bfd *abfd;
asection *section;
{
for (natptr = native;
count != 0;
--count, natptr += each_size, ++generic)
- NAME (lynx, swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *) natptr);
+ NAME(lynx,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *) natptr);
}
else
{
for (natptr = native;
count != 0;
--count, natptr += each_size, ++generic)
- NAME (lynx, swap_std_reloc_out) (abfd, *generic, (struct reloc_std_external *) natptr);
+ NAME(lynx,swap_std_reloc_out) (abfd, *generic, (struct reloc_std_external *) natptr);
}
if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
symbol index order
*/
-extern bfd_target ieee_vec;
+extern const bfd_target ieee_vec;
long
ieee_get_symtab (abfd, location)
* archive stuff
*/
-bfd_target *
+const bfd_target *
ieee_archive_p (abfd)
bfd *abfd;
{
if (this_byte (&(ieee->h)) != Module_Beginning)
{
abfd->tdata.ieee_ar_data = save;
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
next_byte (&(ieee->h));
{
bfd_release (abfd, ieee);
abfd->tdata.ieee_ar_data = save;
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
/* Throw away the filename */
read_id (&(ieee->h));
if (!obstack_begin (&ob, 128))
{
bfd_set_error (bfd_error_no_memory);
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
ieee->element_count = 0;
if (!ieee->elements)
{
bfd_set_error (bfd_error_no_memory);
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
/* Now scan the area again, and replace BB offsets with file */
return abfd->tdata.ieee_data ? true : false;
}
-bfd_target *
+const bfd_target *
ieee_object_p (abfd)
bfd *abfd;
{
ieee->h.input_p = buffer;
if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
- goto fail;
+ goto got_wrong_format;
ieee->read_symbols = false;
ieee->read_data = false;
processor = ieee->mb.processor = read_id (&(ieee->h));
if (strcmp (processor, "LIBRARY") == 0)
- goto fail;
+ goto got_wrong_format;
ieee->mb.module_name = read_id (&(ieee->h));
if (abfd->filename == (CONST char *) NULL)
{
{
bfd_arch_info_type *arch = bfd_scan_arch (processor);
if (arch == 0)
- goto fail;
+ goto got_wrong_format;
abfd->arch_info = arch;
}
ieee_slurp_sections (abfd);
return abfd->xvec;
+got_wrong_format:
+ bfd_set_error (bfd_error_wrong_format);
fail:
(void) bfd_release (abfd, ieee);
abfd->tdata.ieee_data = save;
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
void
#define ieee_bfd_final_link _bfd_generic_final_link
/*SUPPRESS 460 */
-bfd_target ieee_vec =
+const bfd_target ieee_vec =
{
"ieee", /* name */
bfd_target_ieee_flavour,
extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *));
extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *));
-extern bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
-extern bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
+extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
+extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *,
Elf32_Internal_Rela *));
-extern bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
-extern bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
+extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
+extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
char *lynx_core_file_failing_command();
int lynx_core_file_failing_signal();
boolean lynx_core_file_matches_executable_p();
-bfd_target *lynx_core_file_p();
+const bfd_target *lynx_core_file_p();
#define MY_core_file_failing_command lynx_core_file_failing_command
#define MY_core_file_failing_signal lynx_core_file_failing_signal
0 /* finish_dynamic_link */
};
-bfd_target aout_mips_little_vec =
+const bfd_target aout_mips_little_vec =
{
"a.out-mips-little", /* name */
bfd_target_aout_flavour,
(PTR) MY_backend_data,
};
-bfd_target aout_mips_big_vec =
+const bfd_target aout_mips_big_vec =
{
"a.out-mips-big", /* name */
bfd_target_aout_flavour,
#define get_word bfd_h_get_32
#endif
-bfd_target *
+const bfd_target *
nlm_object_p (abfd)
bfd *abfd;
{
if (arch != bfd_arch_unknown)
bfd_default_set_arch_mach (abfd, arch, (unsigned long) 0);
+ abfd->flags |= EXEC_P;
+ bfd_get_start_address (abfd) = nlm_fixed_header (abfd)->codeStartOffset;
+
return (abfd->xvec);
got_wrong_format_error:
/* BFD back-end for oasys objects.
- Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
This file is part of BFD, the Binary File Descriptor library.
/*
*/
-extern bfd_target oasys_vec;
+extern const bfd_target oasys_vec;
long
oasys_get_symtab (abfd, location)
* archive stuff
*/
-static bfd_target *
+static const bfd_target *
oasys_archive_p (abfd)
bfd *abfd;
{
header.mod_count > 10000 ||
header.sym_count > 100000 ||
header.xref_count > 100000)
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
/*
That all worked, let's buy the space for the header and read in
}
#define MAX_SECS 16
-static bfd_target *
+static const bfd_target *
oasys_object_p (abfd)
bfd *abfd;
{
fail:
(void) bfd_release (abfd, oasys);
abfd->tdata.oasys_obj_data = save;
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
#define oasys_bfd_final_link _bfd_generic_final_link
/*SUPPRESS 460 */
-bfd_target oasys_vec =
+const bfd_target oasys_vec =
{
"oasys", /* name */
bfd_target_oasys_flavour,
BFD_JUMP_TABLE_RELOCS (oasys),
BFD_JUMP_TABLE_WRITE (oasys),
BFD_JUMP_TABLE_LINK (oasys),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
(PTR) 0
};
/* Forward declarations */
static boolean som_mkobject PARAMS ((bfd *));
-static bfd_target * som_object_setup PARAMS ((bfd *,
- struct header *,
- struct som_exec_auxhdr *));
+static const bfd_target * som_object_setup PARAMS ((bfd *,
+ struct header *,
+ struct som_exec_auxhdr *));
static boolean setup_sections PARAMS ((bfd *, struct header *));
-static bfd_target * som_object_p PARAMS ((bfd *));
+static const bfd_target * som_object_p PARAMS ((bfd *));
static boolean som_write_object_contents PARAMS ((bfd *));
static boolean som_slurp_string_table PARAMS ((bfd *));
static unsigned int som_slurp_symbol_table PARAMS ((bfd *));
/* Perform some initialization for an object. Save results of this
initialization in the BFD. */
-static bfd_target *
+static const bfd_target *
som_object_setup (abfd, file_hdrp, aux_hdrp)
bfd *abfd;
struct header *file_hdrp;
/* Read in a SOM object and make it into a BFD. */
-static bfd_target *
+static const bfd_target *
som_object_p (abfd)
bfd *abfd;
{
return section->reloc_count;
}
-extern bfd_target som_vec;
+extern const bfd_target som_vec;
/* A hook to set up object file dependent section information. */
#define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define som_bfd_final_link _bfd_generic_final_link
-bfd_target som_vec =
+const bfd_target som_vec =
{
"som", /* name */
bfd_target_som_flavour,
}
-static bfd_target *
+static const bfd_target *
object_p (abfd)
bfd *abfd;
{
return abfd->xvec;
}
-static bfd_target *
+static const bfd_target *
srec_object_p (abfd)
bfd *abfd;
{
return NULL;
if (b[0] != 'S' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
/* We create one section called .text for all the contents,
and allocate enough room for the entire file. */
}
-static bfd_target *
+static const bfd_target *
symbolsrec_object_p (abfd)
bfd *abfd;
{
return NULL;
if (b[0] != '$' || b[1] != '$')
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
return object_p (abfd);
}
char buffer[MAXCHUNK];
/* Dump out the symbols of a bfd */
int i;
- int len = bfd_get_symcount (abfd);
+ int count = bfd_get_symcount (abfd);
- if (len)
+ if (count)
{
size_t len;
asymbol **table = bfd_get_outsymbols (abfd);
sprintf (buffer, "$$ %s\r\n", abfd->filename);
- len = strlen (buffer) + 1;
+ len = strlen (buffer);
if (bfd_write (buffer, len, 1, abfd) != len)
return false;
- for (i = 0; i < len; i++)
+ for (i = 0; i < count; i++)
{
asymbol *s = table[i];
#if 0
}
}
sprintf (buffer, "$$ \r\n");
- len = strlen (buffer) + 1;
+ len = strlen (buffer);
if (bfd_write (buffer, len, 1, abfd) != len)
return false;
}
#define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define srec_bfd_final_link _bfd_generic_final_link
-bfd_target srec_vec =
+const bfd_target srec_vec =
{
"srec", /* name */
bfd_target_srec_flavour,
{
_bfd_dummy_target,
srec_object_p, /* bfd_check_format */
- (struct bfd_target * (*)()) bfd_nullvoidptr,
- (struct bfd_target * (*)()) bfd_nullvoidptr,
+ _bfd_dummy_target,
+ _bfd_dummy_target,
},
{
bfd_false,
-bfd_target symbolsrec_vec =
+const bfd_target symbolsrec_vec =
{
"symbolsrec", /* name */
bfd_target_srec_flavour,
{
_bfd_dummy_target,
symbolsrec_object_p, /* bfd_check_format */
- (struct bfd_target * (*)()) bfd_nullvoidptr,
- (struct bfd_target * (*)()) bfd_nullvoidptr,
+ _bfd_dummy_target,
+ _bfd_dummy_target,
},
{
bfd_false,
Return true if the file looks like it's in TekHex format. Just look
for a percent sign and some hex digits */
-static bfd_target *
+static const bfd_target *
tekhex_object_p (abfd)
bfd *abfd;
{
return NULL;
if (b[0] != '%' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
tekhex_mkobject (abfd);
#define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define tekhex_bfd_final_link _bfd_generic_final_link
-bfd_target tekhex_vec =
+const bfd_target tekhex_vec =
{
"tekhex", /* name */
bfd_target_tekhex_flavour,
{
_bfd_dummy_target,
tekhex_object_p, /* bfd_check_format */
- (struct bfd_target * (*)()) bfd_nullvoidptr,
- (struct bfd_target * (*)()) bfd_nullvoidptr,
+ _bfd_dummy_target,
+ _bfd_dummy_target,
},
{
bfd_false,