I've got two files named "hello.c" and "hello1.c"
In hello.c I have:
#include <stdio.h>
main()
{
printf("Hello World!\n");
}
In hello1.c I have:
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/sysctl.h>
#include <asm/io.h>
#include <typedefs.h>
#include <bcm4710.h>
#include <sbutils.h>
static int __init diag_init()
{
printk("Hello World!\n");
return 0;
}
static void __exit diag_exit()
{
printk("Byebye!\n");
}
module_init(diag_init);
module_exit(diag_exit);
I can use mipsel-uclibc-gcc to compile hello.c to a binary file hello and then use wget to download it to WRT54G and then execute it. It works well.
However, I can only use mipsel-uclibc-gcc to compile hello1.c to hello1.o
and then use
insmod helloworld.o
rmmod helloworld
dmesg
to get the result.
So what's the difference between two files?
How can mipsel-uclibc-gcc tell the difference between them?