From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22238 invoked by alias); 14 Apr 2010 06:47:16 -0000 Received: (qmail 22228 invoked by uid 22791); 14 Apr 2010 06:47:15 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org Received: from ns1.siteground211.com (HELO serv01.siteground211.com) (209.62.36.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Apr 2010 06:47:11 +0000 Received: from [91.154.117.150] (port=29883 helo=gandalf) by serv01.siteground211.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1O1wNQ-000516-05; Wed, 14 Apr 2010 01:47:08 -0500 Date: Wed, 14 Apr 2010 06:47:00 -0000 From: Felipe Balbi To: Felipe Balbi Cc: gcc-help@gcc.gnu.org, iant@google.com Subject: Re: Figuring out start and end of sections Message-ID: <20100414064750.GD4285@gandalf> Reply-To: me@felipebalbi.com References: <20100414062234.GB4285@gandalf> <20100414063043.GC4285@gandalf> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100414063043.GC4285@gandalf> User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2010-04/txt/msg00122.txt.bz2 Hi, On Wed, Apr 14, 2010 at 09:30:43AM +0300, Felipe Balbi wrote: > I commented the for loop just to get the thing compiling and nm doesn't > show any __start_ symbols: now I got it working: #include typedef int (*initcall_t)(void); extern initcall_t __start__initcall[]; extern initcall_t __stop__initcall[]; static int my_init(void) { printf("hello world from _init\n"); } static initcall_t __my_initcall_my_init __attribute__((__used__)) __attribute__((section("_initcall"))) = my_init; static void call_initcall(initcall_t fn) { fn(); } int main(int argc, char *argv[]) { initcall_t *fn; for (fn = __start__initcall; fn < __stop__initcall; fn++) call_initcall(*fn); return 0; } thanks a lot Ian and Andrew. -- balbi