From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67698 invoked by alias); 27 Apr 2017 16:00:53 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 67441 invoked by uid 89); 27 Apr 2017 16:00:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,NO_DNS_FOR_FROM,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Apr 2017 16:00:31 +0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Apr 2017 09:00:27 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([172.25.70.218]) by fmsmga005.fm.intel.com with ESMTP; 27 Apr 2017 09:00:27 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 1000) id 75B7A2003B0; Thu, 27 Apr 2017 09:00:27 -0700 (PDT) Date: Thu, 27 Apr 2017 16:00:00 -0000 From: "H.J. Lu" To: binutils@sourceware.org Subject: [committed, PATCH] i386: Simplify VxWorks for non-PIC Message-ID: <20170427160027.GA23641@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.8.0 (2017-02-23) X-SW-Source: 2017-04/txt/msg00265.txt.bz2 Change if (PIC) { #1 } else { #2 if (VxWorks) { #3 } } #4 if (VxWorks && !PIC) { #5 } to #4 if (PIC) { #1 } else { #2 if (VxWorks) { #3 #5 } } * elf32-i386.c (elf_i386_finish_dynamic_sections): Simplify VxWorks for non-PIC. --- bfd/ChangeLog | 5 +++++ bfd/elf32-i386.c | 62 +++++++++++++++++++++++++++----------------------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 376f201..5f8f67c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2017-04-27 H.J. Lu + + * elf32-i386.c (elf_i386_finish_dynamic_sections): Simplify + VxWorks for non-PIC. + 2017-04-27 Alan Modra * elf-bfd.h (struct elf_backend_data): Make asection param of diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 78c5d5b..45c6c0e 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -5848,9 +5848,15 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd, bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); } - /* Fill in the first entry in the procedure linkage table. */ if (htab->elf.splt && htab->elf.splt->size > 0) { + /* UnixWare sets the entsize of .plt to 4, although that doesn't + really seem like the right value. */ + elf_section_data (htab->elf.splt->output_section) + ->this_hdr.sh_entsize = 4; + + /* Fill in the special first entry in the procedure linkage + table. */ if (bfd_link_pic (info)) { memcpy (htab->elf.splt->contents, abed->plt->pic_plt0_entry, @@ -5882,6 +5888,9 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd, if (abed->is_vxworks) { Elf_Internal_Rela rel; + int num_plts = (htab->elf.splt->size + / abed->plt->plt_entry_size) - 1; + unsigned char *p; /* Generate a relocation for _GLOBAL_OFFSET_TABLE_ + 4. On IA32 we use REL relocations so the addend goes in @@ -5900,39 +5909,28 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd, bfd_elf32_swap_reloc_out (output_bfd, &rel, htab->srelplt2->contents + sizeof (Elf32_External_Rel)); - } - } - - /* UnixWare sets the entsize of .plt to 4, although that doesn't - really seem like the right value. */ - elf_section_data (htab->elf.splt->output_section) - ->this_hdr.sh_entsize = 4; - /* Correct the .rel.plt.unloaded relocations. */ - if (abed->is_vxworks && !bfd_link_pic (info)) - { - int num_plts = (htab->elf.splt->size - / abed->plt->plt_entry_size) - 1; - unsigned char *p; - - p = htab->srelplt2->contents; - if (bfd_link_pic (info)) - p += PLTRESOLVE_RELOCS_SHLIB * sizeof (Elf32_External_Rel); - else - p += PLTRESOLVE_RELOCS * sizeof (Elf32_External_Rel); - - for (; num_plts; num_plts--) - { - Elf_Internal_Rela rel; - bfd_elf32_swap_reloc_in (output_bfd, p, &rel); - rel.r_info = ELF32_R_INFO (htab->elf.hgot->indx, R_386_32); - bfd_elf32_swap_reloc_out (output_bfd, &rel, p); - p += sizeof (Elf32_External_Rel); + /* Correct the .rel.plt.unloaded relocations. */ + p = htab->srelplt2->contents; + if (bfd_link_pic (info)) + p += PLTRESOLVE_RELOCS_SHLIB * sizeof (Elf32_External_Rel); + else + p += PLTRESOLVE_RELOCS * sizeof (Elf32_External_Rel); - bfd_elf32_swap_reloc_in (output_bfd, p, &rel); - rel.r_info = ELF32_R_INFO (htab->elf.hplt->indx, R_386_32); - bfd_elf32_swap_reloc_out (output_bfd, &rel, p); - p += sizeof (Elf32_External_Rel); + for (; num_plts; num_plts--) + { + bfd_elf32_swap_reloc_in (output_bfd, p, &rel); + rel.r_info = ELF32_R_INFO (htab->elf.hgot->indx, + R_386_32); + bfd_elf32_swap_reloc_out (output_bfd, &rel, p); + p += sizeof (Elf32_External_Rel); + + bfd_elf32_swap_reloc_in (output_bfd, p, &rel); + rel.r_info = ELF32_R_INFO (htab->elf.hplt->indx, + R_386_32); + bfd_elf32_swap_reloc_out (output_bfd, &rel, p); + p += sizeof (Elf32_External_Rel); + } } } } -- 2.9.3