Module Name:    src
Committed By:   matt
Date:           Tue Jun 25 16:51:14 UTC 2013

Modified Files:
        src/lib/csu/arch/mips: crtbegin.h

Log Message:
Deal with O32 callling sequences.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/mips/crtbegin.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/csu/arch/mips/crtbegin.h
diff -u src/lib/csu/arch/mips/crtbegin.h:1.1 src/lib/csu/arch/mips/crtbegin.h:1.2
--- src/lib/csu/arch/mips/crtbegin.h:1.1	Sat Jun 22 02:37:09 2013
+++ src/lib/csu/arch/mips/crtbegin.h	Tue Jun 25 16:51:14 2013
@@ -28,10 +28,41 @@
  */
 
 __asm(	"\n\t"
-	".pushsection .init, \"ax\", @progbits" "\n\t"
-	"jal	__do_global_ctors_aux"		"\n\t"
+	".pushsection .init, \"ax\", @progbits"			"\n\t"
+#ifdef __mips_o32
+	".set noreorder"					"\n\t"
+	".set nomacro"						"\n\t"
+	"lw	$28,16($sp)" 					"\n\t"
+	"nop"							"\n\t"
+	"lw	$25,%got(__do_global_ctors_aux)($28)"		"\n\t"
+	"nop"							"\n\t"
+	"addiu   $25,$25,%lo(__do_global_ctors_aux)"		"\n\t"
+	".reloc	1f,R_MIPS_JALR,__do_global_ctors_aux"		"\n\t"
+	"1:	jalr	$25"					"\n\t"
+        "nop"							"\n\t"
+	".set macro"						"\n\t"
+	".set reorder"						"\n\t"
+#else
+	"jal	__do_global_ctors_aux"				"\n\t"
+#endif
 	".popsection");
+
 __asm(	"\n\t"
 	".pushsection .fini, \"ax\", @progbits" "\n\t"
-	"jal	__do_global_dtors_aux"		"\n\t"
+#ifdef __mips_o32
+	".set noreorder"					"\n\t"
+	".set nomacro"						"\n\t"
+	"lw	$28,16($sp)" 					"\n\t"
+	"nop"							"\n\t"
+	"lw	$25,%got(__do_global_dtors_aux)($28)"		"\n\t"
+	"nop"							"\n\t"
+	"addiu   $25,$25,%lo(__do_global_dtors_aux)"		"\n\t"
+	".reloc	1f,R_MIPS_JALR,__do_global_dtors_aux"		"\n\t"
+	"1:	jalr	$25"					"\n\t"
+        "nop"							"\n\t"
+	".set macro"						"\n\t"
+	".set reorder"						"\n\t"
+#else
+	"jal	__do_global_dtors_aux"				"\n\t"
+#endif
 	".popsection");

Reply via email to