aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2003-01-15 07:42:21 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2003-01-15 07:42:21 +0000
commit3c0121e4ebbef242d704631435f009c695202eb1 (patch)
tree48f065a1fa990b46bdfa5f3b3e157f4e93046073
parent553eb139b1b989269a513ea578c8888374554e69 (diff)
downloadgcc-3c0121e4ebbef242d704631435f009c695202eb1.zip
gcc-3c0121e4ebbef242d704631435f009c695202eb1.tar.gz
gcc-3c0121e4ebbef242d704631435f009c695202eb1.tar.bz2
mips.h (CRT_CALL_STATIC_FUNCTION): Define so as to set $gp before the call.
* config/mips/mips.h (CRT_CALL_STATIC_FUNCTION): Define so as to set $gp before the call. From-SVN: r61310
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/mips/mips.h28
2 files changed, 33 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 62db009..dba42fb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2003-01-15 Alexandre Oliva <aoliva@redhat.com>
+
+ * config/mips/mips.h (CRT_CALL_STATIC_FUNCTION): Define so as
+ to set $gp before the call.
+
2003-01-14 Richard Henderson <rth@redhat.com>
* config/alpha/alpha.c (alpha_expand_mov): Use correct mode
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 864be70..3e19180 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -4674,3 +4674,31 @@ while (0)
/* Generate calls to memcpy, etc., not bcopy, etc. */
#define TARGET_MEM_FUNCTIONS
+
+/* Since the bits of the _init and _fini function is spread across
+ many object files, each potentially with its own GP, we must assume
+ we need to load our GP. We don't preserve $gp or $ra, since each
+ init/fini chunk is supposed to initialize $gp, and crti/crtn
+ already take care of preserving $ra and, when appropriate, $gp. */
+#if _MIPS_SIM == _MIPS_SIM_ABI32
+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
+ asm (SECTION_OP "\n\
+ .set noreorder\n\
+ bal 1f\n\
+ nop\n\
+1: .cpload $31\n\
+ .set reorder\n\
+ jal " USER_LABEL_PREFIX #FUNC "\n\
+ " TEXT_SECTION_ASM_OP);
+#elif (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
+ || (defined _ABI64 && _MIPS_SIM == _ABI64)
+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
+ asm (SECTION_OP "\n\
+ .set noreorder\n\
+ bal 1f\n\
+ nop\n\
+1: .set reorder\n\
+ .cpsetup $31, $2, 1b\n\
+ jal " USER_LABEL_PREFIX #FUNC "\n\
+ " TEXT_SECTION_ASM_OP);
+#endif