This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

target/9571: PowerPC -- problems with 'const', -msdata=eabi and sections.


>Number:         9571
>Category:       target
>Synopsis:       PowerPC -- problems with 'const', -msdata=eabi and sections.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 04 14:06:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Sergei Organov
>Release:        gcc version 3.3 20030203 (prerelease)
>Organization:
>Environment:
Linux 2.4.20 i686
>Description:
Given the code:

$ cat const.cc
extern double const d;
double const d = 3.14;
double f() { return d; }
$ ~/try/tools/bin/ppc-rtems-gcc -meabi -msdata=eabi -c -O4 -save-temps -mregnames const.cc -o const.o
const.s: Assembler messages:
const.s:3: Warning: setting incorrect section attributes for .sdata2
$ cat const.s
	.file	"const.cc"
	.globl d
	.section	.sdata2,"aw",@progbits
	.align 3
	.type	d, @object
	.size	d, 8
d:
	.long	1074339512
	.long	1374389535
	.section	.rodata.cst8,"aM",@progbits,8
	.align 3
.LC0:
	.long	1074339512
	.long	1374389535
	.section	".text"
	.align 2
	.globl _Z1fv
	.type	_Z1fv, @function
_Z1fv:
.LFB3:
	lis %r3,.LC0@ha
	lfd %f1,.LC0@l(%r3)
	blr
.LFE3:
	.size	_Z1fv, .-_Z1fv
	.ident	"GCC: (GNU) 3.3 20030203 (prerelease)"


Problems: 

1. Attempt to set "w" attribute for read-only section '.sdata2'.
2. A copy of value of 'd' is put into section '.rodata.cst8'.
   The latter should better go away entirely or at least be 
   '.sdata2.cst8', I think.
3. As a consequence of (2) function f() needs 2 insns instead 
   of 1 to load the constant into register.

For comparison consider perfect code generated in this case:

$ cat var.cc
extern double d;
double d = 3.14;
double f() { return d; }
$ ~/try/tools/bin/ppc-rtems-gcc -meabi -msdata=eabi -c -O4 -save-temps -mregnames var.cc -o var.o
$ cat var.s
	.file	"var.cc"
	.globl d
	.section	.sdata,"aw",@progbits
	.align 3
	.type	d, @object
	.size	d, 8
d:
	.long	1074339512
	.long	1374389535
	.section	".text"
	.align 2
	.globl _Z1fv
	.type	_Z1fv, @function
_Z1fv:
.LFB3:
	lfd %f1,d@sda21(%r0)
	blr
.LFE3:
	.size	_Z1fv, .-_Z1fv
	.ident	"GCC: (GNU) 3.3 20030203 (prerelease)"
>How-To-Repeat:
Refer to description.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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