public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Petar Jovanovic" <petar.jovanovic@rt-rk.com>
To: <gcc-patches@gcc.gnu.org>,	<Catherine_Moore@mentor.com>,
	<macro@linux-mips.org>,	<Matthew.Fortune@imgtec.com>
Subject: [PATCH v3][MIPS] fix CRT_CALL_STATIC_FUNCTION macro
Date: Tue, 21 Apr 2015 17:42:00 -0000	[thread overview]
Message-ID: <005001d07c5a$8c9e9b90$a5dbd2b0$@rt-rk.com> (raw)

New patch, v3. PTAL.

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 566564bd6d80fd6b5ebd6b8eccf09e3716246930
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.

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..ee00a17
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/call-from-init.c
@@ -0,0 +1,10 @@
+/* Check that __do_global_ctors_aux can be reached from .init section that
+   is in a different (256MB) region. */
+/* { dg-do run } */
+/* { dg-options "-Wl,--section-start=.init=0x0FF00000" } */
+/* { 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 } {

             reply	other threads:[~2015-04-21 17:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 17:42 Petar Jovanovic [this message]
2015-04-21 18:52 ` Maciej W. Rozycki
2015-04-22 15:42   ` Petar Jovanovic
2015-04-23 14:55     ` Maciej W. Rozycki
2015-04-24 15:13       ` Petar Jovanovic

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='005001d07c5a$8c9e9b90$a5dbd2b0$@rt-rk.com' \
    --to=petar.jovanovic@rt-rk.com \
    --cc=Catherine_Moore@mentor.com \
    --cc=Matthew.Fortune@imgtec.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=macro@linux-mips.org \
    /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).