* elf-vxworks.h (elf_vxworks_add_dynamic_entries): Declare.
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 8 Nov 2007 13:57:44 +0000 (13:57 +0000)
committerNathan Sidwell <nathan@codesourcery.com>
Thu, 8 Nov 2007 13:57:44 +0000 (13:57 +0000)
(elf_vxworks_finish_dynamic_entry): Declare.
* elf-vxworks.c: Include elf/vxworks.h.
(elf_vxworks_add_dynamic_entries): New.
(elf_vxworks_finish_dynamic_entry): New.
* Makefile.am (elf-vxworks.lo): Add dependency.
* Makefile.in (elf-vxworks.lo): Add dependency.
* elf32-i386.c (elf_i386_size_dynamic_sections,
elf_i386_finish_dynamic_sections): Call
elf_vxworks_add_dynamic_entries and
elf_vxworks_finish_dynamic_entry.
* elf32-ppc.c (ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections,
sparc_finish_dyn): Likewise.
* elf32-sh.c (sh_elf_size_dynamic_sections,
sh_elf_finish_dynamic_sections): Likewise.
* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_sections): Likewise.
* elf32-arm.c (elf32_arm_size_dynamic_sections,
elf32_arm_finish_dynamic_sections): Likewise.

bfd/elf-vxworks.c
bfd/elf-vxworks.h

index 98d2dfca98d4779608a281654e3c1ffed6145b94..074430c78f32e25d222585a940e7a8f75d5c5160 100644 (file)
@@ -25,6 +25,7 @@
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf-vxworks.h"
+#include "elf/vxworks.h"
 
 /* Return true if symbol NAME, as defined by ABFD, is one of the special
    __GOTT_BASE__ or __GOTT_INDEX__ symbols.  */
@@ -225,3 +226,69 @@ elf_vxworks_final_write_processing (bfd *abfd,
   if (sec)
     d->this_hdr.sh_info = elf_section_data (sec)->this_idx;
 }
+
+/* Add the dynamic entries required by VxWorks.  These point to the
+   tls sections.  */
+
+bfd_boolean
+elf_vxworks_add_dynamic_entries (bfd *output_bfd, struct bfd_link_info *info)
+{
+  if (bfd_get_section_by_name (output_bfd, ".tls_data"))
+    {
+      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;
+    }
+  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 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
+elf_vxworks_finish_dynamic_entry (bfd *output_bfd, Elf_Internal_Dyn *dyn)
+{
+  asection *sec;
+  
+  switch (dyn->d_tag)
+    {
+    default:
+      return FALSE;
+      
+    case DT_VX_WRS_TLS_DATA_START:
+      sec = bfd_get_section_by_name (output_bfd, ".tls_data");
+      dyn->d_un.d_ptr = sec->vma;
+      break;
+      
+    case DT_VX_WRS_TLS_DATA_SIZE:
+      sec = bfd_get_section_by_name (output_bfd, ".tls_data");
+      dyn->d_un.d_val = sec->size;
+      break;
+      
+    case DT_VX_WRS_TLS_DATA_ALIGN:
+      sec = bfd_get_section_by_name (output_bfd, ".tls_data");
+      dyn->d_un.d_val
+       = (bfd_size_type)1 << bfd_get_section_alignment (abfd, sec);
+      break;
+      
+    case DT_VX_WRS_TLS_VARS_START:
+      sec = bfd_get_section_by_name (output_bfd, ".tls_vars");
+      dyn->d_un.d_ptr = sec->vma;
+      break;
+      
+    case DT_VX_WRS_TLS_VARS_SIZE:
+      sec = bfd_get_section_by_name (output_bfd, ".tls_vars");
+      dyn->d_un.d_val = sec->size;
+      break;
+    }
+  return TRUE;
+}
+
+
index 1b461d0ea47b11907b4ff5d11d9aa56b96a78773..6850b3e30089599841da33bb72318c63cafaba69 100644 (file)
@@ -33,3 +33,6 @@ bfd_boolean elf_vxworks_emit_relocs
 void elf_vxworks_final_write_processing (bfd *, bfd_boolean);
 bfd_boolean elf_vxworks_create_dynamic_sections
   (bfd *, struct bfd_link_info *, asection **);
+bfd_boolean elf_vxworks_add_dynamic_entries (bfd *, struct bfd_link_info *);
+bfd_boolean elf_vxworks_finish_dynamic_entry (bfd *, Elf_Internal_Dyn *);
+