请问怎么在solaris x86上编译内核模块
请问怎么在solaris x86上编译内核模块//hello.c
#include <sys/ddi.h>
#include <sys/sunddi.h>
#include <sys/modctl.h>
extern struct mod_ops mod_miscops;
static struct modlmisc modlmisc = {
&mod_miscops,
"First Loadable Kernel Module",
};
static struct modlinkage modlinkage = {
MODREV_1,
(void *)&modlmisc,
NULL
};
int _init(void)
{
int i;
if ((i = mod_install(&modlinkage)) != 0)
cmn_err(CE_NOTE,"Could not install module\n");
else
cmn_err(CE_NOTE,"flkm: successfully installed");
return i;
}
int _info(struct modinfo *modinfop)
{
return (mod_info(&modlinkage, modinfop));
}
int _fini(void)
{
int i;
if ((i = mod_remove(&modlinkage)) != 0)
cmn_err(CE_NOTE,"Could not remove module\n");
else
cmn_err(CE_NOTE,"flkm: successfully removed");
return i;
}
bash-3.00# gcc -D_KERNEL -DSVR4 -DSOL2 -O2 -c hello.c
bash-3.00# ld -o hello -r hello.o
bash-3.00# modload hello
can't load module: Invalid argument