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]

[chris@mips.com: glibc clone for linux-mips]


----- Forwarded message from Chris Dearman <chris at mips dot com> -----

Delivered-To: hjl at localhost dot lucon dot org
Date: Tue, 11 Mar 2003 20:45:11 +0000
From: Chris Dearman <chris at mips dot com>
Organization: MIPS Technologies (UK) Ltd
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
X-Accept-Language: en-us, en
To: "H. J. Lu" <hjl at lucon dot org>
Cc: Ralf Baechle <ralf at linux-mips dot org>
Subject: glibc clone for linux-mips
X-MTUK-Scanner: Found to be clean
X-MTUK-SpamCheck: not spam, SpamAssassin (score=-1, required 4.5, AWL,
	NOSPAM_INC, SIGNATURE_SHORT_DENSE, SPAM_PHRASE_00_01, USER_AGENT,
	USER_AGENT_MOZILLA_UA, X_ACCEPT_LANG)


Hi,
   I've come across a problem in the glibc clone code.  If the clone'd 
function returns instead of calling exit, the gp register is not 
restored correctly (from glibc-2.2.5-42.1.mips.rpm on ftp.linux-mips.org)

000000000010e080 <__clone>:
   10e080:       3c1c000b        lui     $gp,0xb
   10e084:       279c3e00        addiu   $gp,$gp,15872
   10e088:       0399e021        addu    $gp,$gp,$t9
   10e08c:       27bdffe0        addiu   $sp,$sp,-32
   10e090:       afbc0010        sw      $gp,16($sp)
   10e094:       10800010        beqz    $a0,10e0d8 <error>
   10e098:       24020016        li      $v0,22
   10e09c:       10a0000e        beqz    $a1,10e0d8 <error>
   10e0a0:       00000000        nop
   10e0a4:       24a5ffe0        addiu   $a1,$a1,-32
   10e0a8:       aca40000        sw      $a0,0($a1)
   10e0ac:       aca70004        sw      $a3,4($a1)
   10e0b0:       00c02021        move    $a0,$a2
   10e0b4:       24021018        li      $v0,4120
   10e0b8:       0000000c        syscall
   10e0bc:       14e00006        bnez    $a3,10e0d8 <error>
   10e0c0:       00000000        nop
   10e0c4:       10400009        beqz    $v0,10e0ec <__thread_start>
   10e0c8:       00000000        nop
   10e0cc:       03e00008        jr      $ra
   10e0d0:       27bd0020        addiu   $sp,$sp,32
   10e0d4:       00000000        nop

000000000010e0d8 <error>:
   10e0d8:       27bd0020        addiu   $sp,$sp,32
   10e0dc:       8f9981b8        lw      $t9,-32328($gp)
   10e0e0:       00000000        nop
   10e0e4:       03200008        jr      $t9
   10e0e8:       00000000        nop

000000000010e0ec <__thread_start>:
   10e0ec:       afbc0010        sw      $gp,16($sp)
   10e0f0:       8fb90000        lw      $t9,0($sp)
   10e0f4:       8fa40004        lw      $a0,4($sp)
   10e0f8:       0320f809        jalr    $t9
   10e0fc:       00000000        nop
   10e100:       00402021        move    $a0,$v0
## gp has not been restored so the following lw is done from
## the wrong GOT
   10e104:       8f999294        lw      $t9,-28012($gp)
   10e108:       00000000        nop
   10e10c:       0320f809        jalr    $t9
   10e110:       00000000        nop


   The __thread_start code uses jalr to call the user function which gas 
does not expand into a jal/gp reload (from 
glibc/sysdeps/unix/sysv/linux/mips/clone.S):

ENTRY(__thread_start)
	/* cp is already loaded.  */
	.cprestore	16
	/* The stackframe has been created on entry of clone().  */
	/* Restore the arg for user's function.  */
	lw		t9,0(sp)	/* Function pointer.  */
	lw		a0,4(sp)	/* Argument pointer.  */

	/* Call the user's function.  */
	jal		t9

	/* Call _exit rather than doing it inline for breakpoint purposes.  */
	move		a0,v0

   Changing this to "jal t9" makes gas DTRT.

	Regards
		Chris

	
-- 
                          Chris Dearman          mailto:chris at mips dot com
     _    _ ____  ___     MIPS Technologies (UK) Phone:  +44 1223 706200
     |\  /|||___)(___     The Fruit Farm         Direct: +44 1223 706206
     | \/ |||    ____)    Ely Road, Chittering   Fax:    +44 1223 706250
     TECHNOLOGIES (UK)    Cambridge CB5 9PH      Cell:   +44 7986 889625
                          England                http://www.mips.com


----- End forwarded message -----


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