This is the mail archive of the gcc-prs@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]

c/4136: wrong assembler for static variables with -fPIC on powerpc-elf-netbsd



>Number:         4136
>Category:       c
>Synopsis:       wrong assembler for static variables with -fPIC on powerpc-elf-netbsd
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 27 06:56:02 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Tomas Berndtsson
>Release:        gcc version 3.1 20010826 (experimental)
>Organization:
>Environment:
Cross compiler for powerpc-elf-netbsd, on host i386--netbsd.
Using builtin specs.
Configured with: ../../gcc-cvs/configure --target=powerpc-elf-netbsd --prefix=/usr/local --enable-languages=c --with-local-prefix=/usr/local/powerpc-elf-netbsd --without-headers --with-newlib
Thread model: single
gcc version 3.1 20010826 (experimental)
 
Cross compiler compiled with:
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
on NetBSD/i386. 
>Description:
This is also verified on gcc 2.95.2 and 2.95.3 as well as 2.95.4 from CVS. 

When compiling a file with option -fPIC, when a static variable is used in a function,
the output assembler code is wrong. Compiling with -fpic or no such option works.

The resulting error message from gas is: 
/var/tmp//ccG6GMLk.s: Assembler messages:
/var/tmp//ccG6GMLk.s:28: Error: unsupported relocation type

>How-To-Repeat:
With -fPIC, it will reference the variable with:
        lwz 0,.LCL0-.LCF0(30)

However, the label ".LCL0" does not exist in the assembler output. 
Using a gcc 2.95.2 on Linux/PPC, will add these two lines:
.LCL0:
        .long .LCTOC1-.LCF0

which the output from gcc under NetBSD/PPC does not include.

When compiling with -fpic, or no extra option, the variable is 
referred to simply by the label with its name, and not a relative
address.
>Fix:
As I've understood, -fPIC is not necessary to use on powerpc (rs6000), 
but some makefiles do (gcc included, for libgcc2), and some files
don't compile. 
>Release-Note:
>Audit-Trail:
>Unformatted:
 
----gnatsweb-attachment----
Content-Type: text/x-csrc; name="pic.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="pic.c"

aW50IHRqbygpCnsKICBzdGF0aWMgaW50IGEgPSAwOwogIHJldHVybiBhOwp9Cg==


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