Subject: port-mips/5248: user profiling is broken on mips
To: None <gnats-bugs@gnats.netbsd.org>
From: Noriyuki Shiota <shiota@pdd.ssd.ricoh.co.jp>
List: netbsd-bugs
Date: 04/03/1998 13:19:44
>Number: 5248
>Category: port-mips
>Synopsis: user profiling is broken on mips
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Apr 2 20:35:00 1998
>Last-Modified:
>Originator: Noriyuki Shiota
>Organization:
Ricoh Co., Ltd.
>Release: NetBSD-1.3
>Environment:
original port based on NetBSD-1.3-pmax
>Description:
Profiled object dumps core.
>How-To-Repeat:
Excute object compiled with -pg and linked with gcrt0.o.
>Fix:
On profiling, gcc inserts the following code at the beginning of procedure:
move $at, $ra
jal _mcount
subu $sp, $sp, 8
"subu" instruction is placed on the delayed slot of "jal".
But gas produces the following for "jal _mcount" on .abicalls case:
lw $t9, -32680($gp) ; _mcount
nop
jalr $t9
nop
lw $gp,16($sp)
nop
In this case, "jalr" and "subu" are not excuted in intended order.
*** gnu/usr.bin/gcc/arch/mips/mips.h 1998/02/20 13:15:16 1.1
--- gnu/usr.bin/gcc/arch/mips/mips.h 1998/02/20 13:15:35
***************
*** 2070,2082 ****
fprintf (FILE, "\t.set\tnoat\n"); \
fprintf (FILE, "\tmove\t%s,%s\t\t# save current return address\n", \
reg_names[GP_REG_FIRST + 1], reg_names[GP_REG_FIRST + 31]); \
- fprintf (FILE, "\tjal\t_mcount\n"); \
fprintf (FILE, \
"\t%s\t%s,%s,%d\t\t# _mcount pops 2 words from stack\n", \
TARGET_64BIT ? "dsubu" : "subu", \
reg_names[STACK_POINTER_REGNUM], \
reg_names[STACK_POINTER_REGNUM], \
TARGET_LONG64 ? 16 : 8); \
fprintf (FILE, "\t.set\treorder\n"); \
fprintf (FILE, "\t.set\tat\n"); \
}
--- 2070,2083 ----
fprintf (FILE, "\t.set\tnoat\n"); \
fprintf (FILE, "\tmove\t%s,%s\t\t# save current return address\n", \
reg_names[GP_REG_FIRST + 1], reg_names[GP_REG_FIRST + 31]); \
fprintf (FILE, \
"\t%s\t%s,%s,%d\t\t# _mcount pops 2 words from stack\n", \
TARGET_64BIT ? "dsubu" : "subu", \
reg_names[STACK_POINTER_REGNUM], \
reg_names[STACK_POINTER_REGNUM], \
TARGET_LONG64 ? 16 : 8); \
+ fprintf (FILE, "\tjal\t_mcount\n"); \
+ fprintf (FILE, "\tnop\n"); \
fprintf (FILE, "\t.set\treorder\n"); \
fprintf (FILE, "\t.set\tat\n"); \
}
>Audit-Trail:
>Unformatted: