linux-mips
[Top] [All Lists]

Re: Setting up of GP in static, non-PIC version of glibc?

To: Ralf Baechle <ralf@oss.sgi.com>
Subject: Re: Setting up of GP in static, non-PIC version of glibc?
From: Jay Carlson <nop@nop.com>
Date: Tue, 26 Feb 2002 00:10:50 -0500
Cc: Jay Carlson <nop@nop.com>, Hartvig Ekner <hartvige@mips.com>, linux-mips@oss.sgi.com
In-reply-to: <20020225173433.B3680@dea.linux-mips.net>
Sender: owner-linux-mips@oss.sgi.com

On Monday, February 25, 2002, at 11:34 AM, Ralf Baechle wrote:

On Mon, Feb 25, 2002 at 04:16:20PM +0100, Hartvig Ekner wrote:

        .globl ENTRY_POINT
        .type ENTRY_POINT,@function
ENTRY_POINT:
#ifdef __PIC__
        SET_GP
#else
        la  $28, _gp
#endif

Makes things work (this code ends in crt1.o). Is this the right place to
fix it?

Non-PIC code doesn't use $gp, so any reference to $gp is a bug.  Note
that we don't support global data optimization for ELF either that is,
-G 0 is the default.

By default non-PIC code *does* use $gp due to the brain damage in gas; gas defaults to -G 8 unless told otherwise (-KPIC implies -G0 so we don't see this in PIC code.) gcc won't know anything about this, of course.

What I'm doing in SUBTARGET_ASM_SPEC is to write something like "%{fno-pic: %{!G: -G0}}"--if we're not in PIC mode, pass -G0 to gas by default.

Anyway, once that's straightened out, -G8 does appear to work the way you'd expect, with the code that Hartvig pasted above---I had written a byte-for-byte identical patch :-)

Jay


<Prev in Thread] Current Thread [Next in Thread>