[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
IA64: Incomplete unwind description for strncpy, strcat, _mcount
From: |
Patil, Harish |
Subject: |
IA64: Incomplete unwind description for strncpy, strcat, _mcount |
Date: |
Wed, 13 Nov 2002 11:39:15 -0800 |
>Submitter-Id: net
>Originator:
>Organization: Intel
>Confidential: no
>Synopsis: Incomplete unwind description for strncpy, strcat, _mcount
>Severity: non-critical
>Priority: medium
>Category: libc
>Class: sw-bug
>Release: libc-2.2.4
>Environment:
Host type: ia64-unknown-linux-gnu
System: Linux shli0002 2.4.18 #1 SMP Fri May 31 13:56:22 EDT 2002 ia64
unknown
Architecture: ia64
Addons: linuxthreads
Build CFLAGS: -O2 -g
Build CC: gcc32
Compiler version: 3.2
Kernel headers: 2.4.9-18
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
Stdio: libio
>Description:
The test program uses strncpy and strcat.
Looking at the output of "readelf -u" on the test program the unwind
info for strncpy says:
R2:prologue_gr(mask=[rp,ar.pfs],grsave=r35,rlen=5)
This is a shorthand for telling that rp is saved in r35 and ar.pfs
is saved in r36. This is incomplete because it tells 'where' rp and pfs
are saved but does not tell 'when' they are saved i.e. a P7:pfs_when and
P7:rp_when are missing in the unwind info.
Function strcat has the same problem as shown in the test case. Looking
at glibc source function _mcount has the same problem.
>How-To-Repeat:
BEGIN strtest.c
#include <stdio.h>
void do_strncpy()
{
char a[4] = "hia";
char b[4] = "hib";
strncpy(a,b,3);
}
void do_strcat()
{
char a[4] = "hia";
char b[5] = "";
strcat(a,b);
}
main()
{
do_strncpy();
do_strcat();
printf("Done\n");
}
END strtest.c
gcc -static strtest.c -o strtest
readelf -u strtest > strtest.unw
vi strtest.unw
>Fix:
Looking at: sysdeps/ia64/strncpy.S
ENTRY(strncpy)
.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(3)
alloc saved_pfs = ar.pfs, 3, 6, 3, 0
mov saved_b0 = b0
We see that pfs is saved in t==0 and rp is saved in t==1.
Problem: the assembly directive ".prologue mask, reg" has no way to
specify the 'time' where save actually occurs.
Possible fix: Use the more verbose ".save" directive so the assembly
would look like:
.prologue
.save pfs, saved_pfs
alloc saved_pfs = ar.pfs, 3, 6, 3, 0
.save rp, saved_b0
mov saved_b0 = b0
The result will be a slightly expanded unwind info: so instead of the
compact R2:prologue_gr(mask=[rp,ar.pfs],grsave=r35,rlen=5) the assembler
will generate two records P3:rp_gr(reg=35) and P3:pfs_gr(reg=36) but it
will also correctly generate the currently missing P7:pfs_when(t=0) and
P7:rp_when(t=1).
strcat.S and _mcount.S also use
.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(3)
hence have the same problem/fix.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- IA64: Incomplete unwind description for strncpy, strcat, _mcount,
Patil, Harish <=