* sunos.c (sunos_create_dynamic_sections): We need the dynamic
[deliverable/binutils-gdb.git] / bfd / cf-m68klynx.c
index f056503940b7e2318d759ccb1d9e66c23220692a..6425c3013e759c62472d5380b7ae8c06260b9667 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for Motorola M68K COFF LynxOS files.
-   Copyright 1993 Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -16,7 +16,7 @@ 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.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #define TARGET_SYM     m68klynx_coff_vec
 #define TARGET_NAME    "coff-m68k-lynx"
@@ -28,18 +28,25 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define _bfd_m68kcoff_howto_table _bfd_m68klynx_howto_table    
 #define _bfd_m68kcoff_rtype2howto _bfd_m68klynx_rtype2howto    
 #define _bfd_m68kcoff_howto2rtype _bfd_m68klynx_howto2rtype    
+#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68klynx_reloc_type_lookup
 
 #define LYNX_SPECIAL_FN _bfd_m68klynx_special_fn
 
 #include "bfd.h"
+#include "sysdep.h"
 
-static bfd_reloc_status_type _bfd_m68klynx_special_fn PARAMS ((bfd *abfd,
-                                                     arelent *reloc_entry,
-                                                     asymbol *symbol,
-                                                     PTR data,
-                                                     asection *input_section,
-                                                     bfd *output_bfd,
-                                                     char **error_message));
+#ifdef ANSI_PROTOTYPES
+struct internal_reloc;
+struct coff_link_hash_entry;
+struct internal_syment;
+#endif
+
+static bfd_reloc_status_type _bfd_m68klynx_special_fn
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static reloc_howto_type *coff_m68k_lynx_rtype_to_howto
+  PARAMS ((bfd *, asection *, struct internal_reloc *,
+          struct coff_link_hash_entry *, struct internal_syment *,
+          bfd_vma *));
 
 /* For some reason when using m68k COFF the value stored in the .text
    section for a reference to a common symbol is the value itself plus
@@ -52,8 +59,8 @@ static bfd_reloc_status_type _bfd_m68klynx_special_fn PARAMS ((bfd *abfd,
    reloc type to make any required adjustments.  */
 
 static bfd_reloc_status_type
-_bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section, output_bfd,
-                         error_message)
+_bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section,
+                         output_bfd, error_message)
      bfd *abfd;
      arelent *reloc_entry;
      asymbol *symbol;
@@ -96,7 +103,7 @@ _bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section, output
 
   if (diff != 0)
     {
-      const reloc_howto_type *howto = reloc_entry->howto;
+      reloc_howto_type *howto = reloc_entry->howto;
       unsigned char *addr = (unsigned char *) data + reloc_entry->address;
 
       switch (howto->size)
@@ -162,9 +169,58 @@ _bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section, output
       cache_ptr->addend = - (ptr->section->vma + ptr->value);  \
     else                                                       \
       cache_ptr->addend = 0;                                   \
-    if (ptr && howto_table[reloc.r_type].pc_relative)          \
+    if (ptr && (reloc.r_type == R_PCRBYTE                      \
+               || reloc.r_type == R_PCRWORD                    \
+               || reloc.r_type == R_PCRLONG))                  \
       cache_ptr->addend += asect->vma;                         \
   }
 
+#define coff_rtype_to_howto coff_m68k_lynx_rtype_to_howto
 
 #include "coff-m68k.c"
+
+/* coff-m68k.c uses the special COFF backend linker.  We need to
+   adjust common symbols.
+
+   We can't define this function until after we have included
+   coff-m68k.c, because it uses RTYPE2HOWTO.  */
+
+/*ARGSUSED*/
+static reloc_howto_type *
+coff_m68k_lynx_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+     bfd *abfd;
+     asection *sec;
+     struct internal_reloc *rel;
+     struct coff_link_hash_entry *h;
+     struct internal_syment *sym;
+     bfd_vma *addendp;
+{
+  arelent relent;
+  reloc_howto_type *howto;
+
+  RTYPE2HOWTO (&relent, rel);
+
+  howto = relent.howto;
+
+  if (howto->pc_relative)
+    *addendp += sec->vma;
+
+  if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
+    {
+      /* This is a common symbol.  The section contents include the
+        size (sym->n_value) as an addend.  The relocate_section
+        function will be adding in the final value of the symbol.  We
+        need to subtract out the current size in order to get the
+        correct result.  */
+      BFD_ASSERT (h != NULL);
+      *addendp -= sym->n_value;
+    }
+
+  /* If the output symbol is common (in which case this must be a
+     relocateable link), we need to add in the final size of the
+     common symbol.  */
+  if (h != NULL && h->root.type == bfd_link_hash_common)
+    *addendp += h->root.u.c.size;
+
+  return howto;
+}
This page took 0.024798 seconds and 4 git commands to generate.