From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18437 invoked by alias); 16 Jan 2003 10:53:52 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 18428 invoked from network); 16 Jan 2003 10:53:47 -0000 Received: from unknown (HELO alcor.imaginet.fr) (195.68.86.12) by sources.redhat.com with SMTP; 16 Jan 2003 10:53:47 -0000 Received: from free.fr (gw.netgem.com [195.68.2.34]) by alcor.imaginet.fr (8.9.3/8.8.8) with ESMTP id LAA19474 for ; Thu, 16 Jan 2003 11:55:35 +0100 (MET) Message-ID: <3E268F3A.4070000@free.fr> Date: Thu, 16 Jan 2003 13:36:00 -0000 From: Fabrice Bellard User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020828 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gcc@gcc.gnu.org Subject: i386 ELF PIC PLT optimization ? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-01/txt/msg00739.txt.bz2 Hi, Did anybody try to improve the i386 ELF ABI for PIC code ? By looking at how the thinks are handled on PowerPC, I think that several improvements are possible, for both smaller and faster code : 1) On i386, the PLT is built by the static linker whereas on PPC it is built dynamically by the dynamic linker. The net result is that the executables are smaller and that indirect jumps can be avoided in the PLT, so the inter DLL/EXEs calls are faster. The PLT can be also smaller because only 5 (or 8) bytes per entry could be used (a call opcode can be used for lazy binding and a direct jmp after). 2) On i386, it is almost always needed to initialize %ebx properly to the GOT address when entering a DLL function (except for functions calling only static functions and referencing no global variables). On PPC, it is only needed to initialize %r30 when accessing global variables. By using a dynamically generated PLT on i386, we could avoid the %ebx register usage when calling a function by the PLT and so we would need to initialize %ebx only in rare cases (only if the function accesses global variables). The net result would be smaller code (because no function prologue in most cases) and faster DLL function calls (no indirect jmp and in most cases %ebx will be usable in the function). I am thinking about implementing it in TinyCC (a tiny C compiler) to test it. Does anyone have implemented similar ideas in GCC ? Of course, a small patch in ld.so would be needed to support that while staying compatible with standard DLLs. Fabrice.