public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking
@ 2013-04-20 10:59 Mike Frysinger
  2013-04-24 18:02 ` Richard Earnshaw
  2013-04-28 15:16 ` [PATCH v2] " Mike Frysinger
  0 siblings, 2 replies; 4+ messages in thread
From: Mike Frysinger @ 2013-04-20 10:59 UTC (permalink / raw)
  To: gcc-patches; +Cc: nickc, richard.earnshaw, paul, ramana.radhakrishnan

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking
  2013-04-20 10:59 [PATCH] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking Mike Frysinger
@ 2013-04-24 18:02 ` Richard Earnshaw
  2013-04-28 15:16 ` [PATCH v2] " Mike Frysinger
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Earnshaw @ 2013-04-24 18:02 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gcc-patches, nickc, paul, Ramana Radhakrishnan

On 19/04/13 22:40, Mike Frysinger wrote:
> 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)
>
>


Mike,

Thanks for the patch.  The concept is right, but I think we need a 
better approach to avoid problems like this cropping up again.

What I'd like to see is BPABI_LINK_SPEC in bpabi.h split into 
EABI_LINK_SPEC (and containing TARGET_FIX_V4BX_SPEC & BE8_LINK_SPEC) and 
then all EABI-based targets using EABI_LINK_SPEC as part of their rule set.

R.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking
  2013-04-20 10:59 [PATCH] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking Mike Frysinger
  2013-04-24 18:02 ` Richard Earnshaw
@ 2013-04-28 15:16 ` Mike Frysinger
  2013-04-29 12:20   ` Richard Earnshaw
  1 sibling, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2013-04-28 15:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: nickc, richard.earnshaw, paul, ramana.radhakrishnan

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

	* 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)
 
-- 
1.8.2.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking
  2013-04-28 15:16 ` [PATCH v2] " Mike Frysinger
@ 2013-04-29 12:20   ` Richard Earnshaw
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Earnshaw @ 2013-04-29 12:20 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gcc-patches, nickc, paul, Ramana Radhakrishnan

On 28/04/13 04:52, Mike Frysinger wrote:
> 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-27  Mike Frysinger  <vapier@gentoo.org>
>
> 	* 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.

OK.

R.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-29 10:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-20 10:59 [PATCH] gcc: arm: linux-eabi: fix handling of armv4 bx fixups when linking Mike Frysinger
2013-04-24 18:02 ` Richard Earnshaw
2013-04-28 15:16 ` [PATCH v2] " Mike Frysinger
2013-04-29 12:20   ` Richard Earnshaw

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).