%L conversions
[deliverable/binutils-gdb.git] / bfd / elf32-i386.c
index e4c75af123964a660832d5a876fcf9d1ac9b9b1b..09067859a8dacbddb99f761f279b25ca05831743 100644 (file)
@@ -1,5 +1,5 @@
 /* Intel 80386/80486-specific support for 32-bit ELF
-   Copyright (C) 1993-2017 Free Software Foundation, Inc.
+   Copyright (C) 1993-2018 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -381,7 +381,7 @@ elf_i386_rtype_to_howto (bfd *abfd, unsigned r_type)
          >= R_386_vt - R_386_ext2))
     {
       /* xgettext:c-format */
-      _bfd_error_handler (_("%B: invalid relocation type %d"),
+      _bfd_error_handler (_("%pB: invalid relocation type %d"),
                          abfd, (int) r_type);
       indx = R_386_NONE;
     }
@@ -1156,10 +1156,10 @@ elf_i386_tls_transition (struct bfd_link_info *info, bfd *abfd,
 
       _bfd_error_handler
        /* xgettext:c-format */
-       (_("%B: TLS transition from %s to %s against `%s' at %#Lx "
-          "in section `%A' failed"),
+       (_("%pB: TLS transition from %s to %s against `%s'"
+          " at %#" PRIx64 " in section `%pA' failed"),
         abfd, from->name, to->name, name,
-        rel->r_offset, sec);
+        (uint64_t) rel->r_offset, sec);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
@@ -1247,7 +1247,7 @@ elf_i386_convert_load_reloc (bfd *abfd, Elf_Internal_Shdr *symtab_hdr,
 
       _bfd_error_handler
        /* xgettext:c-format */
-       (_("%B: direct GOT relocation R_386_GOT32X against `%s' without base"
+       (_("%pB: direct GOT relocation R_386_GOT32X against `%s' without base"
           " register can not be used when making a shared object"),
         abfd, name);
       return FALSE;
@@ -1507,7 +1507,7 @@ elf_i386_check_relocs (bfd *abfd,
       if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
        {
          /* xgettext:c-format */
-         _bfd_error_handler (_("%B: bad symbol index: %d"),
+         _bfd_error_handler (_("%pB: bad symbol index: %d"),
                              abfd, r_symndx);
          goto error_return;
        }
@@ -1578,6 +1578,10 @@ elf_i386_check_relocs (bfd *abfd,
                                     rel, rel_end, h, r_symndx, FALSE))
        goto error_return;
 
+      /* Check if _GLOBAL_OFFSET_TABLE_ is referenced.  */
+      if (h == htab->elf.hgot)
+       htab->got_referenced = TRUE;
+
       switch (r_type)
        {
        case R_386_TLS_LDM:
@@ -1700,7 +1704,7 @@ elf_i386_check_relocs (bfd *abfd,
                                             NULL);
                    _bfd_error_handler
                      /* xgettext:c-format */
-                     (_("%B: `%s' accessed both as normal and "
+                     (_("%pB: `%s' accessed both as normal and "
                         "thread local symbol"),
                       abfd, name);
                    bfd_set_error (bfd_error_bad_value);
@@ -1720,11 +1724,19 @@ elf_i386_check_relocs (bfd *abfd,
 
        case R_386_GOTOFF:
        case R_386_GOTPC:
-       create_got:
+create_got:
          if (r_type != R_386_TLS_IE)
            {
              if (eh != NULL)
-               eh->zero_undefweak &= 0x2;
+               {
+                 eh->zero_undefweak &= 0x2;
+
+                 /* Need GOT to resolve undefined weak symbol to 0.  */
+                 if (r_type == R_386_GOTOFF
+                     && h->root.type == bfd_link_hash_undefweak
+                     && bfd_link_executable (info))
+                   htab->got_referenced = TRUE;
+               }
              break;
            }
          /* Fall through */
@@ -1764,7 +1776,7 @@ do_relocation:
                    {
                      _bfd_error_handler
                        /* xgettext:c-format */
-                       (_("%B: unsupported non-PIC call to IFUNC `%s'"),
+                       (_("%pB: unsupported non-PIC call to IFUNC `%s'"),
                         abfd, h->root.root.string);
                      bfd_set_error (bfd_error_bad_value);
                      goto error_return;
@@ -1800,7 +1812,7 @@ do_relocation:
 
          size_reloc = FALSE;
 do_size:
-         if (NEED_DYNAMIC_RELOCATION_P (info, h, sec, r_type,
+         if (NEED_DYNAMIC_RELOCATION_P (info, FALSE, h, sec, r_type,
                                         R_386_32))
            {
              struct elf_dyn_relocs *p;
@@ -2342,7 +2354,7 @@ bad_ifunc_reloc:
                                         NULL);
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B: relocation %s against STT_GNU_IFUNC "
+               (_("%pB: relocation %s against STT_GNU_IFUNC "
                   "symbol `%s' isn't supported"), input_bfd,
                 howto->name, name);
              bfd_set_error (bfd_error_bad_value);
@@ -2375,7 +2387,7 @@ do_ifunc_pointer:
 
                  if (POINTER_LOCAL_IFUNC_P (info, h))
                    {
-                     info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
+                     info->callbacks->minfo (_("Local IFUNC function `%s' in %pB\n"),
                                              h->root.root.string,
                                              h->root.u.def.section->owner);
 
@@ -2590,7 +2602,7 @@ disallow_got32:
 
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%B: direct GOT relocation %s against `%s'"
+                   (_("%pB: direct GOT relocation %s against `%s'"
                       " without base register can not be used"
                       " when making a shared object"),
                     input_bfd, howto->name, name);
@@ -2640,7 +2652,7 @@ disallow_got32:
 
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%B: relocation R_386_GOTOFF against undefined %s"
+                   (_("%pB: relocation R_386_GOTOFF against undefined %s"
                       " `%s' can not be used when making a shared object"),
                     input_bfd, v, h->root.root.string);
                  bfd_set_error (bfd_error_bad_value);
@@ -2653,7 +2665,7 @@ disallow_got32:
                {
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%B: relocation R_386_GOTOFF against protected %s"
+                   (_("%pB: relocation R_386_GOTOFF against protected %s"
                       " `%s' can not be used when making a shared object"),
                     input_bfd,
                     h->type == STT_FUNC ? "function" : "data",
@@ -3430,10 +3442,10 @@ disallow_got32:
        {
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
+           (_("%pB(%pA+%#" PRIx64 "): unresolvable %s relocation against symbol `%s'"),
             input_bfd,
             input_section,
-            rel->r_offset,
+            (uint64_t) rel->r_offset,
             howto->name,
             h->root.root.string);
          return FALSE;
@@ -3470,9 +3482,9 @@ check_relocation_error:
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B(%A+%#Lx): reloc against `%s': error %d"),
+               (_("%pB(%pA+%#" PRIx64 "): reloc against `%s': error %d"),
                 input_bfd, input_section,
-                rel->r_offset, name, (int) r);
+                (uint64_t) rel->r_offset, name, (int) r);
              return FALSE;
            }
        }
@@ -3681,7 +3693,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
                          + got_offset);
          if (PLT_LOCAL_IFUNC_P (info, h))
            {
-             info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
+             info->callbacks->minfo (_("Local IFUNC function `%s' in %pB\n"),
                                      h->root.root.string,
                                      h->root.u.def.section->owner);
 
@@ -3820,7 +3832,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
                }
              if (SYMBOL_REFERENCES_LOCAL_P (info, h))
                {
-                 info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
+                 info->callbacks->minfo (_("Local IFUNC function `%s' in %pB\n"),
                                          h->root.root.string,
                                          h->root.u.def.section->owner);
 
@@ -4178,6 +4190,7 @@ elf_i386_get_synthetic_symtab (bfd *abfd,
   switch (get_elf_x86_backend_data (abfd)->target_os)
     {
     case is_normal:
+    case is_solaris:
       non_lazy_plt = &elf_i386_non_lazy_plt;
       lazy_ibt_plt = &elf_i386_lazy_ibt_plt;
       non_lazy_ibt_plt = &elf_i386_non_lazy_ibt_plt;
@@ -4337,6 +4350,7 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
   switch (get_elf_x86_backend_data (info->output_bfd)->target_os)
     {
     case is_normal:
+    case is_solaris:
       init_table.plt0_pad_byte = 0x0;
       init_table.lazy_plt = &elf_i386_lazy_plt;
       init_table.non_lazy_plt = &elf_i386_non_lazy_plt;
@@ -4454,6 +4468,14 @@ elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
 #undef TARGET_LITTLE_NAME
 #define        TARGET_LITTLE_NAME              "elf32-i386-sol2"
 
+static const struct elf_x86_backend_data elf_i386_solaris_arch_bed =
+  {
+    is_solaris                         /* os */
+  };
+
+#undef elf_backend_arch_data
+#define        elf_backend_arch_data           &elf_i386_solaris_arch_bed
+
 #undef elf_backend_post_process_headers
 
 /* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
@@ -4580,6 +4602,9 @@ elf32_iamcu_elf_object_p (bfd *abfd)
 #undef ELF_MACHINE_CODE
 #define        ELF_MACHINE_CODE                EM_IAMCU
 
+#undef elf_backend_arch_data
+#define        elf_backend_arch_data           &elf_i386_arch_bed
+
 #undef ELF_OSABI
 
 #undef  elf32_bed
This page took 0.042037 seconds and 4 git commands to generate.