Add support for non-ELF targets to check their relocs.
[deliverable/binutils-gdb.git] / bfd / coffcode.h
index 181f9af15b47f9d42fc45aaf86d3be5102372cd9..eef3fa8d1da6be75d83be01a56334a5a11239b9b 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for the generic parts of most COFF variants, for BFD.
-   Copyright (C) 1990-2015 Free Software Foundation, Inc.
+   Copyright (C) 1990-2016 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -962,7 +962,7 @@ handle_COMDAT (bfd * abfd,
          /* All 3 branches use this.  */
          symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
 
-         /* PR 17512 file: 078-11867-0.004  */ 
+         /* PR 17512 file: 078-11867-0.004  */
          if (symname == NULL)
            {
              _bfd_error_handler (_("%B: unable to load COMDAT section name"), abfd);
@@ -1009,6 +1009,13 @@ handle_COMDAT (bfd * abfd,
 
                seen_state = 1;
 
+               /* PR 17512: file: e2cfe54f.  */
+               if (esym + bfd_coff_symesz (abfd) >= esymend)
+                 {
+                   _bfd_error_handler (_("%B: warning: No symbol for section '%s' found"),
+                                       abfd, symname);
+                   break;
+                 }
                /* This is the section symbol.  */
                bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
                                      isym.n_type, isym.n_sclass,
@@ -1162,7 +1169,7 @@ styp_to_sec_flags (bfd *abfd,
                   flagword *flags_ptr)
 {
   struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
-  long styp_flags = internal_s->s_flags;
+  unsigned long styp_flags = internal_s->s_flags;
   flagword sec_flags;
   bfd_boolean result = TRUE;
   bfd_boolean is_dbg = FALSE;
@@ -1185,7 +1192,7 @@ styp_to_sec_flags (bfd *abfd,
   /* Process each flag bit in styp_flags in turn.  */
   while (styp_flags)
     {
-      long flag = styp_flags & - styp_flags;
+      unsigned long flag = styp_flags & - styp_flags;
       char * unhandled = NULL;
 
       styp_flags &= ~ flag;
@@ -1345,6 +1352,10 @@ CODE_FRAGMENT
 .  COFF_SYMBOL_PE_SECTION
 .};
 .
+.typedef asection * (*coff_gc_mark_hook_fn)
+.  (asection *, struct bfd_link_info *, struct internal_reloc *,
+.   struct coff_link_hash_entry *, struct internal_syment *);
+.
 Special entry points for gdb to swap in coff symbol table parts:
 .typedef struct
 .{
@@ -2080,7 +2091,7 @@ coff_mkobject_hook (bfd * abfd,
     }
   if (coff->go32stub != NULL)
     memcpy (coff->go32stub, internal_f->go32stub, GO32_STUBSIZE);
-  
+
   return coff;
 }
 #endif
@@ -3163,6 +3174,15 @@ coff_compute_section_file_positions (bfd * abfd)
         This repairs 'ld -r' for arm-wince-pe target.  */
       if (page_size == 0)
        page_size = 1;
+
+      /* PR 17512: file: 0ac816d3.  */
+      if (page_size < 0)
+       {
+         bfd_set_error (bfd_error_file_too_big);
+         (*_bfd_error_handler)
+           (_("%B: page size is too large (0x%x)"), abfd, page_size);
+         return FALSE;
+       }
     }
   else
     page_size = PE_DEF_FILE_ALIGNMENT;
@@ -4056,6 +4076,8 @@ coff_write_object_contents (bfd * abfd)
     internal_f.f_flags |= F_DYNLOAD;
 #endif
 
+  memset (&internal_a, 0, sizeof internal_a);
+
   /* Set up architecture-dependent stuff.  */
   {
     unsigned int magic = 0;
@@ -4664,7 +4686,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
              *p++ = &lineno_cache[i];
 
          BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
-         
+
          /* Sort by functions.  */
          qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
 
@@ -5135,7 +5157,7 @@ coff_classify_symbol (bfd *abfd,
          asection *sec;
          char * name;
          char buf[SYMNMLEN + 1];
+
          name = _bfd_coff_internal_syment_name (abfd, syment, buf)
          sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
          if (sec != NULL && name != NULL
@@ -5458,6 +5480,8 @@ dummy_reloc16_extra_cases (bfd *abfd ATTRIBUTE_UNUSED,
   _bfd_generic_copy_link_hash_symbol_type
 #define coff_bfd_link_split_section  _bfd_generic_link_split_section
 
+#define coff_bfd_link_check_relocs   _bfd_generic_link_check_relocs
+
 #ifndef coff_start_final_link
 #define coff_start_final_link NULL
 #endif
@@ -5739,6 +5763,7 @@ coff_bigobj_swap_sym_in (bfd * abfd, void * ext1, void * in1)
     }
 
   in->n_value = H_GET_32 (abfd, ext->e_value);
+  BFD_ASSERT (sizeof (in->n_scnum) >= 4);
   in->n_scnum = H_GET_32 (abfd, ext->e_scnum);
   in->n_type = H_GET_16 (abfd, ext->e_type);
   in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
@@ -5977,7 +6002,7 @@ static bfd_coff_backend_data bigobj_swap_table =
 #endif
 
 #ifndef coff_bfd_gc_sections
-#define coff_bfd_gc_sections               bfd_generic_gc_sections
+#define coff_bfd_gc_sections               bfd_coff_gc_sections
 #endif
 
 #ifndef coff_bfd_lookup_section_flags
This page took 0.025783 seconds and 4 git commands to generate.