From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31546 invoked by alias); 24 Nov 2009 01:58:27 -0000 Received: (qmail 31475 invoked by uid 22791); 24 Nov 2009 01:58:26 -0000 X-SWARE-Spam-Status: No, hits=2.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-px0-f194.google.com (HELO mail-px0-f194.google.com) (209.85.216.194) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Nov 2009 01:58:20 +0000 Received: by pxi32 with SMTP id 32so1858621pxi.15 for ; Mon, 23 Nov 2009 17:58:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.143.27.32 with SMTP id e32mr586307wfj.244.1259027898404; Mon, 23 Nov 2009 17:58:18 -0800 (PST) Date: Tue, 24 Nov 2009 01:58:00 -0000 Message-ID: <4df04b840911231758md5a545el2d417b663af1647f@mail.gmail.com> Subject: No .got section in ELF From: yunfeng zhang To: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 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/msg00630.txt.bz2 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? Here is the new workflow 1) Using new option, such as, new option `--segment-model=aligned' to trigger the feature. 2) Gcc creates a section (nogot) which stores data pair offsetof(B - A) and new_offset address for every function. 3) Ld reads nogot section and update new_offset according to above formular. 4) nogot section is discarded later. Constrast to traditional PIC code, we save an indirect memory load instruction and shrink memory fee by avoiding to load .got section into memory. And it seems it's fit with gcc4.5 link-time optimizer feature.