From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12521 invoked by alias); 22 Sep 2011 19:19:34 -0000 Received: (qmail 12484 invoked by uid 22791); 22 Sep 2011 19:19:33 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from smtp2-g21.free.fr (HELO smtp2-g21.free.fr) (212.27.42.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Sep 2011 19:19:17 +0000 Received: from [127.0.0.1] (unknown [62.147.250.108]) by smtp2-g21.free.fr (Postfix) with ESMTP id 39E9F4B00BE for ; Thu, 22 Sep 2011 21:19:10 +0200 (CEST) Message-ID: <4E7B8A22.8020509@free.fr> Date: Thu, 22 Sep 2011 19:19:00 -0000 From: dboml User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: How use linux_kernel init_calls system in a modular application? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2011-09/txt/msg00182.txt.bz2 Hello, I develop a modular application like this: main.c main.h modul1/module1.c modul1/module1.h modul2/module2.c modul2/module2.h modul3/module3.c modul3/module3.h so in main.c, i need to include all modules header like this: #ifdef USE_MODULE_1 #include modul1/module1.H #endif #ifdef USE_MODULE_2 #include modul2/module2.H #endif #ifdef USE_MODULE_3 #include modul3/module3.H #endif int main () { #ifdef USE_MODULE_1 module1_init(); #endif #ifdef USE_MODULE_2 module2_init(); #endif #ifdef USE_MODULE_3 module3_init(); #endif } So, i decide to use the system in linux KERNEL initCalls. It is based on linker sections where are stor init modules functions. in main.h: typedef int (*initcall_t)(void); #define MODULE_INIT(fn) static initcall_t __initcall_##fn __used __attribute__((__section__(".initcall.init"))) = fn; in modul1/module1.c : MODULE_INIT(module1_init) And then, use it in main.c main(){ for (fn = __initcall_start; fn < __initcall_end; fn++) do_one_initcall(*fn); } My question is: how configure the linker for my linux app? For the moment i "don't use" any special linker script. Can't find a good tutorial.... Thanks for any help. David.