Fix compilation of the BFD sub-directory with a gcc v8 compiler by adding extra casts.
[deliverable/binutils-gdb.git] / bfd / bout.c
index 15baadfe50cf197e3c0ec275f183a075a6bb859e..1098cf9e4df2dda1e378cb990ea49a3a0e87c76e 100644 (file)
@@ -1,14 +1,12 @@
 /* BFD back-end for Intel 960 b.out binaries.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006
-   Free Software Foundation, Inc.
+   Copyright (C) 1990-2018 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
    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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "bfdlink.h"
 #include "genlink.h"
@@ -138,8 +137,8 @@ b_out_callback (bfd *abfd)
                     );
 
   /* The positions of the string table and symbol table.  */
-  obj_str_filepos (abfd) = N_STROFF (*execp);
-  obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+  obj_str_filepos (abfd) = N_STROFF (execp);
+  obj_sym_filepos (abfd) = N_SYMOFF (execp);
 
   /* The alignments of the sections.  */
   obj_textsec (abfd)->alignment_power = execp->a_talign;
@@ -162,12 +161,12 @@ b_out_callback (bfd *abfd)
   obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
 
   /* The file positions of the sections.  */
-  obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
-  obj_datasec (abfd)->filepos = N_DATOFF (*execp);
+  obj_textsec (abfd)->filepos = N_TXTOFF (execp);
+  obj_datasec (abfd)->filepos = N_DATOFF (execp);
 
   /* The file positions of the relocation info.  */
-  obj_textsec (abfd)->rel_filepos = N_TROFF (*execp);
-  obj_datasec (abfd)->rel_filepos =  N_DROFF (*execp);
+  obj_textsec (abfd)->rel_filepos = N_TROFF (execp);
+  obj_datasec (abfd)->rel_filepos =  N_DROFF (execp);
 
   adata (abfd).page_size = 1;  /* Not applicable.  */
   adata (abfd).segment_size = 1; /* Not applicable.  */
@@ -194,7 +193,7 @@ b_out_object_p (bfd *abfd)
 
   anexec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
 
-  if (N_BADMAG (anexec))
+  if (N_BADMAG (&anexec))
     {
       bfd_set_error (bfd_error_wrong_format);
       return 0;
@@ -451,20 +450,20 @@ b_out_write_object_contents (bfd *abfd)
               b_out_symbol_cmp);
 
       /* Back to your regularly scheduled program.  */
-      if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*exec_hdr (abfd))), SEEK_SET)
+      if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (exec_hdr (abfd))), SEEK_SET)
          != 0)
        return FALSE;
 
       if (! aout_32_write_syms (abfd))
        return FALSE;
 
-      if (bfd_seek (abfd, (file_ptr) (N_TROFF (*exec_hdr (abfd))), SEEK_SET)
+      if (bfd_seek (abfd, (file_ptr) (N_TROFF (exec_hdr (abfd))), SEEK_SET)
          != 0)
        return FALSE;
 
       if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd)))
        return FALSE;
-      if (bfd_seek (abfd, (file_ptr) (N_DROFF (*exec_hdr (abfd))), SEEK_SET)
+      if (bfd_seek (abfd, (file_ptr) (N_DROFF (exec_hdr (abfd))), SEEK_SET)
          != 0)
        return FALSE;
 
@@ -477,7 +476,7 @@ b_out_write_object_contents (bfd *abfd)
 /* Some reloc hackery.  */
 
 #define CALLS    0x66003800    /* Template for 'calls' instruction     */
-#define BAL      0x0b000000    /* Template for 'bal' instruction       */
+#define BAL      0x0b000000    /* Template for 'bal' instruction       */
 #define BAL_MASK  0x00ffffff
 #define BALX     0x85f00000    /* Template for 'balx' instruction      */
 #define BALX_MASK 0x0007ffff
@@ -518,11 +517,9 @@ get_value (arelent *reloc,
        value = h->u.c.size;
       else
        {
-         if (! ((*link_info->callbacks->undefined_symbol)
-                (link_info, bfd_asymbol_name (symbol),
-                 input_section->owner, input_section, reloc->address,
-                 TRUE)))
-           abort ();
+         (*link_info->callbacks->undefined_symbol)
+           (link_info, bfd_asymbol_name (symbol),
+            input_section->owner, input_section, reloc->address, TRUE);
          value = 0;
        }
     }
@@ -616,9 +613,9 @@ callj_callback (bfd *abfd,
   else if ((symbol->symbol.flags & BSF_SECTION_SYM) != 0)
     {
       /* A callj against a symbol in the same section is a fully
-         resolved relative call.  We don't need to do anything here.
-         If the symbol is not in the same section, I'm not sure what
-         to do; fortunately, this case will probably never arise.  */
+        resolved relative call.  We don't need to do anything here.
+        If the symbol is not in the same section, I'm not sure what
+        to do; fortunately, this case will probably never arise.  */
       BFD_ASSERT (! shrinking);
       BFD_ASSERT (symbol->symbol.section == input_section);
     }
@@ -635,7 +632,8 @@ callj_callback (bfd *abfd,
 }
 
 static reloc_howto_type *
-b_out_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
+b_out_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                            bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -651,6 +649,20 @@ b_out_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_typ
     }
 }
 
+static reloc_howto_type *
+b_out_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                            const char *r_name)
+{
+  if (strcasecmp (howto_reloc_callj.name, r_name) == 0)
+    return &howto_reloc_callj;
+  if (strcasecmp (howto_reloc_abs32.name, r_name) == 0)
+    return &howto_reloc_abs32;
+  if (strcasecmp (howto_reloc_pcrel24.name, r_name) == 0)
+    return &howto_reloc_pcrel24;
+
+  return NULL;
+}
+
 /* Allocate enough room for all the reloc entries, plus pointers to them all.  */
 
 static bfd_boolean
@@ -769,7 +781,7 @@ b_out_slurp_reloc_table (bfd *abfd, sec_ptr asect, asymbol **symbols)
        /* Sign-extend symnum from 24 bits to whatever host uses.  */
        s = symnum;
        if (s & (1 << 23))
-         s |= (~0) << 24;
+         s |= (~0U) << 24;
 
        cache_ptr->sym_ptr_ptr = (asymbol **)NULL;
        switch (s)
@@ -1055,7 +1067,7 @@ abs32code (bfd *abfd,
      jump we were going to.  */
   gap = value - (dot - shrink);
 
-  if (-1 << 23 < (long)gap && (long)gap < 1 << 23)
+  if ((long)(-1UL << 23) < (long)gap && (long)gap < 1L << 23)
     {
       /* Change the reloc type from 32bitcode possible 24, to 24bit
         possible 32.  */
@@ -1078,7 +1090,6 @@ aligncode (bfd *abfd,
           unsigned int shrink)
 {
   bfd_vma dot = output_addr (input_section) + r->address;
-  bfd_vma gap;
   bfd_vma old_end;
   bfd_vma new_end;
   unsigned int shrink_delta;
@@ -1094,9 +1105,6 @@ aligncode (bfd *abfd,
      than we used to be.  */
   new_end = ((dot - shrink + size) & ~size);
 
-  /* This is the new end.  */
-  gap = old_end - ((dot + size) & ~size);
-
   shrink_delta = (old_end - new_end) - shrink;
 
   if (shrink_delta)
@@ -1129,6 +1137,10 @@ b_out_bfd_relax_section (bfd *abfd,
   arelent **reloc_vector = NULL;
   long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
 
+  if (bfd_link_relocatable (link_info))
+    (*link_info->callbacks->einfo)
+      (_("%P%F: --relax and -r may not be used together\n"));
+
   if (reloc_size < 0)
     return FALSE;
 
@@ -1360,24 +1372,32 @@ b_out_bfd_get_relocated_section_contents (bfd *output_bfd,
 
 /* Build the transfer vectors for Big and Little-Endian B.OUT files.  */
 
-#define aout_32_bfd_make_debug_symbol          _bfd_nosymbols_bfd_make_debug_symbol
-#define aout_32_close_and_cleanup              aout_32_bfd_free_cached_info
+#define aout_32_find_line                     _bfd_nosymbols_find_line
+#define aout_32_get_symbol_version_string      _bfd_nosymbols_get_symbol_version_string
+#define aout_32_bfd_make_debug_symbol         _bfd_nosymbols_bfd_make_debug_symbol
+#define aout_32_close_and_cleanup             aout_32_bfd_free_cached_info
 #define b_out_bfd_link_hash_table_create       _bfd_generic_link_hash_table_create
-#define b_out_bfd_link_hash_table_free         _bfd_generic_link_hash_table_free
-#define b_out_bfd_link_add_symbols             _bfd_generic_link_add_symbols
-#define b_out_bfd_link_just_syms               _bfd_generic_link_just_syms
-#define b_out_bfd_final_link                   _bfd_generic_final_link
-#define b_out_bfd_link_split_section           _bfd_generic_link_split_section
-#define b_out_bfd_gc_sections                  bfd_generic_gc_sections
-#define b_out_bfd_merge_sections               bfd_generic_merge_sections
-#define b_out_bfd_is_group_section             bfd_generic_is_group_section
-#define b_out_bfd_discard_group                bfd_generic_discard_group
-#define b_out_section_already_linked           _bfd_generic_section_already_linked
+#define b_out_bfd_link_add_symbols            _bfd_generic_link_add_symbols
+#define b_out_bfd_link_just_syms              _bfd_generic_link_just_syms
+#define b_out_bfd_copy_link_hash_symbol_type \
+  _bfd_generic_copy_link_hash_symbol_type
+#define b_out_bfd_final_link                  _bfd_generic_final_link
+#define b_out_bfd_link_split_section          _bfd_generic_link_split_section
+#define b_out_bfd_gc_sections                 bfd_generic_gc_sections
+#define b_out_bfd_lookup_section_flags        bfd_generic_lookup_section_flags
+#define b_out_bfd_merge_sections              bfd_generic_merge_sections
+#define b_out_bfd_is_group_section            bfd_generic_is_group_section
+#define b_out_bfd_discard_group                       bfd_generic_discard_group
+#define b_out_section_already_linked          _bfd_generic_section_already_linked
+#define b_out_bfd_define_common_symbol        bfd_generic_define_common_symbol
+#define b_out_bfd_define_start_stop           bfd_generic_define_start_stop
 #define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+#define b_out_bfd_link_check_relocs           _bfd_generic_link_check_relocs
+#define b_out_set_reloc                               _bfd_generic_set_reloc
 
-extern const bfd_target b_out_vec_little_host;
+extern const bfd_target bout_le_vec;
 
-const bfd_target b_out_vec_big_host =
+const bfd_target bout_be_vec =
 {
   "b.out.big",                 /* Name.  */
   bfd_target_aout_flavour,
@@ -1390,7 +1410,7 @@ const bfd_target b_out_vec_big_host =
   '_',                         /* Symbol leading char.  */
   ' ',                         /* AR_pad_char.  */
   16,                          /* AR_max_namelen.  */
-
+  0,                           /* match priority.  */
   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.  */
@@ -1414,12 +1434,12 @@ const bfd_target b_out_vec_big_host =
      BFD_JUMP_TABLE_LINK (b_out),
      BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
-  & b_out_vec_little_host,
+  & bout_le_vec,
 
   NULL
 };
 
-const bfd_target b_out_vec_little_host =
+const bfd_target bout_le_vec =
 {
   "b.out.little",              /* Name.  */
   bfd_target_aout_flavour,
@@ -1432,6 +1452,7 @@ const bfd_target b_out_vec_little_host =
   '_',                         /* Symbol leading char.  */
   ' ',                         /* AR_pad_char.  */
   16,                          /* AR_max_namelen.  */
+  0,                           /* match priority.  */
   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.  */
@@ -1456,7 +1477,7 @@ const bfd_target b_out_vec_little_host =
      BFD_JUMP_TABLE_LINK (b_out),
      BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
-  & b_out_vec_big_host,
+  & bout_be_vec,
 
   NULL
 };
This page took 0.030194 seconds and 4 git commands to generate.