public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gcc-patches@gcc.gnu.org
Cc: nickc@redhat.com,	richard.earnshaw@arm.com,
	paul@codesourcery.com,	ramana.radhakrishnan@arm.com
Subject: [PATCH] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking
Date: Sat, 20 Apr 2013 10:59:00 -0000	[thread overview]
Message-ID: <1366407647-1956-1-git-send-email-vapier@gentoo.org> (raw)

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 <vapier@gentoo.org>

2013-04-19  Mike Frysinger  <vapier@gentoo.org>

	* config/arm/linux-eabi.h (LINK_SPEC): Add TARGET_FIX_V4BX_SPEC.
---
Note: This issue seems to exist since the code was first introduced.
      At least, I've tested gcc-4.5.x and gcc-4.8.x and they both fail,
      and the code looks the same in gcc-4.[467].x.  That means it's
      not technically a regression, so I guess policy dictates that it
      can't be merged into older branches?

 gcc/config/arm/linux-eabi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
index 4a425c8..8b7ebb2 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 TARGET_FIX_V4BX_SPEC BE8_LINK_SPEC			\
   LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC,				\
 		       LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
 
-- 
1.8.2.1

             reply	other threads:[~2013-04-19 21:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-20 10:59 Mike Frysinger [this message]
2013-04-24 18:02 ` Richard Earnshaw
2013-04-28 15:16 ` [PATCH v2] " Mike Frysinger
2013-04-29 12:20   ` Richard Earnshaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1366407647-1956-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nickc@redhat.com \
    --cc=paul@codesourcery.com \
    --cc=ramana.radhakrishnan@arm.com \
    --cc=richard.earnshaw@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).