-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsection.c
More file actions
46 lines (35 loc) · 701 Bytes
/
Copy pathsection.c
File metadata and controls
46 lines (35 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <stdlib.h>
typedef void (*myown_call)(void);
extern myown_call _myown_start;
extern myown_call _myown_end;
#define _init __attribute__((unused, section(".myown")))
#define func_init(func) myown_call _fn##func _init = func
void func3()
{
printf("\tthis is section 3\n");
}
func_init(func3);
void func2()
{
printf("\tthis is section 2\n");
}
func_init(func2);
void func1()
{
printf("\tthis is section 1\n");
}
func_init(func1);
void do_initcalls(void)
{
myown_call *call_ptr = &_myown_start;
do{
fprintf(stdout,"call ptr:%p\n",call_ptr);
(*call_ptr)();
call_ptr++;
}while(call_ptr < &_myown_end);
}
int main(int argc,void *argv[])
{
do_initcalls();
}