This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] fix MIPS n32/64 runtime symbol resolution registersaving


The set of registers being saved/restored during n32/64 runtime symbol
resolution was incomplete.  This would lead to args 6 and 7 to a
dynamically-resolved function being clobbered the first time it was
invoked.

(I'm not quite sure this hasn't been noticed previously.  It looks it
might not be seen depending on compiler and binutils version, and on
the way the compiler generates function calls.  But, in any case, the
existing register save/restore code seems fairly obviously incomplete
since there are 8 arg registers that must not be clobbered by the
symbol resolution code.)

e.g.:

        #include <stdio.h>
        
        main () {
                printf("%d,%d,%d,%d,%d,%d,%d,%d,%d\n",1,2,3,4,5,6,7,8,9);
                printf("%d,%d,%d,%d,%d,%d,%d,%d,%d\n",1,2,3,4,5,6,7,8,9);
        }

Old:

        % $old_ldso ./a.out
        1,2,3,4,5,715819552,0,8,9
        1,2,3,4,5,6,7,8,9

New (with same a.out binary):

        % $new_ldso ./a.out
        1,2,3,4,5,6,7,8,9
        1,2,3,4,5,6,7,8,9


chris
--
2004-05-15  Chris Demetriou  <cgd@broadcom.com>

	* sysdeps/mips/dl-machine.h (ELF_DL_FRAME_SIZE)
	(ELF_DL_SAVE_ARG_REGS, ELF_DL_RESTORE_ARG_REGS): For the N32
	and 64 ABIs, save and restore regs $10 and $11 (a6 and a7).

Index: sysdeps/mips/dl-machine.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mips/dl-machine.h,v
retrieving revision 1.71
diff -u -p -r1.71 dl-machine.h
--- sysdeps/mips/dl-machine.h	15 Apr 2004 14:08:16 -0000	1.71
+++ sysdeps/mips/dl-machine.h	15 May 2004 21:32:40 -0000
@@ -281,26 +281,30 @@ elf_machine_runtime_link_map (ElfW(Addr)
 
 #else /* _MIPS_SIM == _MIPS_SIM_NABI32 || _MIPS_SIM == _MIPS_SIM_ABI64 */
 
-#define ELF_DL_FRAME_SIZE 64
+#define ELF_DL_FRAME_SIZE 80
 
 #define ELF_DL_SAVE_ARG_REGS "\
-	sd	$15, 56($29)\n						      \
+	sd	$15, 72($29)\n						      \
 	sd	$4, 8($29)\n						      \
 	sd	$5, 16($29)\n						      \
 	sd	$6, 24($29)\n						      \
 	sd	$7, 32($29)\n						      \
 	sd	$8, 40($29)\n						      \
 	sd	$9, 48($29)\n						      \
+	sd	$10, 56($29)\n						      \
+	sd	$11, 64($29)\n						      \
 "
 
 #define ELF_DL_RESTORE_ARG_REGS "\
-	ld	$31, 56($29)\n						      \
+	ld	$31, 72($29)\n						      \
 	ld	$4, 8($29)\n						      \
 	ld	$5, 16($29)\n						      \
 	ld	$6, 24($29)\n						      \
 	ld	$7, 32($29)\n						      \
 	ld	$8, 40($29)\n						      \
 	ld	$9, 48($29)\n						      \
+	ld	$10, 56($29)\n						      \
+	ld	$11, 64($29)\n						      \
 "
 
 #define IFABIO32(X)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]