Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf32-i386.c
index e4c75af123964a660832d5a876fcf9d1ac9b9b1b..1a4b53ae3055331592b043ef34b518d690ee2c1b 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.
 
@@ -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:
@@ -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 */
@@ -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;
@@ -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.024538 seconds and 4 git commands to generate.