daily update
[deliverable/binutils-gdb.git] / bfd / coff-i386.c
index 47c041d3c0c1f88caa3ba18619adac510069c2d9..adc343329b02e4370c189bc39e3c1d7b28a776f4 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for Intel 386 COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2007
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
 #include "coff/go32exe.h"
 #endif
 
+#ifndef bfd_pe_print_pdata
+#define bfd_pe_print_pdata     NULL
+#endif
+
 #include "libcoff.h"
 
 static bfd_reloc_status_type coff_i386_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+  (bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **);
 static reloc_howto_type *coff_i386_rtype_to_howto
-  PARAMS ((bfd *, asection *, struct internal_reloc *,
-          struct coff_link_hash_entry *, struct internal_syment *,
-          bfd_vma *));
+  (bfd *, asection *, struct internal_reloc *,
+   struct coff_link_hash_entry *, struct internal_syment *,
+   bfd_vma *);
 static reloc_howto_type *coff_i386_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
+  (bfd *, bfd_reloc_code_real_type);
 
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
 /* The page size is a guess based on ELF.  */
@@ -191,7 +195,8 @@ static bfd_boolean in_reloc_p (abfd, howto)
      bfd * abfd ATTRIBUTE_UNUSED;
      reloc_howto_type *howto;
 {
-  return ! howto->pc_relative && howto->type != R_IMAGEBASE;
+  return ! howto->pc_relative && howto->type != R_IMAGEBASE
+        && howto->type != R_SECREL32;
 }
 #endif /* COFF_WITH_PE */
 
@@ -450,7 +455,7 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
 {
   reloc_howto_type *howto;
 
-  if (rel->r_type > sizeof (howto_table) / sizeof (howto_table[0]))
+  if (rel->r_type >= sizeof (howto_table) / sizeof (howto_table[0]))
     {
       bfd_set_error (bfd_error_bad_value);
       return NULL;
@@ -518,25 +523,26 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
       *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
     }
 
-  if (rel->r_type == R_SECREL32)
+  BFD_ASSERT (sym != NULL);
+  if (rel->r_type == R_SECREL32 && sym != NULL)
     {
       bfd_vma osect_vma;
 
-      if (h && (h->type == bfd_link_hash_defined
-               || h->type == bfd_link_hash_defweak))
+      if (h && (h->root.type == bfd_link_hash_defined
+               || h->root.type == bfd_link_hash_defweak))
        osect_vma = h->root.u.def.section->output_section->vma;
       else
        {
-         asection *sec;
+         asection *s;
          int i;
 
          /* Sigh, the only way to get the section to offset against
             is to find it the hard way.  */
 
-         for (sec = abfd->sections, i = 1; i < sym->n_scnum; i++)
-           sec = sec->next;
+         for (s = abfd->sections, i = 1; i < sym->n_scnum; i++)
+           s = s->next;
 
-         osect_vma = sec->output_section->vma;
+         osect_vma = s->output_section->vma;
        }
 
       *addendp -= osect_vma;
@@ -655,6 +661,7 @@ const bfd_target
 #endif
   '/',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
+  0,                           /* match priority.  */
 
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
@@ -664,8 +671,13 @@ const bfd_target
      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, coff_object_p, /* bfd_check_format */
-       bfd_generic_archive_p, coff_object_p},
+    /* bfd_check_format */
+#ifdef COFF_CHECK_FORMAT
+    {_bfd_dummy_target, COFF_CHECK_FORMAT,
+       bfd_generic_archive_p, COFF_CHECK_FORMAT},
+#else
+    {_bfd_dummy_target, coff_object_p, bfd_generic_archive_p, coff_object_p},
+#endif
     {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
        bfd_false},
     {bfd_false, coff_write_object_contents, /* bfd_write_contents */
This page took 0.024382 seconds and 4 git commands to generate.