Adding a new object file to kernel source code and use it's function
Hi all,
I have an object file foo.o which provide a function foo().
when I use this object file with simple main.c as shown below it works correctly.
Code:
#main.c
include "foo.h"
int main()
{
foo();
return 0;
}
I use gcc for compile & link.
Code:
gcc -o foo foo.o main.c
Goal:
I want to use foo() in init/main.c of my linux-2.6.35 kernel source code.
What I've done:
I added foo.o and foo.h to the kernel/init/ directory, modified my init/main.c to use foo(), and added foo.o to obj-y in init/Makefile as shown below.
Code:
obj-y := main.o version.o mounts.o foo.o
Problem:
I get these errors when I make the kernel..
Code:
init/built-in.o: In function `foo1':
foo.c:(.text+0xe3): undefined reference to `printf'
foo.c:(.text+0xf8): undefined reference to `printf'
foo.c:(.text+0x19f): undefined reference to `printf'
foo.c:(.text+0x1b8): undefined reference to `printf'
init/built-in.o: In function `foo2':
foo.c:(.text+0x1e6): undefined reference to `printf'
init/built-in.o:foo.c:(.text+0x1ff): more undefined references to `printf' follow
init/built-in.o: In function `foo3':
foo.c:(.text+0xcb0): undefined reference to `putchar'
foo.c:(.text+0xe29): undefined reference to `stdout'
foo.c:(.text+0xe3c): undefined reference to `fputc'
foo.c:(.text+0xe51): undefined reference to `stdout'
foo.c:(.text+0xe63): undefined reference to `fputc'
foo.c:(.text+0xe76): undefined reference to `puts'
.
.
.
I know the problem arises from Makefile, but I don't know how to solve it.
I would appreciate any help!
Thanks!