From patchwork Fri Mar 4 16:24:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 336 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:41:48 -0000 Delivered-To: patches@linaro.org Received: by 10.224.60.68 with SMTP id o4cs20369qah; Fri, 4 Mar 2011 08:24:04 -0800 (PST) Received: by 10.227.173.141 with SMTP id p13mr745278wbz.64.1299255843600; Fri, 04 Mar 2011 08:24:03 -0800 (PST) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id s1si4474357wbs.59.2011.03.04.08.24.03 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Mar 2011 08:24:03 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of richard.sandiford@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of richard.sandiford@linaro.org) smtp.mail=richard.sandiford@linaro.org Received: by wwb31 with SMTP id 31so3034479wwb.31 for ; Fri, 04 Mar 2011 08:24:03 -0800 (PST) Received: by 10.216.11.205 with SMTP id 55mr716438wex.72.1299255842888; Fri, 04 Mar 2011 08:24:02 -0800 (PST) Received: from richards-thinkpad (gbibp9ph1--blueice2n1.emea.ibm.com [195.212.29.75]) by mx.google.com with ESMTPS id n78sm1252533weq.27.2011.03.04.08.24.01 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Mar 2011 08:24:02 -0800 (PST) From: Richard Sandiford To: binutils@sourceware.org Mail-Followup-To: binutils@sourceware.org, patches@linaro.org, richard.sandiford@linaro.org Cc: patches@linaro.org Subject: [4/6] Always set dynobj during elf32_arm_check_relocs Date: Fri, 04 Mar 2011 16:24:00 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 References to STT_GNU_IFUNC symbols may need a iplt entry, and thus an .iplt section. The problem is that we don't definitively know during elf32_arm_check_relocs whether a relocation refers to an STT_GNU_IFUNC or not. The easiest way out is to be conservative and create the ifunc sections before the main loop in elf32_arm_check_relocs. Generic code will then remove them if they turn out not to be needed. Creating the sections requires a dynobj, so this patch sets that in the same place. This follows existing practice on PPC, among others. Tested on arm-linux-gnueabi. OK to install? Richard bfd/ * elf32-arm.c (elf32_arm_check_relocs): Always assign a dynobj. (elf32_arm_finish_dynamic_sections): Move sgot != NULL assertion into the PLT block. ld/ * emultempl/armelf.em (arm_elf_before_allocation): Check dynobj instead of dynamic_sections_created. Index: bfd/elf32-arm.c =================================================================== --- bfd/elf32-arm.c 2011-03-04 16:14:50.000000000 +0000 +++ bfd/elf32-arm.c 2011-03-04 16:15:39.000000000 +0000 @@ -11398,7 +11398,11 @@ elf32_arm_check_relocs (bfd *abfd, struc return FALSE; } - dynobj = elf_hash_table (info)->dynobj; + if (htab->root.dynobj == NULL) + htab->root.dynobj = abfd; + + dynobj = htab->root.dynobj; + symtab_hdr = & elf_symtab_hdr (abfd); sym_hashes = elf_sym_hashes (abfd); nsyms = NUM_SHDR_ENTRIES (symtab_hdr); @@ -11544,13 +11548,9 @@ elf32_arm_check_relocs (bfd *abfd, struc case R_ARM_GOTOFF32: case R_ARM_GOTPC: - if (htab->root.sgot == NULL) - { - if (htab->root.dynobj == NULL) - htab->root.dynobj = abfd; - if (!create_got_section (htab->root.dynobj, info)) - return FALSE; - } + if (htab->root.sgot == NULL + && !create_got_section (htab->root.dynobj, info)) + return FALSE; break; case R_ARM_PC24: @@ -13132,7 +13132,6 @@ elf32_arm_finish_dynamic_sections (bfd * dynobj = elf_hash_table (info)->dynobj; sgot = htab->root.sgotplt; - BFD_ASSERT (htab->symbian_p || sgot != NULL); sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); if (elf_hash_table (info)->dynamic_sections_created) @@ -13142,6 +13141,7 @@ elf32_arm_finish_dynamic_sections (bfd * splt = htab->root.splt; BFD_ASSERT (splt != NULL && sdyn != NULL); + BFD_ASSERT (htab->symbian_p || sgot != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); Index: ld/emultempl/armelf.em =================================================================== --- ld/emultempl/armelf.em 2011-03-04 16:13:27.000000000 +0000 +++ ld/emultempl/armelf.em 2011-03-04 16:14:56.000000000 +0000 @@ -67,7 +67,7 @@ arm_elf_before_allocation (void) /* We should be able to set the size of the interworking stub section. We can't do it until later if we have dynamic sections, though. */ - if (! elf_hash_table (&link_info)->dynamic_sections_created) + if (elf_hash_table (&link_info)->dynobj == NULL) { /* Here we rummage through the found bfds to collect glue information. */ LANG_FOR_EACH_INPUT_STATEMENT (is)