From patchwork Mon Aug 29 14:56:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 74916 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1674410qga; Mon, 29 Aug 2016 07:57:11 -0700 (PDT) X-Received: by 10.98.94.6 with SMTP id s6mr33618595pfb.31.1472482631346; Mon, 29 Aug 2016 07:57:11 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l1si39546962pal.86.2016.08.29.07.57.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Aug 2016 07:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-93705-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of binutils-return-93705-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-93705-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=J9hw 6I/BRJ3k/99lWeAcwmJL9Y9vm2uU5ceQKkDJHht7SYKcvpvEDY06zravvEep+n1x JVehnzqA795dUxy7hyQSnyaPsQnVwOxLnZ/rl2T97IfoXT8UYswhHb7C7fWY26hf h/7WeDgSUEygRIsCuxLmKmLNNSgZn0Dhs+nptiw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; s=default; bh=ifSV1RaXmR 1z3cWVl4Jsf/UIex0=; b=aszdgbaZivXL8VL+qDuAjaddXk1C+IPKo3bcMb8Mp6 8QoBjj6CzYqwvbFYY0xpr8Z7kLqsZZzJh0EiUNbrQAN6APrjMDhRitsL2DsM7NIz 4NJgTuZO7jLVCz8dKKhyOfjdJa99OKkT6CmjGqyc9izGpbjaPCrTRj7FTtay9QeB w= Received: (qmail 81063 invoked by alias); 29 Aug 2016 14:56:55 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Delivered-To: mailing list binutils@sourceware.org Received: (qmail 81046 invoked by uid 89); 29 Aug 2016 14:56:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=holidays, lyon, Lyon, D*foss.arm.com X-HELO: mail-qt0-f181.google.com Received: from mail-qt0-f181.google.com (HELO mail-qt0-f181.google.com) (209.85.216.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 29 Aug 2016 14:56:44 +0000 Received: by mail-qt0-f181.google.com with SMTP id u25so69422823qtb.1 for ; Mon, 29 Aug 2016 07:56:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hgZ+00Tm4ZhQICguLLF3/amIn4Z0kDKHdb3EtqK6hRM=; b=Gn6VFpvdSbgNuIUJBw88IZMxdOivpycNp6NsiUDH0kbLGenER97wa0eU8L8OmVdGU0 yrBBWbETzOFvYXM0IBBSluwtSm5lo3oOX74ds60/BWkzbJqsrBeuwfapP/RlMgBk0IRU aExxU1vXlX2FVVPhO2ZYHKcdA1bhw5fUTByvXzwAuF23yhwS8YYWmgDM/aNfMseD0/KH 6AmIwXKd+pebQKavCuk+IIZIjllP85jmHz+3O3zs64b3oWlRX/N7KCSgxDoKjPBjDFFz vKrTsrodOljkdtwYbw5RsWkwloHBBScWwugfoPObDJefVgoD9iSkkcG4hhnpMxJMqrd3 7iCQ== X-Gm-Message-State: AE9vXwOKcvPJ5gjmRVWuF53BqrHBTNSybNpM71LVmV47SjKeikAfEgyCYO6bBtEL030NNIMK5J3mwmpNl9TzOdK5 X-Received: by 10.200.46.216 with SMTP id i24mr19312383qta.79.1472482602798; Mon, 29 Aug 2016 07:56:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.21.9 with HTTP; Mon, 29 Aug 2016 07:56:41 -0700 (PDT) In-Reply-To: <210bfecf-d453-62f6-7657-ea22ed3bc006@foss.arm.com> References: <005601d13d58$522afb60$f680f220$@foss.arm.com> <1796369.8BmbsroDJA@e108577-lin> <577E5070.3020606@arm.com> <4163700.8nzTNaTl0I@e108577-lin> <378f9855-1f2f-abcc-6030-b077e9b1932e@foss.arm.com> <5b0cd645-7628-705f-3c86-7388513c0708@arm.com> <5f9e12c3-b5b5-1e7d-e319-018a270690e9@foss.arm.com> <0051e9d5-09e6-8bb1-fc15-40693a82fc6f@arm.com> <778fe071-0d3d-aa68-0923-aff851b7d656@foss.arm.com> <210bfecf-d453-62f6-7657-ea22ed3bc006@foss.arm.com> From: Christophe Lyon Date: Mon, 29 Aug 2016 16:56:41 +0200 Message-ID: Subject: Re: [RFC PATCH, binutils, ARM 11/11, ping] Add support for stable secure gateway veneers addresses To: Thomas Preudhomme Cc: binutils@sourceware.org X-IsSubscribed: yes On 26 August 2016 at 16:18, Thomas Preudhomme wrote: > On 26/08/16 13:36, Thomas Preudhomme wrote: >> >> Hi Christophe, >> >> On 26/08/16 12:55, Christophe Lyon wrote: >>> >>> >>> I've noticed that the new tests fail on armeb. I didn't look at the >>> detailed logs yet, but I guess you can a look? >>> >>> ./ld/ld.sum:FAIL: Input secure gateway import library >>> ./ld/ld.sum:FAIL: Input secure gateway import library: no output import >>> library >>> ./ld/ld.sum:FAIL: Input secure gateway import library: earlier stub >>> section base >>> ./ld/ld.sum:FAIL: Input secure gateway import library: later stub section >>> base >>> ./ld/ld.sum:FAIL: Input secure gateway import library: veneer comeback >>> ./ld/ld.sum:FAIL: Input secure gateway import library: entry function >>> change >> >> >> I can reproduce indeed. I'll have a look, thanks for the notice. Note that >> Monday is a bank holidays here so might only answer after that if I'm too >> slow >> to find the root cause. > > > Doh, the code checks for a SG instruction by comparing the 4 bytes in the > code against its litteral value. The problem of course is that the read puts > the 4 bytes of the instruction in memory order but these will then be > interpreted according to the endianness. > > The fix should be easy. > Indeed, thanks to your analysis it was quick enough. Here is a patch, maybe there is a simpler way? Thanks, Christophe > Best regards, > > Thomas 2016-08-29 Christophe Lyon bfd/ * elf32-arm.c (cmse_entry_fct_p): Read first instruction in an endianness independent way. diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 9ff418a..5c04b9b 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -5791,11 +5791,19 @@ cmse_entry_fct_p (struct elf32_arm_link_hash_entry *hash) section = hash->root.root.u.def.section; abfd = section->owner; offset = hash->root.root.u.def.value - section->vma; - if (!bfd_get_section_contents (abfd, section, &first_insn, offset, - sizeof (first_insn))) - return FALSE; /* Start by SG instruction. */ + bfd_byte * contents; + /* Get cached copy if it exists. */ + if (elf_section_data (section)->this_hdr.contents != NULL) + contents = elf_section_data (section)->this_hdr.contents; + else + { + /* Go get them off disk. */ + if (! bfd_malloc_and_get_section (abfd, section, &contents)) + return FALSE; + } + first_insn = bfd_get_32 (abfd, contents + offset); return first_insn == 0xe97fe97f; }