[Top] [All Lists]

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

To: Ralf Baechle <>
Subject: Re: Setting up of GP in static, non-PIC version of glibc?
From: Jay Carlson <>
Date: Tue, 26 Feb 2002 00:10:50 -0500
Cc: Jay Carlson <>, Hartvig Ekner <>,
In-reply-to: <>

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
#ifdef __PIC__
        la  $28, _gp

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 :-)


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