From patchwork Sun Apr 28 03:52:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 240234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B78492C00AC for ; Sun, 28 Apr 2013 13:52:19 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=LtwwDnUOkMP/hO+wJaVhNLXzUvbaCEkOeG6SgTrfap+LobU0cvv4c No7xLNEhhdK0MlvSiBe0nPbsI/7ussQkmPYiTUMRc3Nv5pO3qyDwn9XqfbRpiRIC mSPbRPjAM8zSXrlCr5qsfjg1RfJPItRB/+0s3dCbTvC9+UWeWpmYPw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=aeP/UEwctnkBXoSUSc6yPHxrvQk=; b=K7AwBFNpiudJlxY17Aq9 g01ZlueOyyuqdnszKYVxhGzOxSXQnHmggNpxYgzQS51mPGQdvwXU1F4Bj/SQDiWy jK9MSh+a0yjrbAfGtmNW6p32DapiO958erfuxBeYQu5ZCq+nUQhTI6Tcsm0LrEIq 7N2VCejWtgpKj5sryoxGFAA= Received: (qmail 17622 invoked by alias); 28 Apr 2013 03:52:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 17610 invoked by uid 89); 28 Apr 2013 03:52:12 -0000 X-Spam-SWARE-Status: No, score=-6.0 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 28 Apr 2013 03:52:11 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 436C333DEEA; Sun, 28 Apr 2013 03:52:08 +0000 (UTC) From: Mike Frysinger To: gcc-patches@gcc.gnu.org Cc: nickc@redhat.com, richard.earnshaw@arm.com, paul@codesourcery.com, ramana.radhakrishnan@arm.com Subject: [PATCH v2] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking Date: Sat, 27 Apr 2013 23:52:07 -0400 Message-Id: <1367121127-30236-1-git-send-email-vapier@gentoo.org> In-Reply-To: <1366407647-1956-1-git-send-email-vapier@gentoo.org> References: <1366407647-1956-1-git-send-email-vapier@gentoo.org> The bpabi.h header already sets up defines to automatically use the --fix-v4bx flag with the assembler & linker as needed, and creates a default assembly & linker spec which uses those. Unfortunately, the linux-eabi.h header clobbers the LINK_SPEC define and doesn't include the v4bx define when setting up its own. So while the assembler spec is retained and works fine to generate the right relocs, building for armv4 targets doesn't invoke the linker correctly so all the relocs get processed as if we had an armv4t target. You can see this with -dumpspecs when configuring gcc for an armv4 target and using --with-arch=armv4: $ armv4l-unknown-linux-gnueabi-gcc -dumpspecs |& grep -B 1 fix-v4bx *subtarget_extra_asm_spec: .... %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx} ... With this fix in place, we also get the link spec: $ armv4l-unknown-linux-gnueabi-gcc -dumpspecs |& grep -B 1 fix-v4bx *link: ... %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx} ... And all my hello world tests / glibc builds automatically turn the bx insn into the 'mov pc, lr' insn and all is right in the world. Signed-off-by: Mike Frysinger 2013-04-27 Mike Frysinger * config/arm/bpabi.h (EABI_LINK_SPEC): Define. (BPABI_LINK_SPEC): Use new EABI_LINK_SPEC. * config/arm/linux-eabi.h (LINK_SPEC): Replace BE8_LINK_SPEC with EABI_LINK_SPEC. --- v2 - create a dedicated link spec as suggested by Richard gcc/config/arm/bpabi.h | 6 +++++- gcc/config/arm/linux-eabi.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/config/arm/bpabi.h b/gcc/config/arm/bpabi.h index 8e6683b..ff89633 100644 --- a/gcc/config/arm/bpabi.h +++ b/gcc/config/arm/bpabi.h @@ -91,11 +91,15 @@ #define SUBTARGET_EXTRA_LINK_SPEC "" #endif +/* Split out the EABI common values so other targets can use it. */ +#define EABI_LINK_SPEC \ + TARGET_FIX_V4BX_SPEC BE8_LINK_SPEC + /* The generic link spec in elf.h does not support shared libraries. */ #define BPABI_LINK_SPEC \ "%{mbig-endian:-EB} %{mlittle-endian:-EL} " \ "%{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} " \ - "-X" SUBTARGET_EXTRA_LINK_SPEC TARGET_FIX_V4BX_SPEC BE8_LINK_SPEC + "-X" SUBTARGET_EXTRA_LINK_SPEC EABI_LINK_SPEC #undef LINK_SPEC #define LINK_SPEC BPABI_LINK_SPEC diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h index 4a425c8..23671a7 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -80,7 +80,7 @@ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to use the GNU/Linux version, not the generic BPABI version. */ #undef LINK_SPEC -#define LINK_SPEC BE8_LINK_SPEC \ +#define LINK_SPEC EABI_LINK_SPEC \ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)