From owner-freebsd-toolchain@FreeBSD.ORG Thu Feb 16 17:08:54 2012 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17DE7106566B; Thu, 16 Feb 2012 17:08:54 +0000 (UTC) (envelope-from draco@marino.st) Received: from shepard.synsport.net (mail.synsport.com [208.69.230.148]) by mx1.freebsd.org (Postfix) with ESMTP id E24128FC17; Thu, 16 Feb 2012 17:08:53 +0000 (UTC) Received: from [10.31.9.93] (unknown [213.225.137.129]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by shepard.synsport.net (Postfix) with ESMTP id 094D343B4E; Thu, 16 Feb 2012 10:51:25 -0600 (CST) Message-ID: <4F3D3409.3040006@marino.st> Date: Thu, 16 Feb 2012 17:51:21 +0100 From: John Marino User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20120129 Thunderbird/10.0 MIME-Version: 1.0 To: Konstantin Belousov References: <4F3C5A3A.6050107@FreeBSD.org> <20120216154730.GL3283@deviant.kiev.zoral.com.ua> In-Reply-To: <20120216154730.GL3283@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Pedro Giffuni , freebsd-toolchain@freebsd.org Subject: Re: DragonFly added support for ELF preinit, init, and fini arrays X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Feb 2012 17:08:54 -0000 On 2/16/2012 16:47, Konstantin Belousov wrote: > On Wed, Feb 15, 2012 at 08:22:02PM -0500, Pedro Giffuni wrote: >> Hello; >> >> FYI, this commit in DragonFly seems interesting: >> >> http://leaf.dragonflybsd.org/mailarchive/commits/2012-02/msg00146.html >> >> It appears like linux had them from a while and some years ago they started >> using them for C++ in gcc: >> >> http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01872.html >> >> cheers, > If you read the commit message, you will notice something at the end. > > I have WIP patches to add support for the init arrays to our rtld. > It is not tested yet, and I want to ponder more about the ABI changes > in csu that I introduce. > > In fact, I am more interested in having answer to the question, what > immediate and long-term use do we have for the feature. Also, I want > non-artificial test cases for DT_INIT_ARRAY and DT_FINI_ARRAY. > > http://people.freebsd.org/~kib/misc/init_array.1.patch Hi Konstantin, One obvious case for the immediate use is the building of gold linker in binutils 2.22. By default, it moves constructors into the init array, so gold will segfault if it was linked with itself. (The workaround is to patch option.h file to change the ctors-in-init-array to false before building gold so it has the same behavior as gnu ld). Also, GCC now supports generation of .init_array and .fini_array directly rather than using .ctor and .dtor sections. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770 I can't say how much current software depends on the functionality working though. Mostly this would be transparently handled by gcc and the linker. The main benefit from what I can tell is that .init_array is more efficient at startup because the array is executed in order while .ctors is executed in reverse. .ctors is also considered legacy and supporting it is "backwards compatible". Apparently ARM eabi only uses .init_array and not .ctors. There seems to be a slow movement to eliminate .ctors on the linux side with rationale that .init_array support has been available 11 years and the gcc patch is an indication of that attitude. John