* [PATCH v4][MIPS] fix CRT_CALL_STATIC_FUNCTION macro
@ 2015-04-24 14:51 Petar Jovanovic
2015-04-29 20:50 ` Moore, Catherine
0 siblings, 1 reply; 2+ messages in thread
From: Petar Jovanovic @ 2015-04-24 14:51 UTC (permalink / raw)
To: gcc-patches, 'Maciej W. Rozycki',
Matthew.Fortune, Catherine_Moore
New patch, v4. PTAL.
(resending the patch in plan text format, sorry for the multiple emails, I
am going to switch back to git-send-email)
Regards,
Petar
gcc/ChangeLog:
2015-04-21 Petar Jovanovic <petar.jovanovic@rt-rk.com>
* config/mips/mips.h (CRT_CALL_STATIC_FUNCTION): Fix the macro to
use
la/jalr instead of jal.
gcc/testsuite/ChangeLog:
2015-04-21 Petar Jovanovic <petar.jovanovic@rt-rk.com>
* gcc.target/mips/call-from-init.c: New test.
* gcc.target/mips/mips.exp: Add section_start to mips_option_groups.
commit 1c54988c43bdc653a730b97ea7a774a83f944e56
Author: Petar Jovanovic <petar.jovanovic@rt-rk.com>
Date: Thu Jan 22 02:15:22 2015 +0100
[mips] fix CRT_CALL_STATIC_FUNCTION macro
jal can not reach a target in different region, so replace it with
la/jalr variant.
New test has been added. It uses -Wl,--section-start=.init= and
-Wl,--section-start=.text= to put the two sections in different 256-MB
regions, so the test fails (on Linux) if the change is not applied.
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index ec69ed5..4bd83f5 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -3034,11 +3034,11 @@ while (0)
nop\n\
1: .cpload $31\n\
.set reorder\n\
- jal " USER_LABEL_PREFIX #FUNC "\n\
+ la $25, " USER_LABEL_PREFIX #FUNC "\n\
+ jalr $25\n\
.set pop\n\
" TEXT_SECTION_ASM_OP);
-#elif ((defined _ABIN32 && _MIPS_SIM == _ABIN32) \
- || (defined _ABI64 && _MIPS_SIM == _ABI64))
+#elif (defined _ABIN32 && _MIPS_SIM == _ABIN32)
#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
asm (SECTION_OP "\n\
.set push\n\
@@ -3048,7 +3048,22 @@ while (0)
nop\n\
1: .set reorder\n\
.cpsetup $31, $2, 1b\n\
- jal " USER_LABEL_PREFIX #FUNC "\n\
+ la $25, " USER_LABEL_PREFIX #FUNC "\n\
+ jalr $25\n\
+ .set pop\n\
+ " TEXT_SECTION_ASM_OP);
+#elif (defined _ABI64 && _MIPS_SIM == _ABI64)
+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
+ asm (SECTION_OP "\n\
+ .set push\n\
+ .set nomips16\n\
+ .set noreorder\n\
+ bal 1f\n\
+ nop\n\
+1: .set reorder\n\
+ .cpsetup $31, $2, 1b\n\
+ dla $25, " USER_LABEL_PREFIX #FUNC "\n\
+ jalr $25\n\
.set pop\n\
" TEXT_SECTION_ASM_OP);
#endif
diff --git a/gcc/testsuite/gcc.target/mips/call-from-init.c
b/gcc/testsuite/gcc.target/mips/call-from-init.c
new file mode 100644
index 0000000..4fe5acf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/call-from-init.c
@@ -0,0 +1,11 @@
+/* Check that __do_global_ctors_aux can be reached from .init section that
+ is in a different (256MB) region. */
+/* { dg-do run { target { "mips*-*-linux*" } } } */
+/* { dg-skip-if "" { "mips*-sde-elf mips*-mti-elf mips*-img-elf" } } */
+/* { dg-options "-Wl,--section-start=.init=0x0FFF0000" } */
+/* { dg-options "-Wl,--section-start=.text=0x10000000" } */
+
+int
+main (void) {
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/mips/mips.exp
b/gcc/testsuite/gcc.target/mips/mips.exp
index a0980a9..1dd4173 100644
--- a/gcc/testsuite/gcc.target/mips/mips.exp
+++ b/gcc/testsuite/gcc.target/mips/mips.exp
@@ -254,6 +254,7 @@ set mips_option_groups {
madd "HAS_MADD"
maddps "HAS_MADDPS"
lsa "(|!)HAS_LSA"
+ section_start "-Wl,--section-start=.*"
}
for { set option 0 } { $option < 32 } { incr option } {
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH v4][MIPS] fix CRT_CALL_STATIC_FUNCTION macro
2015-04-24 14:51 [PATCH v4][MIPS] fix CRT_CALL_STATIC_FUNCTION macro Petar Jovanovic
@ 2015-04-29 20:50 ` Moore, Catherine
0 siblings, 0 replies; 2+ messages in thread
From: Moore, Catherine @ 2015-04-29 20:50 UTC (permalink / raw)
To: Petar Jovanovic, gcc-patches, 'Maciej W. Rozycki',
Matthew.Fortune
Cc: Moore, Catherine
> -----Original Message-----
> From: Petar Jovanovic [mailto:petar.jovanovic@rt-rk.com]
> Sent: Friday, April 24, 2015 10:51 AM
> Subject: [PATCH v4][MIPS] fix CRT_CALL_STATIC_FUNCTION macro
>
> gcc/ChangeLog:
>
> 2015-04-21 Petar Jovanovic <petar.jovanovic@rt-rk.com>
>
> * config/mips/mips.h (CRT_CALL_STATIC_FUNCTION): Fix the macro
> to use
> la/jalr instead of jal.
>
> gcc/testsuite/ChangeLog:
>
> 2015-04-21 Petar Jovanovic <petar.jovanovic@rt-rk.com>
>
> * gcc.target/mips/call-from-init.c: New test.
> * gcc.target/mips/mips.exp: Add section_start to
Thank you, Petar. I have now committed this patch.
Catherine
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-29 20:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-24 14:51 [PATCH v4][MIPS] fix CRT_CALL_STATIC_FUNCTION macro Petar Jovanovic
2015-04-29 20:50 ` Moore, Catherine
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).