From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51888 invoked by alias); 8 May 2017 14:29:28 -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 48371 invoked by uid 89); 8 May 2017 14:29:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_LOTSOFHASH,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Requirements, HTo:U*nickc, Secure, Requirement X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 May 2017 14:29:24 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AAB611516; Mon, 8 May 2017 07:29:25 -0700 (PDT) Received: from [10.2.206.52] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EA0133F4FF; Mon, 8 May 2017 07:29:24 -0700 (PDT) Subject: Re: [PATCH, LD, ping] Make import libraries relocatable objects To: Nick Clifton , Richard Earnshaw , Alan Modra , binutils@sourceware.org References: <3f56df33-a8ee-778d-a1b8-7a91c68cc359@foss.arm.com> <8d909776-eebd-4301-8089-44eb6e43b52d@redhat.com> <52e50c88-4e33-fe0f-84b6-ff237848b599@foss.arm.com> From: Thomas Preudhomme Message-ID: <69630dd8-b5bd-bc4e-6d61-4de676e065c1@foss.arm.com> Date: Mon, 08 May 2017 14:29:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------7D5E2B95602179177672F8A8" X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00084.txt.bz2 This is a multi-part message in MIME format. --------------7D5E2B95602179177672F8A8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 370 Great then. Committed the attached updated patch as per your comments. Best regards, Thomas On 08/05/17 09:51, Nick Clifton wrote: > Hi Thomas, > >> Will do. Can you confirm you are happy with the target-independent change as well? > > I am. > > As far as I know only the ARM target is actually using ELF based import libraries at the moment. > > Cheers > Nick > > --------------7D5E2B95602179177672F8A8 Content-Type: text/x-patch; name="relocatable_object_implib.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="relocatable_object_implib.patch" Content-length: 2761 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 434649f1ca18841320345e7fdf437c4ad47a1428..8dcaf45523e726dc71ff8df8bdbd07ba759120fb 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -17498,6 +17498,10 @@ elf32_arm_filter_implib_symbols (bfd *abfd ATTRIBUTE_UNUSED, { struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (info); + /* Requirement 8 of "ARM v8-M Security Extensions: Requirements on + Development Tools" (ARM-ECM-0359818) mandates Secure Gateway import + library to be a relocatable object file. */ + BFD_ASSERT (!(bfd_get_file_flags (info->out_implib_bfd) & EXEC_P)); if (globals->cmse_implib) return elf32_arm_filter_cmse_symbols (abfd, info, syms, symcount); else diff --git a/bfd/elflink.c b/bfd/elflink.c index 4af4b1cd3d33c0b566349d545038accee4ffd51a..f8555d802f62bc2e2c46d50959f9bd1b2f0a7177 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -11271,10 +11271,11 @@ elf_output_implib (bfd *abfd, struct bfd_link_info *info) if (!bfd_set_format (implib_bfd, bfd_object)) return FALSE; + /* Use flag from executable but make it a relocatable object. */ flags = bfd_get_file_flags (abfd); flags &= ~HAS_RELOC; if (!bfd_set_start_address (implib_bfd, 0) - || !bfd_set_file_flags (implib_bfd, flags)) + || !bfd_set_file_flags (implib_bfd, flags & ~EXEC_P)) return FALSE; /* Copy architecture of output file to import library file. */ diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 1a4d262e60816f6ebaa44e54a32125985bf7d0f2..2e193324907e71b86d56f9c82adca1cae3c025a8 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -685,7 +685,8 @@ set armeabitests_nonacl { "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-implib.lib --cmse-implib" "" "-march=armv8-m.base -mthumb --defsym VER=1" {cmse-implib.s} - {{readelf {-s tmpdir/cmse-implib.lib} cmse-implib.rd}} + {{readelf {-s tmpdir/cmse-implib.lib} cmse-implib.rd} + {readelf {-h tmpdir/cmse-implib.lib} cmse-implib.type}} "cmse-implib"} {"Input secure gateway import library" "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-new-implib.lib --in-implib=tmpdir/cmse-implib.lib --cmse-implib" "" diff --git a/ld/testsuite/ld-arm/cmse-implib.type b/ld/testsuite/ld-arm/cmse-implib.type new file mode 100644 index 0000000000000000000000000000000000000000..7bb3bccc8e5d0ee99a0b9a2674296673b1c3c349 --- /dev/null +++ b/ld/testsuite/ld-arm/cmse-implib.type @@ -0,0 +1,9 @@ +#... +File: tmpdir/cmse-implib.lib +#... +[[:space:]]+Type:[[:space:]]+REL \(Relocatable file\) +#... +File: tmpdir/cmse-implib +#... +[[:space:]]+Type:[[:space:]]+EXEC \(Executable file\) +#... --------------7D5E2B95602179177672F8A8--