* bfd-in2.h: Rebuild.
* All backends: Remove initialization of align_power_min.
+Tue Sep 19 17:02:26 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * targets.c (bfd_target): Remove unused align_power_min field.
+ * bfd-in2.h: Rebuild.
+ * All backends: Remove initialization of align_power_min.
+
Tue Sep 19 14:02:21 1995 steve chamberlain <sac@slash.cygnus.com>
* peicode.h (coff_swap_scnhdr_out): Get sizes for BSS right.
- (pr 8045)
Mon Sep 18 14:35:01 1995 Arne H. Juul <arnej@pvv.unit.no>
'_', /* symbol leading char */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 2, /* minumum alignment power */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
char symbol_leading_char;
char ar_pad_char;
unsigned short ar_max_namelen;
- unsigned int align_power_min;
bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
the file. objcopy cooperates by specially setting the start
address to zero by default. */
+#include <ctype.h>
+
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
+/* Any bfd we create by reading a binary file has three symbols:
+ a start symbol, an end symbol, and an absolute length symbol. */
+#define BIN_SYMS 3
+
static boolean binary_mkobject PARAMS ((bfd *));
+static const bfd_target *binary_object_p PARAMS ((bfd *));
+static boolean binary_get_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static long binary_get_symtab_upper_bound PARAMS ((bfd *));
+static char *mangle_name PARAMS ((bfd *, char *));
+static long binary_get_symtab PARAMS ((bfd *, asymbol **));
static asymbol *binary_make_empty_symbol PARAMS ((bfd *));
+static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
static boolean binary_set_section_contents
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static int binary_sizeof_headers PARAMS ((bfd *, boolean));
/* Create a binary object. Invoked via bfd_set_format. */
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
+/* Any file may be considered to be a binary file, provided the target
+ was not defaulted. That is, it must be explicitly specified as
+ being binary. */
+
+static const bfd_target *
+binary_object_p (abfd)
+ bfd *abfd;
+{
+ struct stat statbuf;
+ asection *sec;
+
+ if (abfd->target_defaulted)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ abfd->symcount = BIN_SYMS;
+
+ /* Find the file size. */
+ if (bfd_stat (abfd, &statbuf) < 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return NULL;
+ }
+
+ /* One data section. */
+ sec = bfd_make_section (abfd, ".data");
+ if (sec == NULL)
+ return NULL;
+ sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
+ sec->vma = 0;
+ sec->_raw_size = statbuf.st_size;
+ sec->filepos = 0;
+
+ abfd->tdata.any = (PTR) sec;
+
+ return abfd->xvec;
+}
+
+#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
+#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define binary_new_section_hook _bfd_generic_new_section_hook
+
+/* Get contents of the only section. */
+
+static boolean
+binary_get_section_contents (abfd, section, location, offset, count)
+ bfd *abfd;
+ asection *section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
+{
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0
+ || bfd_read (location, 1, count, abfd) != count)
+ return false;
+ return true;
+}
+
+/* Return the amount of memory needed to read the symbol table. */
+
+static long
+binary_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ return (BIN_SYMS + 1) * sizeof (asymbol *);
+}
+
+/* Create a symbol name based on the bfd's filename. */
+
+static char *
+mangle_name (abfd, suffix)
+ bfd *abfd;
+ char *suffix;
+{
+ int size;
+ char *buf;
+ char *p;
+
+ size = (strlen (bfd_get_filename (abfd))
+ + strlen (suffix)
+ + sizeof "_binary__");
+
+ buf = (char *) bfd_alloc (abfd, size);
+ if (buf == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+
+ sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
+
+ /* Change any non-alphanumeric characters to underscores. */
+ for (p = buf; *p; p++)
+ if (! isalnum (*p))
+ *p = '_';
+
+ return buf;
+}
-/* We do have to provide a routine to make an empty symbol. */
+/* Return the symbol table. */
+
+static long
+binary_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ asection *sec = (asection *) abfd->tdata.any;
+ asymbol *syms;
+ unsigned int i;
+
+ syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
+ if (syms == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+
+ /* Start symbol. */
+ syms[0].the_bfd = abfd;
+ syms[0].name = mangle_name (abfd, "start");
+ syms[0].value = 0;
+ syms[0].flags = BSF_GLOBAL;
+ syms[0].section = sec;
+ syms[0].udata.p = NULL;
+
+ /* End symbol. */
+ syms[1].the_bfd = abfd;
+ syms[1].name = mangle_name (abfd, "end");
+ syms[1].value = sec->_raw_size;
+ syms[1].flags = BSF_GLOBAL;
+ syms[1].section = sec;
+ syms[1].udata.p = NULL;
+
+ /* Size symbol. */
+ syms[2].the_bfd = abfd;
+ syms[2].name = mangle_name (abfd, "size");
+ syms[2].value = sec->_raw_size;
+ syms[2].flags = BSF_GLOBAL;
+ syms[2].section = bfd_abs_section_ptr;
+ syms[2].udata.p = NULL;
+
+ for (i = 0; i < BIN_SYMS; i++)
+ *alocation++ = syms++;
+ *alocation = NULL;
+
+ return BIN_SYMS;
+}
+
+/* Make an empty symbol. */
static asymbol *
binary_make_empty_symbol (abfd)
return ret;
}
+#define binary_print_symbol _bfd_nosymbols_print_symbol
+
+/* Get information about a symbol. */
+
+static void
+binary_get_symbol_info (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+#define binary_bfd_is_local_label bfd_generic_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
+#define binary_read_minisymbols _bfd_generic_read_minisymbols
+#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define binary_get_reloc_upper_bound \
+ ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
+#define binary_canonicalize_reloc \
+ ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
+#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
/* Set the architecture of a binary file. */
#define binary_set_arch_mach _bfd_generic_set_arch_mach
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)
+ if (! abfd->output_has_begun)
{
- file_ptr adjust;
-
- adjust = - (sec->filepos + offset);
- if (size <= adjust)
- return true;
- size -= adjust;
- data = (PTR) ((bfd_byte *) data + adjust);
- offset += adjust;
+ bfd_vma low;
+ asection *s;
+
+ /* The lowest section VMA sets the virtual address of the start
+ of the file. We use the set the file position of all the
+ sections. */
+ low = abfd->sections->vma;
+ for (s = abfd->sections->next; s != NULL; s = s->next)
+ if (s->vma < low)
+ low = s->vma;
+
+ for (s = abfd->sections; s != NULL; s = s->next)
+ s->filepos = s->vma - low;
+
+ abfd->output_has_begun = true;
}
return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
}
+/* No space is required for header information. */
+
+static int
+binary_sizeof_headers (abfd, exec)
+ bfd *abfd;
+ boolean exec;
+{
+ return 0;
+}
+
+#define binary_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define binary_bfd_relax_section bfd_generic_relax_section
+#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define binary_bfd_final_link _bfd_generic_final_link
+#define binary_bfd_link_split_section _bfd_generic_link_split_section
+
const bfd_target binary_vec =
{
"binary", /* name */
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_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
{ /* bfd_check_format */
_bfd_dummy_target,
- _bfd_dummy_target,
+ binary_object_p, /* bfd_check_format */
_bfd_dummy_target,
_bfd_dummy_target,
},
bfd_false,
},
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
+ BFD_JUMP_TABLE_GENERIC (binary),
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_RELOCS (binary),
BFD_JUMP_TABLE_WRITE (binary),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_LINK (binary),
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
NULL
'_', /* leading underscore */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 2, /* minimum section alignment */
/* data */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
/* Get the howto structure for a generic reloc type. */
-static CONST struct reloc_howto_struct *
+static reloc_howto_type *
alpha_bfd_reloc_type_lookup (abfd, code)
bfd *abfd;
bfd_reloc_code_real_type code;
break;
#endif
default:
- return (CONST struct reloc_howto_struct *) NULL;
+ return (reloc_howto_type *) NULL;
}
return &alpha_howto_table[alpha_type];
BFD_ASSERT (info->relocateable);
- if (h->root.type == bfd_link_hash_defined)
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
{
asection *hsec;
const char *name;
if (! info->relocateable)
{
- if (h->root.type == bfd_link_hash_defined)
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
addend = (h->root.u.def.value
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset);
else
{
if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak
&& h->indx == -1)
{
/* This symbol is not being written out. Pass
if (r_extern)
{
if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak
&& h->indx == -1)
{
/* This symbol is not being written out. */
if (r_extern)
{
/* This is a reloc against a symbol. */
- if (h->root.type == bfd_link_hash_defined)
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
{
asection *hsec;
alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
_bfd_ecoff_make_section_hook, _bfd_ecoff_set_alignment_hook,
_bfd_ecoff_slurp_symbol_table,
- NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL
},
/* Supported architecture. */
bfd_arch_alpha,
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect
- flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
0, /* leading underscore */
' ', /* ar_pad_char */
15, /* ar_max_namelen */
- 4, /* 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 */
(cache_ptr)->howto = aoutarm_std_reloc_howto + (dst)->r_type;
#define coff_rtype_to_howto coff_arm_rtype_to_howto
+
static reloc_howto_type *
coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
bfd *abfd;
if (rel->r_type == 11)
{
- /* Gross, where can I get this from ?? */
- struct bfd_link_info *link_info = coff_data(sec->output_section->owner)->link_info;
- *addendp -= link_info->pe_info->image_base.value;
+ *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
}
return howto;
/* We use the special COFF backend linker. */
#define coff_relocate_section _bfd_coff_generic_relocate_section
+
#include "coffcode.h"
#ifdef TARGET_LITTLE_SYM
'/', /* 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 */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 2, /* minimum alignment power */
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 */
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
'_', /* leading char */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 1, /* minimum section alignment */
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 */
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
#include "coff/internal.h"
#include "libcoff.h"
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
+
static reloc_howto_type r_imm8 =
HOWTO (R_H8500_IMM8, 0, 1, 8, false, 0,
complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff, false);
}
else
{
- relent->sym_ptr_ptr = &(bfd_abs_symbol);
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
}
'_', /* leading symbol underscore */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 1, /* minimum section alignment */
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 */
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
/* The page size is a guess based on ELF. */
+
#define COFF_PAGE_SIZE 0x1000
/* For some reason when using i386 COFF the value stored in the .text
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
diff = reloc_entry->addend;
}
-#define DOIT(x) \
- x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
- if (diff != 0)
+#ifdef COFF_WITH_PE
+ if (reloc_entry->howto->type == 7)
{
- reloc_howto_type *howto = reloc_entry->howto;
- unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+/* diff -= coff_data(output_bfd)->link_info->pe_info.image_base.value;*/
+ exit(1);
+ }
+#endif
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, addr);
- DOIT (x);
- bfd_put_8 (abfd, x, addr);
- }
- break;
+#define DOIT(x) \
+ x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
- case 1:
- {
- short x = bfd_get_16 (abfd, addr);
- DOIT (x);
- bfd_put_16 (abfd, x, addr);
- }
- break;
+ if (diff != 0)
+ {
+ reloc_howto_type *howto = reloc_entry->howto;
+ unsigned char *addr = (unsigned char *) data + reloc_entry->address;
- case 2:
+ switch (howto->size)
{
- long x = bfd_get_32 (abfd, addr);
- DOIT (x);
- bfd_put_32 (abfd, x, addr);
+ 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 ();
}
- break;
-
- default:
- abort ();
- }
- }
+ }
/* Now let bfd_perform_relocation finish everything up. */
return bfd_reloc_continue;
0xffffffff, /* dst_mask */
true), /* pcrel_offset */
/* {7}, */
- HOWTO (7, /* type */
+ HOWTO (R_IMAGEBASE, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
32, /* bitsize */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
coff_i386_reloc, /* special_function */
- "dir32", /* name */
+ "rva32", /* name */
true, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
#ifndef COFF_WITH_PE
- /* I think we *do* want to bypass this. If we don't, I have seen some data
- parameters get the wrong relcation address. If I link two versions
- with and without this section bypassed and then do a binary comparison,
- the addresses which are different can be looked up in the map. The
- case in which this section has been bypassed has addresses which correspond
- to values I can find in the map */
+ /* I think we *do* want to bypass this. If we don't, I have seen some data
+ parameters get the wrong relcation address. If I link two versions
+ with and without this section bypassed and then do a binary comparison,
+ the addresses which are different can be looked up in the map. The
+ case in which this section has been bypassed has addresses which correspond
+ to values I can find in the map */
*addendp -= sym->n_value;
#endif
}
#ifdef COFF_WITH_PE
if (howto->pc_relative)
- *addendp -= 4;
+ *addendp -= 4;
+
+ if (rel->r_type == R_IMAGEBASE)
+ {
+ *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
+ }
#endif
return howto;
'/', /* 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 */
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
static boolean mips_relocate_section PARAMS ((bfd *, struct bfd_link_info *,
bfd *, asection *,
bfd_byte *, PTR));
+static boolean mips_read_relocs PARAMS ((bfd *, asection *));
static boolean mips_relax_section PARAMS ((bfd *, asection *,
struct bfd_link_info *,
boolean *));
/* Get the howto structure for a generic reloc type. */
-static CONST struct reloc_howto_struct *
+static reloc_howto_type *
mips_bfd_reloc_type_lookup (abfd, code)
bfd *abfd;
bfd_reloc_code_real_type code;
mips_type = MIPS_R_SWITCH;
break;
default:
- return (CONST struct reloc_howto_struct *) NULL;
+ return (reloc_howto_type *) NULL;
}
return &mips_howto_table[mips_type];
addend = ecoff_data (input_bfd)->gp - gp;
}
else if (! info->relocateable
- || h->root.type == bfd_link_hash_defined)
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
{
- /* This is a relocation against an undefined or common
- symbol. The current addend in the instruction is
- simply the desired offset into the symbol (normally
- zero). We are going to change this into a relocation
- against a defined symbol, so we want the instruction
- to hold the difference between the final definition
- of the symbol (which will end up in RELOCATION) and
- the GP value of OUTPUT_BFD (which is in GP). */
+ /* This is a relocation against a defined symbol. The
+ current addend in the instruction is simply the
+ desired offset into the symbol (normally zero). We
+ are going to change this into a relocation against a
+ defined symbol, so we want the instruction to hold
+ the difference between the final definition of the
+ symbol (which will end up in RELOCATION) and the GP
+ value of OUTPUT_BFD (which is in GP). */
addend = - gp;
}
else
+ int_rel.r_vaddr
- input_section->vma);
memmove (here + PCREL16_EXPANSION_ADJUSTMENT, here,
- (input_section->_raw_size
- - (int_rel.r_vaddr - input_section->vma)));
+ (size_t) (input_section->_raw_size
+ - (int_rel.r_vaddr - input_section->vma)));
/* Generate the new instructions. */
if (! mips_relax_pcrel16 (info, input_bfd, input_section,
the existing reloc. */
if (int_rel.r_extern)
{
- if (h->root.type == bfd_link_hash_defined)
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && ! bfd_is_abs_section (h->root.u.def.section))
{
const char *name;
if (int_rel.r_extern)
{
/* This is a reloc against a symbol. */
- if (h->root.type == bfd_link_hash_defined)
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
{
asection *hsec;
return true;
}
\f
+/* Read in the relocs for a section. */
+
+static boolean
+mips_read_relocs (abfd, sec)
+ bfd *abfd;
+ asection *sec;
+{
+ struct ecoff_section_tdata *section_tdata;
+
+ section_tdata = ecoff_section_data (abfd, sec);
+ if (section_tdata == (struct ecoff_section_tdata *) NULL)
+ {
+ sec->used_by_bfd =
+ (PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata));
+ if (sec->used_by_bfd == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+
+ section_tdata = ecoff_section_data (abfd, sec);
+ section_tdata->external_relocs = NULL;
+ section_tdata->contents = NULL;
+ section_tdata->offsets = NULL;
+ }
+
+ if (section_tdata->external_relocs == NULL)
+ {
+ bfd_size_type external_relocs_size;
+
+ external_relocs_size = (ecoff_backend (abfd)->external_reloc_size
+ * sec->reloc_count);
+
+ section_tdata->external_relocs =
+ (PTR) bfd_alloc (abfd, external_relocs_size);
+ if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+
+ if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
+ || (bfd_read (section_tdata->external_relocs, 1,
+ external_relocs_size, abfd)
+ != external_relocs_size))
+ return false;
+ }
+
+ return true;
+}
+
/* Relax a section when linking a MIPS ECOFF file. This is used for
embedded PIC code, which always uses PC relative branches which
only have an 18 bit range on MIPS. If a branch is not in range, we
/* Read in the relocs, if we haven't already got them. */
section_tdata = ecoff_section_data (abfd, sec);
- if (section_tdata == (struct ecoff_section_tdata *) NULL)
+ if (section_tdata == (struct ecoff_section_tdata *) NULL
+ || section_tdata->external_relocs == NULL)
{
- bfd_size_type external_reloc_size;
- bfd_size_type external_relocs_size;
-
- sec->used_by_bfd =
- (PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata));
- if (sec->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
-
- section_tdata = ecoff_section_data (abfd, sec);
- section_tdata->contents = NULL;
- section_tdata->offsets = NULL;
-
- external_reloc_size = ecoff_backend (abfd)->external_reloc_size;
- external_relocs_size = external_reloc_size * sec->reloc_count;
-
- section_tdata->external_relocs =
- (PTR) bfd_alloc (abfd, external_relocs_size);
- if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
-
- if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || (bfd_read (section_tdata->external_relocs, 1,
- external_relocs_size, abfd)
- != external_relocs_size))
+ if (! mips_read_relocs (abfd, sec))
goto error_return;
+ section_tdata = ecoff_section_data (abfd, sec);
+ }
+ if (sec->_cooked_size == 0)
+ {
/* We must initialize _cooked_size only the first time we are
called. */
sec->_cooked_size = sec->_raw_size;
if (h == (struct ecoff_link_hash_entry *) NULL)
abort ();
- if (h->root.type != bfd_link_hash_defined)
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
{
/* Just ignore undefined symbols. These will presumably
generate an error later in the link. */
if (info->keep_memory)
contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size);
else
- contents = (bfd_byte *) malloc (sec->_raw_size);
+ contents = (bfd_byte *) malloc ((size_t) sec->_raw_size);
if (contents == (bfd_byte *) NULL)
{
bfd_set_error (bfd_error_no_memory);
adj_h = *adj_h_ptr;
if (adj_h != (struct ecoff_link_hash_entry *) NULL
- && adj_h->root.type == bfd_link_hash_defined
+ && (adj_h->root.type == bfd_link_hash_defined
+ || adj_h->root.type == bfd_link_hash_defweak)
&& adj_h->root.u.def.section == sec
&& adj_h->esym.asym.value > int_rel.r_vaddr)
adj_h->root.u.def.value += PCREL16_EXPANSION_ADJUSTMENT;
return true;
}
+
+/* Given a .sdata section and a .rel.sdata in-memory section, store
+ relocation information into the .rel.sdata section which can be
+ used at runtime to relocate the section. This is called by the
+ linker when the --embedded-relocs switch is used. This is called
+ after the add_symbols entry point has been called for all the
+ objects, and before the final_link entry point is called. This
+ function presumes that the object was compiled using
+ -membedded-pic. */
+
+boolean
+bfd_mips_ecoff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *datasec;
+ asection *relsec;
+ char **errmsg;
+{
+ struct ecoff_link_hash_entry **sym_hashes;
+ struct ecoff_section_tdata *section_tdata;
+ struct external_reloc *ext_rel;
+ struct external_reloc *ext_rel_end;
+ bfd_byte *p;
+
+ BFD_ASSERT (! info->relocateable);
+
+ *errmsg = NULL;
+
+ if (datasec->reloc_count == 0)
+ return true;
+
+ sym_hashes = ecoff_data (abfd)->sym_hashes;
+
+ if (! mips_read_relocs (abfd, datasec))
+ return false;
+
+ relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 4);
+ if (relsec->contents == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+
+ p = relsec->contents;
+
+ section_tdata = ecoff_section_data (abfd, datasec);
+ ext_rel = (struct external_reloc *) section_tdata->external_relocs;
+ ext_rel_end = ext_rel + datasec->reloc_count;
+ for (; ext_rel < ext_rel_end; ext_rel++, p += 4)
+ {
+ struct internal_reloc int_rel;
+ boolean text_relative;
+
+ mips_ecoff_swap_reloc_in (abfd, (PTR) ext_rel, &int_rel);
+
+ /* We are going to write a four byte word into the runtime reloc
+ section. The word will be the address in the data section
+ which must be relocated. This must be on a word boundary,
+ which means the lower two bits must be zero. We use the
+ least significant bit to indicate how the value in the data
+ section must be relocated. A 0 means that the value is
+ relative to the text section, while a 1 indicates that the
+ value is relative to the data section. Given that we are
+ assuming the code was compiled using -membedded-pic, there
+ should not be any other possibilities. */
+
+ /* We can only relocate REFWORD relocs at run time. */
+ if (int_rel.r_type != MIPS_R_REFWORD)
+ {
+ *errmsg = "unsupported reloc type";
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ if (int_rel.r_extern)
+ {
+ struct ecoff_link_hash_entry *h;
+
+ h = sym_hashes[int_rel.r_symndx];
+ /* If h is NULL, that means that there is a reloc against an
+ external symbol which we thought was just a debugging
+ symbol. This should not happen. */
+ if (h == (struct ecoff_link_hash_entry *) NULL)
+ abort ();
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.section->flags & SEC_CODE) != 0)
+ text_relative = true;
+ else
+ text_relative = false;
+ }
+ else
+ {
+ switch (int_rel.r_symndx)
+ {
+ case RELOC_SECTION_TEXT:
+ text_relative = true;
+ break;
+ case RELOC_SECTION_SDATA:
+ case RELOC_SECTION_SBSS:
+ case RELOC_SECTION_LIT8:
+ text_relative = false;
+ break;
+ default:
+ /* No other sections should appear in -membedded-pic
+ code. */
+ *errmsg = "reloc against unsupported section";
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ }
+
+ if ((int_rel.r_offset & 3) != 0)
+ {
+ *errmsg = "reloc not properly aligned";
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ bfd_put_32 (abfd,
+ (int_rel.r_vaddr - datasec->vma + datasec->output_offset
+ + (text_relative ? 0 : 1)),
+ p);
+ }
+
+ return true;
+}
\f
/* This is the ECOFF backend structure. The backend field of the
target vector points to this. */
_bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
_bfd_ecoff_make_section_hook, _bfd_ecoff_set_alignment_hook,
_bfd_ecoff_slurp_symbol_table,
- NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL
},
/* Supported architecture. */
bfd_arch_mips,
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect
- flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
0, /* leading underscore */
' ', /* ar_pad_char */
15, /* ar_max_namelen */
- 4, /* 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 */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
0, /* leading underscore */
' ', /* ar_pad_char */
15, /* ar_max_namelen */
- 4, /* minimum alignment power */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
0, /* leading char */
'/', /* ar_pad_char */
15, /* ar_max_namelen??? FIXMEmgo */
- 3, /* default alignment power */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
#include "coff/internal.h"
#include "libcoff.h"
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
+
static reloc_howto_type r_imm32 =
HOWTO (R_IMM32, 0, 1, 32, false, 0,
complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,
}
else
{
- relent->sym_ptr_ptr = &(bfd_abs_symbol);
+ relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
}
'_', /* leading symbol underscore */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 1, /* minimum section alignment */
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 */
0, /* leading underscore */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 1, /* minimum alignment */
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 back-end for OSF/1 core files.
- Copyright 1993 Free Software Foundation, Inc.
+ Copyright 1993, 1994 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This file can only be compiled on systems which use OSF/1 style
- core files. In the config/XXXXXX.mh file for such a system add
- HDEFINES=-DOSF_CORE
- HDEPFILES=osf-core.o
- */
+ core files. */
#include "bfd.h"
#include "sysdep.h"
bfd_vma, file_ptr));
static asymbol *
osf_core_make_empty_symbol PARAMS ((bfd *));
-static bfd_target *
+static const bfd_target *
osf_core_core_file_p PARAMS ((bfd *));
static char *
osf_core_core_file_failing_command PARAMS ((bfd *));
{
asection *asect;
- asect = bfd_make_section (abfd, name);
+ asect = bfd_make_section_anyway (abfd, name);
if (!asect)
return NULL;
return new;
}
-static bfd_target *
+static const bfd_target *
osf_core_core_file_p (abfd)
bfd *abfd;
{
int i;
char *secname;
struct core_filehdr core_header;
- int dseccnt = 0;
val = bfd_read ((PTR)&core_header, 1, sizeof core_header, abfd);
if (val != sizeof core_header)
for (i = 0; i < core_header.nscns; i++)
{
struct core_scnhdr core_scnhdr;
+ flagword flags;
val = bfd_read ((PTR)&core_scnhdr, 1, sizeof core_scnhdr, abfd);
if (val != sizeof core_scnhdr)
switch (core_scnhdr.scntype)
{
case SCNRGN:
- /* OSF/1 has multiple data sections (data, bss and data/bss sections
- for shared libraries), but bfd doesn't permit data sections with
- the same name. Construct a unique section name. */
- secname = bfd_alloc (abfd, 40);
- if (!secname)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
- sprintf (secname, ".data%d", dseccnt++);
+ secname = ".data";
+ flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
break;
case SCNSTACK:
secname = ".stack";
+ flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
break;
case SCNREGS:
secname = ".reg";
+ flags = SEC_HAS_CONTENTS;
break;
default:
fprintf (stderr, "Unhandled OSF/1 core file section type %d\n",
continue;
}
- if (!make_bfd_asection (abfd, secname,
- SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
+ if (!make_bfd_asection (abfd, secname, flags,
(bfd_size_type) core_scnhdr.size,
(bfd_vma) core_scnhdr.vaddr,
(file_ptr) core_scnhdr.scnptr))
#define osf_core_get_lineno _bfd_nosymbols_get_lineno
#define osf_core_find_nearest_line _bfd_nosymbols_find_nearest_line
#define osf_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define osf_core_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define osf_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
/* If somebody calls any byte-swapping routines, shoot them. */
static void
#define NO_SIGNED_GET \
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-bfd_target osf_core_vec =
+const bfd_target osf_core_vec =
{
"osf-core",
bfd_target_unknown_flavour,
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 */
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
BFD_JUMP_TABLE_WRITE (_bfd_generic),
BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
(PTR) 0 /* backend_data */
};
case R_RSEL:
case R_COMP1:
case R_COMP2:
+ case R_BEGIN_BRTAB:
+ case R_END_BRTAB:
reloc_offset = bfd_reloc->address;
break;
case R_FSEL:
case R_LSEL:
case R_RSEL:
+ case R_BEGIN_BRTAB:
+ case R_END_BRTAB:
bfd_put_8 (abfd, bfd_reloc->howto->type, p);
subspace_reloc_size += 1;
p += 1;
#define som_truncate_arname bfd_bsd_truncate_arname
#define som_slurp_extended_name_table _bfd_slurp_extended_name_table
#define som_update_armap_timestamp bfd_true
+#define som_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
#define som_get_lineno _bfd_nosymbols_get_lineno
#define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
0,
'/', /* ar_pad_char */
14, /* ar_max_namelen */
- 3, /* minimum alignment */
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 */
0, /* leading underscore */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 1, /* minimum alignment */
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 */
0, /* leading underscore */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 1, /* minimum alignment */
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 */
. unsigned short ar_max_namelen;
-The minimum alignment restriction for any section.
-
-. unsigned int align_power_min;
-
Entries for byte swapping for data. These are different from the other
entry points, since they don't take a BFD asthe first argument.
Certain other handlers could do the same.