Question re: -fPIC and -O1 on sparc

Brad Lucier lucier@math.purdue.edu
Fri Jun 11 11:56:00 GMT 1999


Is it planned that the -fPIC and -O1 options will work together in the
next release of egcs for the sparc?  The current prerelease still bombs
on the following example:

This file:

#include <stdio.h>

void test(double x, double *y) {
  printf("%f %f\n", x, *y);
  return;
}
 
void call_test(double x) {
  double y = x;
  test(0.5*y, &y);
  test(0.5*y, &y);
}
 
int main() {
  call_test(1.0);
  return 0;
}

compiled with these options:

polya-134% gcc -O1 -fPIC -o test-egcs test-egcs.c

with this compiler:

polya-135% gcc -v
Reading specs from /opt/egcs-19990602/lib/gcc-lib/sparc-sun-solaris2.5.1/gcc-2.95/specs
gcc version gcc-2.95 19990602 (prerelease)

generates a segmentation fault when run.

The assembly language output follows.

Brad Lucier   lucier@math.purdue.edu

	.file	"test-egcs.c"
gcc2_compiled.:
.section	".rodata"
	.align 8
.LLC0:
	.asciz	"%f %f\n"
.section	".text"
	.align 4
.LLGETPC0:
	retl
	add %o7,%l7,%l7
	.align 4
	.global test
	.type	 test,#function
	.proc	020
test:
	!#PROLOGUE# 0
	save	%sp, -112, %sp
	sethi	%hi(_GLOBAL_OFFSET_TABLE_-4), %l7
	call	.LLGETPC0
	add	%l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
	sethi	%hi(.LLC0), %o0
	or	%o0, %lo(.LLC0), %o0
	ld	[%l7+%o0], %o0
	mov	%i0, %o1
	mov	%i1, %o2
	ld	[%i2], %o3
	call	printf, 0
	ld	[%i2+4], %o4
	ret
	restore
.LLfe1:
	.size	 test,.LLfe1-test
.section	".rodata"
	.align 8
.LLC1:
	.uaword	0x3fe00000 ! ~5.00000000000000000000e-1
	.uaword	0x0
.section	".text"
	.align 4
	.global call_test
	.type	 call_test,#function
	.proc	020
call_test:
	!#PROLOGUE# 0
	save	%sp, -120, %sp
	sethi	%hi(_GLOBAL_OFFSET_TABLE_-4), %l7
	call	.LLGETPC0
	add	%l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
	std	%i0, [%fp-24]
	ldd	[%fp-24], %f2
	sethi	%hi(.LLC1), %o2
	ldd	[%o2+%lo(.LLC1)], %f4
	fmuld	%f2, %f4, %f2
	std	%f2, [%fp-16]
	ldd	[%fp-16], %o0
	call	test, 0
	add	%fp, -24, %o2
	ldd	[%fp-24], %f2
	sethi	%hi(.LLC1), %o2
	ldd	[%o2+%lo(.LLC1)], %f4
	fmuld	%f2, %f4, %f2
	std	%f2, [%fp-16]
	ldd	[%fp-16], %o0
	call	test, 0
	add	%fp, -24, %o2
	ret
	restore
.LLfe2:
	.size	 call_test,.LLfe2-call_test
.section	".rodata"
	.align 8
.LLC2:
	.uaword	0x3ff00000 ! ~1.00000000000000000000e0
	.uaword	0x0
.section	".text"
	.align 4
	.global main
	.type	 main,#function
	.proc	04
main:
	!#PROLOGUE# 0
	save	%sp, -112, %sp
	sethi	%hi(_GLOBAL_OFFSET_TABLE_-4), %l7
	call	.LLGETPC0
	add	%l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
	sethi	%hi(.LLC2), %o0
	or	%o0, %lo(.LLC2), %o0
	ld	[%l7+%o0], %o0
	call	call_test, 0
	ldd	[%o0], %o0
	ret
	restore %g0, 0, %o0
.LLfe3:
	.size	 main,.LLfe3-main
	.ident	"GCC: (GNU) gcc-2.95 19990602 (prerelease)"


More information about the Gcc-bugs mailing list