2001-03-20 Michael Chastain <chastain@redhat.com>
[deliverable/binutils-gdb.git] / bfd / riscix.c
index 192ebff9a14dbaf73f645801934afd596bd4c5de..f5a9ec9bdcb121579e928d1145c54eeb3b2a2b88 100644 (file)
@@ -1,7 +1,8 @@
 /* BFD back-end for RISC iX (Acorn, arm) binaries.
-   Copyright (C) 1994 Free Software Foundation, Inc.
+   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001
+   Free Software Foundation, Inc.
    Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
-   
+
 This file is part of BFD, the Binary File Descriptor library.
 
 This program is free software; you can redistribute it and/or modify
@@ -18,7 +19,6 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
-
 /* RISC iX overloads the MAGIC field to indicate more than just the usual
    [ZNO]MAGIC values.  Also included are squeezing information and
    shared library usage.  */
@@ -36,17 +36,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #define SPOMAGIC        (MF_USES_SL|OMAGIC)     /* OMAGIC with large header */
                                         /* -- may contain a ref to a */
                                         /* shared lib required by the */
-                                        /* object. */
+                                        /* object.  */
 #define SLOMAGIC        (MF_IS_SL|OMAGIC) /* A reference to a shared library */
                                           /* The text portion of the object */
                                           /* contains "overflow text" from */
                                           /* the shared library to be linked */
                                           /* in with an object */
-#define QMAGIC          (MF_SQUEEZED|ZMAGIC)    /* Sqeezed demand paged. */
+#define QMAGIC          (MF_SQUEEZED|ZMAGIC)    /* Sqeezed demand paged.  */
                                           /* NOTE: This interpretation of */
                                           /* QMAGIC seems to be at variance */
                                           /* With that used on other */
-                                          /* architectures. */
+                                          /* architectures.  */
 #define SPZMAGIC        (MF_USES_SL|ZMAGIC)     /* program which uses sl */
 #define SPQMAGIC        (MF_USES_SL|QMAGIC)     /* sqeezed ditto */
 #define SLZMAGIC        (MF_IS_SL|ZMAGIC)       /* shared lib part of prog */
@@ -89,7 +89,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "bfd.h"
 #include "sysdep.h"
 #include "libbfd.h"
-#include "assert.h"
 
 #define WRITE_HEADERS(abfd, execp)                                        \
   {                                                                       \
@@ -116,20 +115,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     if (bfd_get_outsymbols (abfd) != (asymbol **) NULL                    \
        && bfd_get_symcount (abfd) != 0)                                   \
       {                                                                           \
-       if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0)  \
+       if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0)  \
          return false;                                                    \
                                                                           \
-       if (! NAME(aout,write_syms)(abfd)) return false;                   \
+       if (! NAME(aout,write_syms) (abfd)) return false;                  \
                                                                           \
-       if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0) \
+       if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET) != 0) \
          return false;                                                    \
                                                                           \
        if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd)))         \
          return false;                                                    \
-       if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0) \
+       if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET) != 0) \
          return false;                                                    \
                                                                           \
-       if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd)))       \
+       if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd)))      \
          return false;                                                    \
       }                                                                           \
   }
@@ -155,7 +154,7 @@ static reloc_howto_type riscix_std_reloc_howto[] = {
   HOWTO( 5,              0,  1,   16, true,  0, complain_overflow_signed,  0,"DISP16",    true, 0x0000ffff,0x0000ffff, true),
   HOWTO( 6,              0,  2,   32, true,  0, complain_overflow_signed,  0,"DISP32",    true, 0xffffffff,0xffffffff, true),
   HOWTO( 7,              2,  3,   26, false, 0, complain_overflow_signed,  riscix_fix_pcrel_26_done, "ARM26D",true,0x00ffffff,0x00ffffff, false),
-  {-1},
+  EMPTY_HOWTO (-1),
   HOWTO( 9,              0, -1,   16, false, 0, complain_overflow_bitfield,0,"NEG16",        true, 0x0000ffff,0x0000ffff, false),
   HOWTO( 10,              0, -2,   32, false, 0, complain_overflow_bitfield,0,"NEG32",        true, 0xffffffff,0xffffffff, false)
 };
@@ -163,17 +162,16 @@ static reloc_howto_type riscix_std_reloc_howto[] = {
 #define RISCIX_TABLE_SIZE \
   (sizeof (riscix_std_reloc_howto) / sizeof (reloc_howto_type))
 
-
 static bfd_reloc_status_type
 riscix_fix_pcrel_26_done (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;
+     bfd *abfd ATTRIBUTE_UNUSED;
+     arelent *reloc_entry ATTRIBUTE_UNUSED;
+     asymbol *symbol ATTRIBUTE_UNUSED;
+     PTR data ATTRIBUTE_UNUSED;
+     asection *input_section ATTRIBUTE_UNUSED;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     char **error_message ATTRIBUTE_UNUSED;
 {
   /* This is dead simple at present.  */
   return bfd_reloc_ok;
@@ -188,13 +186,13 @@ riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
      PTR data;
      asection *input_section;
      bfd *output_bfd;
-     char **error_message;
+     char **error_message ATTRIBUTE_UNUSED;
 {
   bfd_vma relocation;
   bfd_size_type addr = reloc_entry->address;
   long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
   bfd_reloc_status_type flag = bfd_reloc_ok;
-  
+
   /* If this is an undefined symbol, return error */
   if (symbol->section == &bfd_und_section
       && (symbol->flags & BSF_WEAK) == 0)
@@ -221,7 +219,7 @@ riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
   /* Check for overflow */
   if (relocation & 0x02000000)
     {
-      if ((relocation & ~0x03ffffff) != ~0x03ffffff)
+      if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
        flag = bfd_reloc_overflow;
     }
   else if (relocation & ~0x03ffffff)
@@ -234,14 +232,14 @@ riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
   /* Now the ARM magic... Change the reloc type so that it is marked as done.
      Strictly this is only necessary if we are doing a partial relocation.  */
   reloc_entry->howto = &riscix_std_reloc_howto[7];
-  
+
   return flag;
 }
 
 reloc_howto_type *
-DEFUN(riscix_reloc_type_lookup,(abfd,code),
-      bfd *abfd AND
-      bfd_reloc_code_real_type code)
+riscix_reloc_type_lookup (abfd, code)
+     bfd *abfd;
+     bfd_reloc_code_real_type code;
 {
 #define ASTD(i,j)       case i: return &riscix_std_reloc_howto[j]
   if (code == BFD_RELOC_CTOR)
@@ -267,6 +265,7 @@ DEFUN(riscix_reloc_type_lookup,(abfd,code),
 
 #define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define MY_final_link_callback should_not_be_used
 #define MY_bfd_final_link _bfd_generic_final_link
 
 #define MY_bfd_reloc_type_lookup riscix_reloc_type_lookup
@@ -303,10 +302,9 @@ riscix_swap_std_reloc_out (abfd, g, natptr)
   /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
      relocation has been done already (Only for the 26-bit one I think)???!!!
      */
-  
+
   if (r_length == 3)
     r_pcrel = r_pcrel ? 0 : 1;
-  
 
 #if 0
   /* For a standard reloc, the addend is in the object file.  */
@@ -338,7 +336,7 @@ riscix_swap_std_reloc_out (abfd, g, natptr)
        {
          /* Fill in symbol */
          r_extern = 1;
-         r_index =  stoi((*(g->sym_ptr_ptr))->flags);
+         r_index = (*g->sym_ptr_ptr)->udata.i;
        }
     }
   else
@@ -381,7 +379,7 @@ riscix_squirt_out_relocs (abfd, section)
   arelent **generic;
   unsigned char *native, *natptr;
   size_t each_size;
-  
+
   unsigned int count = section->reloc_count;
   size_t natsize;
 
@@ -411,13 +409,12 @@ riscix_squirt_out_relocs (abfd, section)
   return true;
 }
 
-
 /*
  * This is just like the standard aoutx.h version but we need to do our
  * own mapping of external reloc type values to howto entries.
  */
 long
-MY(canonicalize_reloc)(abfd, section, relptr, symbols)
+MY(canonicalize_reloc) (abfd, section, relptr, symbols)
       bfd *abfd;
       sec_ptr section;
       arelent **relptr;
@@ -427,7 +424,7 @@ MY(canonicalize_reloc)(abfd, section, relptr, symbols)
   unsigned int count, c;
   extern reloc_howto_type NAME(aout,std_howto_table)[];
 
-  /* If we have already read in the relocation table, return the values. */
+  /* If we have already read in the relocation table, return the values.  */
   if (section->flags & SEC_CONSTRUCTOR) {
     arelent_chain *chain = section->constructor_chain;
 
@@ -445,7 +442,7 @@ MY(canonicalize_reloc)(abfd, section, relptr, symbols)
     return section->reloc_count;
   }
 
-  if (!NAME(aout,slurp_reloc_table)(abfd, section, symbols))
+  if (!NAME(aout,slurp_reloc_table) (abfd, section, symbols))
     return -1;
   tblptr = section->relocation;
 
@@ -453,7 +450,7 @@ MY(canonicalize_reloc)(abfd, section, relptr, symbols)
   for (count = 0; count++ < section->reloc_count;)
     {
       c = tblptr->howto - NAME(aout,std_howto_table);
-      assert (c < RISCIX_TABLE_SIZE);
+      BFD_ASSERT (c < RISCIX_TABLE_SIZE);
       tblptr->howto = &riscix_std_reloc_howto[c];
 
       *relptr++ = tblptr++;
@@ -462,7 +459,7 @@ MY(canonicalize_reloc)(abfd, section, relptr, symbols)
   return section->reloc_count;
 }
 
-/* This is the same as NAME(aout,some_aout_object_p), but has different 
+/* This is the same as NAME(aout,some_aout_object_p), but has different
    expansions of the macro definitions.  */
 
 const bfd_target *
@@ -474,7 +471,7 @@ riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
   struct aout_data_struct *rawptr, *oldrawptr;
   const bfd_target *result;
 
-  rawptr = ((struct aout_data_struct  *) 
+  rawptr = ((struct aout_data_struct  *)
            bfd_zalloc (abfd, sizeof (struct aout_data_struct )));
 
   if (rawptr == NULL)
@@ -496,7 +493,7 @@ riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
   execp = abfd->tdata.aout_data->a.hdr;
 
   /* Set the file flags */
-  abfd->flags = NO_FLAGS;
+  abfd->flags = BFD_NO_FLAGS;
   if (execp->a_drsize || execp->a_trsize)
     abfd->flags |= HAS_RELOC;
   /* Setting of EXEC_P has been deferred to the bottom of this function */
@@ -505,8 +502,7 @@ riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
   if (N_DYNAMIC(*execp))
     abfd->flags |= DYNAMIC;
 
-                                                                 
-  if ((execp->a_info & MF_SQUEEZED) != 0) /* Squeezed files aren't supported 
+  if ((execp->a_info & MF_SQUEEZED) != 0) /* Squeezed files aren't supported
                                             (yet)! */
     {
       bfd_set_error (bfd_error_wrong_format);
@@ -544,7 +540,7 @@ riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
   /* The default relocation entry size is that of traditional V7 Unix.  */
   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
 
-  /* The default symbol entry size is that of traditional Unix. */
+  /* The default symbol entry size is that of traditional Unix.  */
   obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
 
   obj_aout_external_syms (abfd) = NULL;
@@ -567,7 +563,7 @@ riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
      : (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS));
   obj_bsssec (abfd)->flags = SEC_ALLOC;
 
-  result = (*callback_to_real_object_p)(abfd);
+  result = (*callback_to_real_object_p) (abfd);
 
 #if defined(MACH) || defined(STAT_FOR_EXEC)
   /* The original heuristic doesn't work in some important cases. The
@@ -610,7 +606,6 @@ riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
   return result;
 }
 
-
 static const bfd_target *
 MY(object_p) (abfd)
      bfd *abfd;
@@ -633,12 +628,11 @@ MY(object_p) (abfd)
   if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) return 0;
 #endif
 
-  NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+  NAME(aout,swap_exec_header_in) (abfd, &exec_bytes, &exec);
 
   target = riscix_some_aout_object_p (abfd, &exec, MY(callback));
 
   return target;
 }
 
-
 #include "aout-target.h"
This page took 0.028865 seconds and 4 git commands to generate.