From: Nathan Sidwell Date: Thu, 8 Nov 2007 13:57:44 +0000 (+0000) Subject: * elf-vxworks.h (elf_vxworks_add_dynamic_entries): Declare. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4d2c0abd8e0a1756a94fbbcc9268e2730c6c922b;p=binutils-gdb.git * elf-vxworks.h (elf_vxworks_add_dynamic_entries): Declare. (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. --- diff --git a/bfd/elf-vxworks.c b/bfd/elf-vxworks.c index 98d2dfca98d..074430c78f3 100644 --- a/bfd/elf-vxworks.c +++ b/bfd/elf-vxworks.c @@ -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; +} + + diff --git a/bfd/elf-vxworks.h b/bfd/elf-vxworks.h index 1b461d0ea47..6850b3e3008 100644 --- a/bfd/elf-vxworks.h +++ b/bfd/elf-vxworks.h @@ -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 *); +