gas: Add md_generic_table_relax_frag
[deliverable/binutils-gdb.git] / bfd / coff-i386.c
index 803c28fcafcf04faa67a031b80eac5d282249902..99f60798636cf7b172dcd7fed5fe1d18502d1ea7 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel 386 COFF files.
-   Copyright (C) 1990-2016 Free Software Foundation, Inc.
+   Copyright (C) 1990-2019 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -41,6 +41,9 @@
 
 #include "libcoff.h"
 
+/* All users of this file have bfd_octets_per_byte (abfd, sec) == 1.  */
+#define OCTETS_PER_BYTE(ABFD, SEC) 1
+
 static reloc_howto_type *coff_i386_rtype_to_howto
   (bfd *, asection *, struct internal_reloc *,
    struct coff_link_hash_entry *, struct internal_syment *,
@@ -67,7 +70,7 @@ coff_i386_reloc (bfd *abfd,
                 arelent *reloc_entry,
                 asymbol *symbol,
                 void * data,
-                asection *input_section ATTRIBUTE_UNUSED,
+                asection *input_section,
                 bfd *output_bfd,
                 char **error_message ATTRIBUTE_UNUSED)
 {
@@ -142,7 +145,12 @@ coff_i386_reloc (bfd *abfd,
   if (diff != 0)
     {
       reloc_howto_type *howto = reloc_entry->howto;
-      unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+      bfd_size_type octets = (reloc_entry->address
+                             * OCTETS_PER_BYTE (abfd, input_section));
+      unsigned char *addr = (unsigned char *) data + octets;
+
+      if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octets))
+       return bfd_reloc_outofrange;
 
       switch (howto->size)
        {
@@ -377,7 +385,7 @@ static reloc_howto_type howto_table[] =
     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));         \
+                + (cache_ptr->sym_ptr_ptr - symbols));         \
     else if (ptr)                                              \
       coffsym = coff_symbol_from (ptr);                                \
     if (coffsym != (coff_symbol_type *) NULL                   \
@@ -493,11 +501,11 @@ coff_i386_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
       *addendp -= 4;
 
       /* If the symbol is defined, then the generic code is going to
-         add back the symbol value in order to cancel out an
-         adjustment it made to the addend.  However, we set the addend
-         to 0 at the start of this function.  We need to adjust here,
-         to avoid the adjustment the generic code will make.  FIXME:
-         This is getting a bit hackish.  */
+        add back the symbol value in order to cancel out an
+        adjustment it made to the addend.  However, we set the addend
+        to 0 at the start of this function.  We need to adjust here,
+        to avoid the adjustment the generic code will make.  FIXME:
+        This is getting a bit hackish.  */
       if (sym != NULL && sym->n_scnum != 0)
        *addendp -= sym->n_value;
     }
@@ -656,27 +664,44 @@ 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_check_format */
+
 #ifdef COFF_CHECK_FORMAT
-    {_bfd_dummy_target, COFF_CHECK_FORMAT,
-       bfd_generic_archive_p, COFF_CHECK_FORMAT},
+  {                            /* bfd_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},
+  {
+    _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 */
-       _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),
+  {                            /* bfd_set_format */
+    _bfd_bool_bfd_false_error,
+    coff_mkobject,
+    _bfd_generic_mkarchive,
+    _bfd_bool_bfd_false_error
+  },
+  {                            /* bfd_write_contents */
+    _bfd_bool_bfd_false_error,
+    coff_write_object_contents,
+    _bfd_write_archive_contents,
+    _bfd_bool_bfd_false_error
+  },
+
+  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),
 
   NULL,
 
This page took 0.026087 seconds and 4 git commands to generate.