From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29206 invoked by alias); 24 Nov 2009 10:00:55 -0000 Received: (qmail 29193 invoked by uid 22791); 24 Nov 2009 10:00:54 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Nov 2009 10:00:50 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAOA0lUK025070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 24 Nov 2009 05:00:48 -0500 Received: from zebedee.pink (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAOA0iww006683; Tue, 24 Nov 2009 05:00:45 -0500 Message-ID: <4B0BAECB.3090703@redhat.com> Date: Tue, 24 Nov 2009 10:00:00 -0000 From: Andrew Haley User-Agent: Thunderbird 2.0.0.23 (X11/20090825) MIME-Version: 1.0 To: yunfeng zhang CC: gcc@gcc.gnu.org Subject: Re: No .got section in ELF References: <4df04b840911231758md5a545el2d417b663af1647f@mail.gmail.com> In-Reply-To: <4df04b840911231758md5a545el2d417b663af1647f@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-11/txt/msg00632.txt.bz2 yunfeng zhang wrote: > The idea I got is about removing .got section in ELF format totally. > > Before we go, let's see the limitation on the idea > 1) It must be deployed on aligned segment model, such as Linux, which cs.start > = ds.start. > 2) Currently, I only know how to do on x86 ELF. > > Here is a typical sample in PIC model (shared library) when library want to > access its global data > ... > // Later code snippet template is used by gcc in almost all shared function > // to imitate `mov %ip, %ebx'. > call next: > next: > pop %ebx // << A. > ... > movl new_offset(%ebx), %eax // << B. load global variable foo to eax. > ... > .global foo // << C. > OK!, to ld, offsetof(C - A) is const, and to gcc offsetof(B - A) is also > const, so to aligned segment model, new_offset = offset(C - A) - offset(B - A), > right? Surely not, because in a shared library the address of the data varies. There are in theory many copies of the library, each one with its r/w data in a different place. Andrew.