Article View: gnu.gcc.bug
Article #6102possible gcc 2.7.2 bug on sparc/solaris 2.5.1
From: Andrew J. Schorr
Date: Wed, 27 Nov 1996 00:00
Date: Wed, 27 Nov 1996 00:00
576 lines
12103 bytes
12103 bytes
I am having a problem with gcc version 2.7.2 on a Sun SPARCstation 20.
uname -a:
SunOS ead32 5.5.1 Generic_103640-03 sun4m sparc sun4m
gcc -v:
Reading specs from /extras/local/gnu/gcc-2.7.2/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2/specs
gcc version 2.7.2
I built a shared library that caused a program to get a SEGV, and, upon
further investigation, I found that one of the functions in the library
would work fine when compiled with -fpic, but would cause a core
dump when compiled with -O -fpic.
So, there is a problem when gcc is invoked this way:
gcc -msupersparc -O -fpic
But everything works OK when -O is not supplied, or if -fpic is not used.
In fact, it turns out that when -O is not used,
the assembler produced is essentially identical with and without -fpic:
schorr@ead32: diff sparc/bug.nopic.s sparc/bug.pic.s
11d10
< !#PROLOGUE# 1
But, when -O is added, there is a difference in the result:
schorr@ead32: diff sparc/bug.nopic.O.s sparc/bug.pic.O.s
16d15
< !#PROLOGUE# 1
38,39c37,38
< sethi %hi(.LLC0),%o2
< ldd [%o2+%lo(.LLC0)],%f2
---
> ld [%l7+.LLC0],%o2
> ldd [%o2],%f2
I do not understand SPARC assembly language, but this difference ends up
causing my program to dump core with a segmentation violation.
Here is the source code of the problematic function (and yes, I know it is
a really stupid function, but the person who wrote it no longer works
here; and yes, when I rewrite the function in a more intelligent fashion,
the problem does go away):
extern double ceil (double);
extern double floor (double);
typedef enum {
DGPlotterMMTPMIN,
DGPlotterMMTPMAX
} DGPlotterMMTPType;
double
CalDateMMTP(type, min, max, ticFreq, mult)
DGPlotterMMTPType type;
double min;
double max;
double ticFreq;
int mult;
{
if (type == DGPlotterMMTPMIN) {
if (mult == 7) {
ticFreq *= mult;
return ceil(min/ticFreq) * ticFreq; /* day 0 was Sunday */
}
else {
ticFreq *= mult;
return ceil(min/ticFreq) * ticFreq;
}
}
else {
if (mult == 7) {
ticFreq *= mult;
return floor(max/ticFreq) * ticFreq;
}
else {
ticFreq *= mult;
return floor(max/ticFreq) * ticFreq;
}
}
}
I am including below the various assembler files produced by my compiler.
They were produced as follows:
gcc -O -fpic -S bug.c -o bug.pic.O.s
gcc -O -S bug.c -o bug.nopic.O.s
gcc -S bug.c -o bug.nopic.s
gcc -fpic -S bug.c -o bug.pic.s
Thank you for your help,
Andy
=============================
Andrew Schorr, SVP
Daiwa Securities America Inc.
Financial Square
32 Old Slip, 12th Floor
New York, NY 10005-3538
e-mail: schorr@ead.dsa.com
phone: 212-612-6574
fax: 212-612-7115
---- Cut Here and unpack ----
#!/bin/sh
# shar: Shell Archiver (v1.22)
#
# Run the following text with /bin/sh to create:
# bug.nopic.O.s
# bug.nopic.s
# bug.pic.O.s
# bug.pic.s
#
if test -f bug.nopic.O.s; then echo "File bug.nopic.O.s exists"; else
echo "x - extracting bug.nopic.O.s (Text)"
sed 's/^X//' << 'SHAR_EOF' > bug.nopic.O.s &&
X .file "bug.c"
Xgcc2_compiled.:
X.section ".rodata"
X .align 8
X.LLC0:
X .long 0x401c0000
X .long 0x0
X.section ".text"
X .align 4
X .global CalDateMMTP
X .type CalDateMMTP,#function
X .proc 07
XCalDateMMTP:
X !#PROLOGUE# 0
X save %sp,-120,%sp
X !#PROLOGUE# 1
X st %i1,[%fp-16]
X st %i2,[%fp-12]
X ldd [%fp-16],%f8
X fmovs %f8,%f6
X fmovs %f9,%f7
X st %i3,[%fp-16]
X st %i4,[%fp-12]
X ldd [%fp-16],%f8
X fmovs %f8,%f4
X fmovs %f9,%f5
X st %i5,[%fp+88]
X ldd [%fp+88],%f8
X std %f8,[%fp-24]
X cmp %i0,0
X bne .LL2
X ld [%fp+96],%f2
X st %f2,[%fp-16]
X ld [%fp-16],%o2
X cmp %o2,7
X bne,a .LL3
X fitod %f2,%f2
X sethi %hi(.LLC0),%o2
X ldd [%o2+%lo(.LLC0)],%f2
X fmuld %f8,%f2,%f8
X std %f8,[%fp-24]
X fdivd %f6,%f8,%f8
X std %f8,[%fp-16]
X call ceil,0
X ldd [%fp-16],%o0
X b .LL10
X ldd [%fp-24],%f8
X.LL3:
X ldd [%fp-24],%f8
X fmuld %f8,%f2,%f8
X std %f8,[%fp-24]
X fdivd %f6,%f8,%f8
X std %f8,[%fp-16]
X call ceil,0
X ldd [%fp-16],%o0
X b .LL10
X ldd [%fp-24],%f8
X.LL2:
X st %f2,[%fp-16]
X ld [%fp-16],%o2
X fitod %f2,%f2
X ldd [%fp-24],%f8
X fmuld %f8,%f2,%f8
X std %f8,[%fp-24]
X fdivd %f4,%f8,%f8
X std %f8,[%fp-16]
X call floor,0
X ldd [%fp-16],%o0
X ldd [%fp-24],%f8
X.LL10:
X fmuld %f0,%f8,%f0
X ret
X restore
X.LLfe1:
X .size CalDateMMTP,.LLfe1-CalDateMMTP
X .ident "GCC: (GNU) 2.7.2"
SHAR_EOF
chmod 0644 bug.nopic.O.s || echo "restore of bug.nopic.O.s fails"
set `wc -c bug.nopic.O.s`;Sum=$1
if test "$Sum" != "1220"
then echo original size 1220, current size $Sum;fi
fi
if test -f bug.nopic.s; then echo "File bug.nopic.s exists"; else
echo "x - extracting bug.nopic.s (Text)"
sed 's/^X//' << 'SHAR_EOF' > bug.nopic.s &&
X .file "bug.c"
Xgcc2_compiled.:
X.section ".text"
X .align 4
X .global CalDateMMTP
X .type CalDateMMTP,#function
X .proc 07
XCalDateMMTP:
X !#PROLOGUE# 0
X save %sp,-136,%sp
X !#PROLOGUE# 1
X st %i0,[%fp+68]
X st %i1,[%fp-24]
X st %i2,[%fp-20]
X st %i3,[%fp-32]
X st %i4,[%fp-28]
X st %i5,[%fp+88]
X ldd [%fp+88],%l0
X std %l0,[%fp-40]
X ld [%fp+68],%o0
X cmp %o0,0
X bne .LL2
X nop
X ld [%fp+96],%o0
X cmp %o0,7
X bne .LL3
X nop
X ld [%fp+96],%f4
X fitod %f4,%f2
X ldd [%fp-40],%f4
X fmuld %f4,%f2,%f2
X std %f2,[%fp-40]
X ldd [%fp-24],%f2
X ldd [%fp-40],%f4
X fdivd %f2,%f4,%f6
X std %f6,[%fp-16]
X ldd [%fp-16],%o2
X mov %o2,%o0
X mov %o3,%o1
X call ceil,0
X nop
X fmovs %f0,%f2
X fmovs %f1,%f3
X ldd [%fp-40],%f4
X fmuld %f2,%f4,%f2
X fmovs %f2,%f0
X fmovs %f3,%f1
X b .LL1
X nop
X b .LL4
X nop
X.LL3:
X ld [%fp+96],%f4
X fitod %f4,%f2
X ldd [%fp-40],%f4
X fmuld %f4,%f2,%f2
X std %f2,[%fp-40]
X ldd [%fp-24],%f2
X ldd [%fp-40],%f4
X fdivd %f2,%f4,%f6
X std %f6,[%fp-16]
X ldd [%fp-16],%o2
X mov %o2,%o0
X mov %o3,%o1
X call ceil,0
X nop
X fmovs %f0,%f2
X fmovs %f1,%f3
X ldd [%fp-40],%f4
X fmuld %f2,%f4,%f2
X fmovs %f2,%f0
X fmovs %f3,%f1
X b .LL1
X nop
X.LL4:
X b .LL5
X nop
X.LL2:
X ld [%fp+96],%o0
X cmp %o0,7
X bne .LL6
X nop
X ld [%fp+96],%f4
X fitod %f4,%f2
X ldd [%fp-40],%f4
X fmuld %f4,%f2,%f2
X std %f2,[%fp-40]
X ldd [%fp-32],%f2
X ldd [%fp-40],%f4
X fdivd %f2,%f4,%f6
X std %f6,[%fp-16]
X ldd [%fp-16],%o2
X mov %o2,%o0
X mov %o3,%o1
X call floor,0
X nop
X fmovs %f0,%f2
X fmovs %f1,%f3
X ldd [%fp-40],%f4
X fmuld %f2,%f4,%f2
X fmovs %f2,%f0
X fmovs %f3,%f1
X b .LL1
X nop
X b .LL7
X nop
X.LL6:
X ld [%fp+96],%f4
X fitod %f4,%f2
X ldd [%fp-40],%f4
X fmuld %f4,%f2,%f2
X std %f2,[%fp-40]
X ldd [%fp-32],%f2
X ldd [%fp-40],%f4
X fdivd %f2,%f4,%f6
X std %f6,[%fp-16]
X ldd [%fp-16],%o2
X mov %o2,%o0
X mov %o3,%o1
X call floor,0
X nop
X fmovs %f0,%f2
X fmovs %f1,%f3
X ldd [%fp-40],%f4
X fmuld %f2,%f4,%f2
X fmovs %f2,%f0
X fmovs %f3,%f1
X b .LL1
X nop
X.LL7:
X.LL5:
X.LL1:
X ret
X restore
X.LLfe1:
X .size CalDateMMTP,.LLfe1-CalDateMMTP
X .ident "GCC: (GNU) 2.7.2"
SHAR_EOF
chmod 0644 bug.nopic.s || echo "restore of bug.nopic.s fails"
set `wc -c bug.nopic.s`;Sum=$1
if test "$Sum" != "1947"
then echo original size 1947, current size $Sum;fi
fi
if test -f bug.pic.O.s; then echo "File bug.pic.O.s exists"; else
echo "x - extracting bug.pic.O.s (Text)"
sed 's/^X//' << 'SHAR_EOF' > bug.pic.O.s &&
X .file "bug.c"
Xgcc2_compiled.:
X.section ".rodata"
X .align 8
X.LLC0:
X .long 0x401c0000
X .long 0x0
X.section ".text"
X .align 4
X .global CalDateMMTP
X .type CalDateMMTP,#function
X .proc 07
XCalDateMMTP:
X !#PROLOGUE# 0
X save %sp,-120,%sp
X st %i1,[%fp-16]
X st %i2,[%fp-12]
X ldd [%fp-16],%f8
X fmovs %f8,%f6
X fmovs %f9,%f7
X st %i3,[%fp-16]
X st %i4,[%fp-12]
X ldd [%fp-16],%f8
X fmovs %f8,%f4
X fmovs %f9,%f5
X st %i5,[%fp+88]
X ldd [%fp+88],%f8
X std %f8,[%fp-24]
X cmp %i0,0
X bne .LL2
X ld [%fp+96],%f2
X st %f2,[%fp-16]
X ld [%fp-16],%o2
X cmp %o2,7
X bne,a .LL3
X fitod %f2,%f2
X ld [%l7+.LLC0],%o2
X ldd [%o2],%f2
X fmuld %f8,%f2,%f8
X std %f8,[%fp-24]
X fdivd %f6,%f8,%f8
X std %f8,[%fp-16]
X call ceil,0
X ldd [%fp-16],%o0
X b .LL10
X ldd [%fp-24],%f8
X.LL3:
X ldd [%fp-24],%f8
X fmuld %f8,%f2,%f8
X std %f8,[%fp-24]
X fdivd %f6,%f8,%f8
X std %f8,[%fp-16]
X call ceil,0
X ldd [%fp-16],%o0
X b .LL10
X ldd [%fp-24],%f8
X.LL2:
X st %f2,[%fp-16]
X ld [%fp-16],%o2
X fitod %f2,%f2
X ldd [%fp-24],%f8
X fmuld %f8,%f2,%f8
X std %f8,[%fp-24]
X fdivd %f4,%f8,%f8
X std %f8,[%fp-16]
X call floor,0
X ldd [%fp-16],%o0
X ldd [%fp-24],%f8
X.LL10:
X fmuld %f0,%f8,%f0
X ret
X restore
X.LLfe1:
X .size CalDateMMTP,.LLfe1-CalDateMMTP
X .ident "GCC: (GNU) 2.7.2"
SHAR_EOF
chmod 0644 bug.pic.O.s || echo "restore of bug.pic.O.s fails"
set `wc -c bug.pic.O.s`;Sum=$1
if test "$Sum" != "1192"
then echo original size 1192, current size $Sum;fi
fi
if test -f bug.pic.s; then echo "File bug.pic.s exists"; else
echo "x - extracting bug.pic.s (Text)"
sed 's/^X//' << 'SHAR_EOF' > bug.pic.s &&
X .file "bug.c"
Xgcc2_compiled.:
X.section ".text"
X .align 4
X .global CalDateMMTP
X .type CalDateMMTP,#function
X .proc 07
XCalDateMMTP:
X !#PROLOGUE# 0
X save %sp,-136,%sp
X st %i0,[%fp+68]
X st %i1,[%fp-24]
X st %i2,[%fp-20]
X st %i3,[%fp-32]
X st %i4,[%fp-28]
X st %i5,[%fp+88]
X ldd [%fp+88],%l0
X std %l0,[%fp-40]
X ld [%fp+68],%o0
X cmp %o0,0
X bne .LL2
X nop
X ld [%fp+96],%o0
X cmp %o0,7
X bne .LL3
X nop
X ld [%fp+96],%f4
X fitod %f4,%f2
X ldd [%fp-40],%f4
X fmuld %f4,%f2,%f2
X std %f2,[%fp-40]
X ldd [%fp-24],%f2
X ldd [%fp-40],%f4
X fdivd %f2,%f4,%f6
X std %f6,[%fp-16]
X ldd [%fp-16],%o2
X mov %o2,%o0
X mov %o3,%o1
X call ceil,0
X nop
X fmovs %f0,%f2
X fmovs %f1,%f3
X ldd [%fp-40],%f4
X fmuld %f2,%f4,%f2
X fmovs %f2,%f0
X fmovs %f3,%f1
X b .LL1
X nop
X b .LL4
X nop
X.LL3:
X ld [%fp+96],%f4
X fitod %f4,%f2
X ldd [%fp-40],%f4
X fmuld %f4,%f2,%f2
X std %f2,[%fp-40]
X ldd [%fp-24],%f2
X ldd [%fp-40],%f4
X fdivd %f2,%f4,%f6
X std %f6,[%fp-16]
X ldd [%fp-16],%o2
X mov %o2,%o0
X mov %o3,%o1
X call ceil,0
X nop
X fmovs %f0,%f2
X fmovs %f1,%f3
X ldd [%fp-40],%f4
X fmuld %f2,%f4,%f2
X fmovs %f2,%f0
X fmovs %f3,%f1
X b .LL1
X nop
X.LL4:
X b .LL5
X nop
X.LL2:
X ld [%fp+96],%o0
X cmp %o0,7
X bne .LL6
X nop
X ld [%fp+96],%f4
X fitod %f4,%f2
X ldd [%fp-40],%f4
X fmuld %f4,%f2,%f2
X std %f2,[%fp-40]
X ldd [%fp-32],%f2
X ldd [%fp-40],%f4
X fdivd %f2,%f4,%f6
X std %f6,[%fp-16]
X ldd [%fp-16],%o2
X mov %o2,%o0
X mov %o3,%o1
X call floor,0
X nop
X fmovs %f0,%f2
X fmovs %f1,%f3
X ldd [%fp-40],%f4
X fmuld %f2,%f4,%f2
X fmovs %f2,%f0
X fmovs %f3,%f1
X b .LL1
X nop
X b .LL7
X nop
X.LL6:
X ld [%fp+96],%f4
X fitod %f4,%f2
X ldd [%fp-40],%f4
X fmuld %f4,%f2,%f2
X std %f2,[%fp-40]
X ldd [%fp-32],%f2
X ldd [%fp-40],%f4
X fdivd %f2,%f4,%f6
X std %f6,[%fp-16]
X ldd [%fp-16],%o2
X mov %o2,%o0
X mov %o3,%o1
X call floor,0
X nop
X fmovs %f0,%f2
X fmovs %f1,%f3
X ldd [%fp-40],%f4
X fmuld %f2,%f4,%f2
X fmovs %f2,%f0
X fmovs %f3,%f1
X b .LL1
X nop
X.LL7:
X.LL5:
X.LL1:
X ret
X restore
X.LLfe1:
X .size CalDateMMTP,.LLfe1-CalDateMMTP
X .ident "GCC: (GNU) 2.7.2"
SHAR_EOF
chmod 0644 bug.pic.s || echo "restore of bug.pic.s fails"
set `wc -c bug.pic.s`;Sum=$1
if test "$Sum" != "1932"
then echo original size 1932, current size $Sum;fi
fi
exit 0
Technical Details
Message-ID:
<199611272102.QAA20166@ead32.ead.dsa.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,38ab452ca69367ba,start X-Google-Attributes: gid113d02,public From: schorr@ead.dsa.com (Andrew J. Schorr) Subject: possible gcc 2.7.2 bug on sparc/solaris 2.5.1 Date: 1996/11/27 Message-ID: <199611272102.QAA20166@ead32.ead.dsa.com> X-Deja-AN: 201118088 sender: bug-gcc-request@prep.ai.mit.edu x-gateway: relay3.UU.NET from bug-gcc to gnu.gcc.bug; Wed, 27 Nov 1996 16:16:35 EST newsgroups: gnu.gcc.bug