Module Name:    src
Committed By:   christos
Date:           Fri Jan 29 22:39:00 UTC 2016

Modified Files:
        src/external/gpl3/binutils/dist/bfd: elfnn-riscv.c

Log Message:
fix bfd for riscv.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/binutils/dist/bfd/elfnn-riscv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/binutils/dist/bfd/elfnn-riscv.c
diff -u src/external/gpl3/binutils/dist/bfd/elfnn-riscv.c:1.2 src/external/gpl3/binutils/dist/bfd/elfnn-riscv.c:1.3
--- src/external/gpl3/binutils/dist/bfd/elfnn-riscv.c:1.2	Sat Mar 28 03:51:20 2015
+++ src/external/gpl3/binutils/dist/bfd/elfnn-riscv.c	Fri Jan 29 17:39:00 2016
@@ -26,10 +26,12 @@
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "libiberty.h"
 #include "libbfd.h"
-#include "bfdlink.h"
-#include "genlink.h"
+#include "bfd_stdint.h"
 #include "elf-bfd.h"
+#include "bfdlink.h"
+#include "objalloc.h"
 #include "elfxx-riscv.h"
 #include "elf/riscv.h"
 #include "opcode/riscv.h"
@@ -358,7 +360,7 @@ riscv_elf_create_dynamic_sections (bfd *
     return FALSE;
 
   htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
-  if (!info->shared)
+  if (!bfd_link_pic (info))
     {
       htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
       htab->sdyntdata =
@@ -367,7 +369,7 @@ riscv_elf_create_dynamic_sections (bfd *
     }
 
   if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss
-      || (!info->shared && (!htab->srelbss || !htab->sdyntdata)))
+      || (!bfd_link_pic (info) && (!htab->srelbss || !htab->sdyntdata)))
     abort ();
 
   return TRUE;
@@ -498,7 +500,7 @@ riscv_elf_check_relocs (bfd *abfd, struc
   const Elf_Internal_Rela *rel;
   asection *sreloc = NULL;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   htab = riscv_elf_hash_table (info);
@@ -547,7 +549,7 @@ riscv_elf_check_relocs (bfd *abfd, struc
 	  break;
 
 	case R_RISCV_TLS_GOT_HI20:
-	  if (info->shared)
+	  if (bfd_link_pic (info))
 	    info->flags |= DF_STATIC_TLS;
 	  if (!riscv_elf_record_got_reference (abfd, info, h, r_symndx)
 	      || !riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_IE))
@@ -579,19 +581,19 @@ riscv_elf_check_relocs (bfd *abfd, struc
 	case R_RISCV_BRANCH:
 	case R_RISCV_PCREL_HI20:
 	  /* In shared libs, these relocs are known to bind locally.  */
-	  if (info->shared)
+	  if (bfd_link_pic (info))
 	    break;
 	  goto static_reloc;
 
 	case R_RISCV_TPREL_HI20:
-	  if (!info->executable)
+	  if (!bfd_link_executable (info))
 	    return bad_static_reloc (abfd, r_type, h);
 	  if (h != NULL)
 	    riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_LE);
 	  goto static_reloc;
 
 	case R_RISCV_HI20:
-	  if (info->shared)
+	  if (bfd_link_pic (info))
 	    return bad_static_reloc (abfd, r_type, h);
 	  /* Fall through.  */
 
@@ -606,7 +608,7 @@ riscv_elf_check_relocs (bfd *abfd, struc
 	  if (h != NULL)
 	    h->non_got_ref = 1;
 
-	  if (h != NULL && !info->shared)
+	  if (h != NULL && !bfd_link_pic (info))
 	    {
 	      /* We may need a .plt entry if the function this reloc
 		 refers to is in a shared lib.  */
@@ -634,14 +636,14 @@ riscv_elf_check_relocs (bfd *abfd, struc
 	     may need to keep relocations for symbols satisfied by a
 	     dynamic library if we manage to avoid copy relocs for the
 	     symbol.  */
-	  if ((info->shared
+	  if ((bfd_link_pic (info)
 	       && (sec->flags & SEC_ALLOC) != 0
 	       && (! riscv_elf_rtype_to_howto (r_type)->pc_relative
 		   || (h != NULL
 		       && (! info->symbolic
 			   || h->root.type == bfd_link_hash_defweak
 			   || !h->def_regular))))
-	      || (!info->shared
+	      || (!bfd_link_pic (info)
 		  && (sec->flags & SEC_ALLOC) != 0
 		  && h != NULL
 		  && (h->root.type == bfd_link_hash_defweak
@@ -757,7 +759,7 @@ riscv_elf_gc_sweep_hook (bfd *abfd, stru
   struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (abfd);
   bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd);
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   elf_section_data (sec)->local_dynrel = NULL;
@@ -816,7 +818,7 @@ riscv_elf_gc_sweep_hook (bfd *abfd, stru
 	case R_RISCV_BRANCH:
 	case R_RISCV_CALL:
 	case R_RISCV_JAL:
-	  if (info->shared)
+	  if (bfd_link_pic (info))
 	    break;
 	  /* Fall through.  */
 
@@ -908,7 +910,7 @@ riscv_elf_adjust_dynamic_symbol (struct 
      only references to the symbol are via the global offset table.
      For such cases we need not do anything here; the relocations will
      be handled correctly by relocate_section.  */
-  if (info->shared)
+  if (bfd_link_pic (info))
     return TRUE;
 
   /* If there are no references to this symbol that do not use the
@@ -960,9 +962,9 @@ riscv_elf_adjust_dynamic_symbol (struct 
     }
 
   if (eh->tls_type & ~GOT_NORMAL)
-    return _bfd_elf_adjust_dynamic_copy (h, htab->sdyntdata);
+    return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdyntdata);
 
-  return _bfd_elf_adjust_dynamic_copy (h, htab->sdynbss);
+  return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdynbss);
 }
 
 /* Allocate space in .plt, .got and associated reloc sections for
@@ -995,7 +997,7 @@ allocate_dynrelocs (struct elf_link_hash
 	    return FALSE;
 	}
 
-      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h))
+      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
 	{
 	  asection *s = htab->elf.splt;
 
@@ -1018,7 +1020,7 @@ allocate_dynrelocs (struct elf_link_hash
 	     location in the .plt.  This is required to make function
 	     pointers compare as equal between the normal executable and
 	     the shared library.  */
-	  if (! info->shared
+	  if (! bfd_link_pic (info)
 	      && !h->def_regular)
 	    {
 	      h->root.u.def.section = s;
@@ -1074,7 +1076,7 @@ allocate_dynrelocs (struct elf_link_hash
       else
 	{
 	  s->size += RISCV_ELF_WORD_BYTES;
-	  if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h))
+	  if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h))
 	    htab->elf.srelgot->size += sizeof (ElfNN_External_Rela);
 	}
     }
@@ -1091,7 +1093,7 @@ allocate_dynrelocs (struct elf_link_hash
      space for pc-relative relocs that have become local due to symbol
      visibility changes.  */
 
-  if (info->shared)
+  if (bfd_link_pic (info))
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
 	{
@@ -1209,7 +1211,7 @@ riscv_elf_size_dynamic_sections (bfd *ou
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (info->executable)
+      if (bfd_link_executable (info))
 	{
 	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
@@ -1220,7 +1222,7 @@ riscv_elf_size_dynamic_sections (bfd *ou
 
   /* Set up .got offsets for local syms, and space for local dynamic
      relocs.  */
-  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
     {
       bfd_signed_vma *local_got;
       bfd_signed_vma *end_local_got;
@@ -1274,7 +1276,7 @@ riscv_elf_size_dynamic_sections (bfd *ou
 	      s->size += RISCV_ELF_WORD_BYTES;
 	      if (*local_tls_type & GOT_TLS_GD)
 		s->size += RISCV_ELF_WORD_BYTES;
-	      if (info->shared
+	      if (bfd_link_pic (info)
 		  || (*local_tls_type & (GOT_TLS_GD | GOT_TLS_IE)))
 		srel->size += sizeof (ElfNN_External_Rela);
 	    }
@@ -1374,7 +1376,7 @@ riscv_elf_size_dynamic_sections (bfd *ou
 #define add_dynamic_entry(TAG, VAL) \
   _bfd_elf_add_dynamic_entry (info, TAG, VAL)
 
-      if (info->executable)
+      if (bfd_link_executable (info))
 	{
 	  if (!add_dynamic_entry (DT_DEBUG, 0))
 	    return FALSE;
@@ -1730,13 +1732,13 @@ riscv_elf_relocate_section (bfd *output_
 	}
       else
 	{
-	  bfd_boolean warned;
+	  bfd_boolean warned, ignored;
 	  /* bfd_boolean ignored; */
 
 	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
 				   r_symndx, symtab_hdr, sym_hashes,
 				   h, sec, relocation,
-				   unresolved_reloc, warned /*, ignored */);
+				   unresolved_reloc, warned, ignored);
 	  if (warned)
 	    {
 	      /* To avoid generating warning messages about truncated
@@ -1753,7 +1755,7 @@ riscv_elf_relocate_section (bfd *output_
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
 					 rel, 1, relend, howto, 0, contents);
 
-      if (info->relocatable)
+      if (bfd_link_relocatable (info))
 	continue;
 
       if (h != NULL)
@@ -1790,8 +1792,8 @@ riscv_elf_relocate_section (bfd *output_
 	      BFD_ASSERT (off != (bfd_vma) -1);
 	      dyn = elf_hash_table (info)->dynamic_sections_created;
 
-	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
-		  || (info->shared
+	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)
+		  || (bfd_link_pic (info)
 		      && SYMBOL_REFERENCES_LOCAL (info, h)))
 		{
 		  /* This is actually a static link, or it is a
@@ -1832,7 +1834,7 @@ riscv_elf_relocate_section (bfd *output_
 		off &= ~1;
 	      else
 		{
-		  if (info->shared)
+		  if (bfd_link_pic (info))
 		    {
 		      asection *s;
 		      Elf_Internal_Rela outrel;
@@ -1885,7 +1887,7 @@ riscv_elf_relocate_section (bfd *output_
 	case R_RISCV_CALL_PLT:
 	case R_RISCV_CALL:
 	case R_RISCV_JAL:
-	  if (info->shared && h != NULL && h->plt.offset != MINUS_ONE)
+	  if (bfd_link_pic (info) && h != NULL && h->plt.offset != MINUS_ONE)
 	    {
 	      /* Refer to the PLT entry.  */
 	      relocation = sec_addr (htab->elf.splt) + h->plt.offset;
@@ -1955,13 +1957,13 @@ riscv_elf_relocate_section (bfd *output_
 	  if ((input_section->flags & SEC_ALLOC) == 0)
 	    break;
 
-	  if ((info->shared
+	  if ((bfd_link_pic (info)
 	       && (h == NULL
 		   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		   || h->root.type != bfd_link_hash_undefweak)
 	       && (! howto->pc_relative
 		   || !SYMBOL_CALLS_LOCAL (info, h)))
-	      || (!info->shared
+	      || (!bfd_link_pic (info)
 		  && h != NULL
 		  && h->dynindx != -1
 		  && !h->non_got_ref
@@ -1987,7 +1989,7 @@ riscv_elf_relocate_section (bfd *output_
 	      if (skip_dynamic_relocation)
 		memset (&outrel, 0, sizeof outrel);
 	      else if (h != NULL && h->dynindx != -1
-		       && !(info->shared
+		       && !(bfd_link_pic (info)
 			    && SYMBOLIC_BIND (info, h)
 			    && h->def_regular))
 		{
@@ -2046,8 +2048,8 @@ riscv_elf_relocate_section (bfd *output_
 	        bfd_boolean dyn;
 	        dyn = htab->elf.dynamic_sections_created;
 
-		if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
-		    && (!info->shared
+		if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)
+		    && (!bfd_link_pic (info)
 			|| !SYMBOL_REFERENCES_LOCAL (info, h)))
 		  {
 		    indx = h->dynindx;
@@ -2056,7 +2058,7 @@ riscv_elf_relocate_section (bfd *output_
 
 	      /* The GOT entries have not been initialized yet.  Do it
 	         now, and emit any relocations.  */
-	      if ((info->shared || indx != 0)
+	      if ((bfd_link_pic (info) || indx != 0)
 		  && (h == NULL
 		      || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		      || h->root.type != bfd_link_hash_undefweak))
@@ -2295,7 +2297,7 @@ riscv_elf_finish_dynamic_symbol (bfd *ou
 	 the symbol was forced to be local because of a version file.
 	 The entry in the global offset table will already have been
 	 initialized in the relocate_section function.  */
-      if (info->shared
+      if (bfd_link_pic (info)
 	  && (info->symbolic || h->dynindx == -1)
 	  && h->def_regular)
 	{
@@ -2672,7 +2674,7 @@ _bfd_riscv_relax_call (bfd *abfd, asecti
   int r_type;
 
   /* See if this function call can be shortened.  */
-  if (!VALID_UJTYPE_IMM (foff) && !(!link_info->shared && near_zero))
+  if (!VALID_UJTYPE_IMM (foff) && !(!bfd_link_pic (link_info) && near_zero))
     return TRUE;
 
   /* Shorten the function call.  */
@@ -2799,7 +2801,7 @@ _bfd_riscv_relax_section (bfd *abfd, ase
 
   *again = FALSE;
 
-  if (info->relocatable
+  if (bfd_link_relocatable (info)
       || (sec->flags & SEC_RELOC) == 0
       || sec->reloc_count == 0
       || (/*info->disable_target_specific_optimizations*/ 0
@@ -2916,7 +2918,7 @@ fail:
 #define ELF_MAXPAGESIZE			0x2000
 #define ELF_COMMONPAGESIZE		0x2000
 
-#define TARGET_LITTLE_SYM		bfd_elfNN_riscv_vec
+#define TARGET_LITTLE_SYM		riscv_elfNN_vec
 #define TARGET_LITTLE_NAME		"elfNN-littleriscv"
 
 #define elf_backend_reloc_type_class	     riscv_reloc_type_class

Reply via email to