Re: Figuring out start and end of sections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <stdio.h>

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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux