RISC-V: Allow nested implications for extensions
[binutils-gdb.git] / bfd / elf-vxworks.c
index 8fe17bf628fdea9be2c49c4017758bbbca26d2f6..3a670c08991aca6b4a99b355a1d06130a4cdb964 100644 (file)
@@ -1,5 +1,5 @@
 /* VxWorks support for ELF
-   Copyright (C) 2005-2019 Free Software Foundation, Inc.
+   Copyright (C) 2005-2023 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -28,7 +28,7 @@
 /* Return true if symbol NAME, as defined by ABFD, is one of the special
    __GOTT_BASE__ or __GOTT_INDEX__ symbols.  */
 
-static bfd_boolean
+static bool
 elf_vxworks_gott_symbol_p (bfd *abfd, const char *name)
 {
   char leading;
@@ -37,7 +37,7 @@ elf_vxworks_gott_symbol_p (bfd *abfd, const char *name)
   if (leading)
     {
       if (*name != leading)
-       return FALSE;
+       return false;
       name++;
     }
   return (strcmp (name, "__GOTT_BASE__") == 0
@@ -45,7 +45,7 @@ elf_vxworks_gott_symbol_p (bfd *abfd, const char *name)
 }
 
 /* Tweak magic VxWorks symbols as they are loaded.  */
-bfd_boolean
+bool
 elf_vxworks_add_symbol_hook (bfd *abfd,
                             struct bfd_link_info *info,
                             Elf_Internal_Sym *sym,
@@ -69,14 +69,14 @@ elf_vxworks_add_symbol_hook (bfd *abfd,
       *flagsp |= BSF_WEAK;
     }
 
-  return TRUE;
+  return true;
 }
 
 /* Perform VxWorks-specific handling of the create_dynamic_sections hook.
    When creating an executable, set *SRELPLT2_OUT to the .rel(a).plt.unloaded
    section.  */
 
-bfd_boolean
+bool
 elf_vxworks_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info,
                                     asection **srelplt2_out)
 {
@@ -98,7 +98,7 @@ elf_vxworks_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info,
                                              | SEC_LINKER_CREATED);
       if (s == NULL
          || !bfd_set_section_alignment (s, bed->s->log_file_align))
-       return FALSE;
+       return false;
 
       *srelplt2_out = s;
     }
@@ -114,7 +114,7 @@ elf_vxworks_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info,
       htab->hgot->other &= ~ELF_ST_VISIBILITY (-1);
       htab->hgot->forced_local = 0;
       if (!bfd_elf_link_record_dynamic_symbol (info, htab->hgot))
-       return FALSE;
+       return false;
     }
   if (htab->hplt)
     {
@@ -122,7 +122,7 @@ elf_vxworks_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info,
       htab->hplt->type = STT_FUNC;
     }
 
-  return TRUE;
+  return true;
 }
 
 /* Tweak magic VxWorks symbols as they are written to the output file.  */
@@ -146,7 +146,7 @@ elf_vxworks_link_output_symbol_hook (struct bfd_link_info *info
 /* Copy relocations into the output file.  Fixes up relocations against PLT
    entries, then calls the generic routine.  */
 
-bfd_boolean
+bool
 elf_vxworks_emit_relocs (bfd *output_bfd,
                         asection *input_section,
                         Elf_Internal_Shdr *input_rel_hdr,
@@ -212,7 +212,7 @@ elf_vxworks_emit_relocs (bfd *output_bfd,
 
 /* Set the sh_link and sh_info fields on the static plt relocation secton.  */
 
-bfd_boolean
+bool
 elf_vxworks_final_write_processing (bfd *abfd)
 {
   asection * sec;
@@ -235,7 +235,7 @@ elf_vxworks_final_write_processing (bfd *abfd)
 /* Add the dynamic entries required by VxWorks.  These point to the
    tls sections.  */
 
-bfd_boolean
+bool
 elf_vxworks_add_dynamic_entries (bfd *output_bfd, struct bfd_link_info *info)
 {
   if (bfd_get_section_by_name (output_bfd, ".tls_data"))
@@ -243,21 +243,21 @@ elf_vxworks_add_dynamic_entries (bfd *output_bfd, struct bfd_link_info *info)
       if (!_bfd_elf_add_dynamic_entry (info, DT_VX_WRS_TLS_DATA_START, 0)
          || !_bfd_elf_add_dynamic_entry (info, DT_VX_WRS_TLS_DATA_SIZE, 0)
          || !_bfd_elf_add_dynamic_entry (info, DT_VX_WRS_TLS_DATA_ALIGN, 0))
-       return FALSE;
+       return false;
     }
   if (bfd_get_section_by_name (output_bfd, ".tls_vars"))
     {
       if (!_bfd_elf_add_dynamic_entry (info, DT_VX_WRS_TLS_VARS_START, 0)
          || !_bfd_elf_add_dynamic_entry (info, DT_VX_WRS_TLS_VARS_SIZE, 0))
-       return FALSE;
+       return false;
     }
-  return TRUE;
+  return true;
 }
 
 /* If *DYN is one of the VxWorks-specific dynamic entries, then fill
    in the value now  and return TRUE.  Otherwise return FALSE.  */
 
-bfd_boolean
+bool
 elf_vxworks_finish_dynamic_entry (bfd *output_bfd, Elf_Internal_Dyn *dyn)
 {
   asection *sec;
@@ -265,7 +265,7 @@ elf_vxworks_finish_dynamic_entry (bfd *output_bfd, Elf_Internal_Dyn *dyn)
   switch (dyn->d_tag)
     {
     default:
-      return FALSE;
+      return false;
 
     case DT_VX_WRS_TLS_DATA_START:
       sec = bfd_get_section_by_name (output_bfd, ".tls_data");
@@ -292,7 +292,20 @@ elf_vxworks_finish_dynamic_entry (bfd *output_bfd, Elf_Internal_Dyn *dyn)
       dyn->d_un.d_val = sec->size;
       break;
     }
-  return TRUE;
+  return true;
 }
 
+/* Add dynamic tags.  */
 
+bool
+_bfd_elf_maybe_vxworks_add_dynamic_tags (bfd *output_bfd,
+                                        struct bfd_link_info *info,
+                                        bool need_dynamic_reloc)
+{
+  struct elf_link_hash_table *htab = elf_hash_table (info);
+  return (_bfd_elf_add_dynamic_tags (output_bfd, info,
+                                    need_dynamic_reloc)
+         && (!htab->dynamic_sections_created
+             || htab->target_os != is_vxworks
+             || elf_vxworks_add_dynamic_entries (output_bfd, info)));
+}