Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/binutils/dist/bfd fix bfd for riscv.



details:   https://anonhg.NetBSD.org/src/rev/de765a1b2a08
branches:  trunk
changeset: 343330:de765a1b2a08
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 29 22:39:00 2016 +0000

description:
fix bfd for riscv.

diffstat:

 external/gpl3/binutils/dist/bfd/elfnn-riscv.c |  88 +++++++++++++-------------
 1 files changed, 45 insertions(+), 43 deletions(-)

diffs (truncated from 350 to 300 lines):

diff -r bae6a135f0fb -r de765a1b2a08 external/gpl3/binutils/dist/bfd/elfnn-riscv.c
--- a/external/gpl3/binutils/dist/bfd/elfnn-riscv.c     Fri Jan 29 22:25:45 2016 +0000
+++ b/external/gpl3/binutils/dist/bfd/elfnn-riscv.c     Fri Jan 29 22:39:00 2016 +0000
@@ -26,10 +26,12 @@
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "libiberty.h"
 #include "libbfd.h"
+#include "bfd_stdint.h"
+#include "elf-bfd.h"
 #include "bfdlink.h"
-#include "genlink.h"
-#include "elf-bfd.h"
+#include "objalloc.h"
 #include "elfxx-riscv.h"
 #include "elf/riscv.h"
 #include "opcode/riscv.h"
@@ -358,7 +360,7 @@
     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 @@
     }
 
   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 @@
   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 @@
          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 @@
        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 @@
          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 @@
             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 @@
   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 @@
        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 @@
      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 @@
     }
 
   if (eh->tls_type & ~GOT_NORMAL)
-    return _bfd_elf_adjust_dynamic_copy (h, htab->sdyntdata);
-
-  return _bfd_elf_adjust_dynamic_copy (h, htab->sdynbss);
+    return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdyntdata);
+
+  return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdynbss);
 }
 
 /* Allocate space in .plt, .got and associated reloc sections for
@@ -995,7 +997,7 @@
            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 @@
             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 @@
       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 @@
      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 @@
   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 @@
 
   /* 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 @@
              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 @@
 #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 @@
        }
       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 @@
        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 @@
              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 @@
                off &= ~1;
              else
                {
-                 if (info->shared)
+                 if (bfd_link_pic (info))
                    {
                      asection *s;
                      Elf_Internal_Rela outrel;
@@ -1885,7 +1887,7 @@
        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 @@
          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 @@
              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 @@
                bfd_boolean dyn;
                dyn = htab->elf.dynamic_sections_created;
 
-               if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
-                   && (!info->shared



Home | Main Index | Thread Index | Old Index