mips.h (CRT_CALL_STATIC_FUNCTION): Fix the macro to use la/jalr instead of jal.
authorPetar Jovanovic <petar.jovanovic@rt-rk.com>
Wed, 29 Apr 2015 20:28:52 +0000 (20:28 +0000)
committerCatherine Moore <clm@gcc.gnu.org>
Wed, 29 Apr 2015 20:28:52 +0000 (16:28 -0400)
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.

From-SVN: r222589

gcc/ChangeLog
gcc/config/mips/mips.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/mips/call-from-init.c [new file with mode: 0644]
gcc/testsuite/gcc.target/mips/mips.exp

index 4c95a75b668ecfb63ba98223b321380f4e9396cc..3b363b04f72dd432f351f517f7cbe9ef8d4a41ac 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-29  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.
+
 2015-04-29  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/65871
index ec69ed5d0610e57290d03afc242110ba18ce3716..4bd83f50092cf523616b8c57e5233568fb05ed37 100644 (file)
@@ -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
index 9d428f83aec719bd25a79736a4a450ca900b2441..7aebfecff77151b0c1a15ddd90891b38236e5fd9 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-29  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.
+
 2015-04-29  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/65871
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 (file)
index 0000000..9c6ac00
--- /dev/null
@@ -0,0 +1,12 @@
+/* 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" } */
+/* { dg-options "-mips32r2" } */
+
+int
+main (void) {
+  return 0;
+}
index a0980a90d0507fa742233de2e6bcdf0205f0f728..1dd4173b6d7a339b7251204cc3e6cb7d3d6c5941 100644 (file)
@@ -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 } {