On Mon, Oct 08, 2001 at 12:39:57PM -0700, Manoj Ekbote wrote: Please fix your mailer so it will break lines at 72 characters. Makes your messages much more readable. > I have been looking at the linux serial driver initialization routine > rs_init() in drivers/char/serial.c. This routine gets invoked as a > part of a do-while loop in do_initcalls() in init/main.c.The code > looks something like this: > > static void __init do_initcalls(void) > { > initcall_t *call; > > call = &__initcall_start; > do { > (*call)(); > call++; > } while (call < &__initcall_end); > > /* Make sure there is no pending stuff from the initcall sequence */ > flush_scheduled_tasks(); > } > > I would like to know where exactly is rs_init() being inserted into > the chain of routines that gets invoked in the do-while loop. Welcome to linker magic! The __initcall directive expands to something like __attribute__ ((unused,__section__ (".initcall.init"))), which will instruct the compiler to but the function pointer in the .initcall.init ELF section (see gcc info file for more information). The boundaries of this section are __initcall_start and __initcall_end, also filled in by the linker at link time. So the rs_init() function pointer will be put *somewhere* into the .initcall.init section. At boot, the function do_initcalls() will call all function pointers in the section, so at a certain point rs_init() will also be called through its function pointer in the .initcall.init section. Erik -- J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department of Electrical Engineering, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635 Fax: +31-15-2781843 Email: J.A.K.Mouw@its.tudelft.nl WWW: http://www-ict.its.tudelft.nl/~erik/ - Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ IRC Channel: irc.openprojects.net / #kernelnewbies Web Page: http://www.kernelnewbies.org/