请问怎么在solaris x86上编译内核模块

hb_hyl 2012-02-07 11:41:48
请问怎么在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
...全文
262 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
adamrao 2012-11-08
  • 打赏
  • 举报
回复
哥们,这个问题解决没,求加QQ详聊,我的q:809178308,我也碰到了这个问题,现在项目很急,希望能帮下忙,谢谢了
hb_hyl 2012-02-08
  • 打赏
  • 举报
回复
bash-3.00# gcc -D_KERNEL -DSVR4 -DSOL2 -O2 -c hello.c
bash-3.00# ld -o hello -r hello.o
在solaris(x86)上编译选项对吗?求解
hb_hyl 2012-02-08
  • 打赏
  • 举报
回复
谢谢,这个模块在solairs(space)系统上可以编译装载,使用的是同样的命令。
但是不知道了为什么在solaris(x86)系统上就会有can't load module: Invalid argument求教是不是编译选项有问题
程序员小迷 2012-02-07
  • 打赏
  • 举报
回复
没搞过;
“can't load module: Invalid argument”
貌似在提示参数有问题
hb_hyl 2012-02-07
  • 打赏
  • 举报
回复
看来真没有人来搞x86 solairs 呀

1,543

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 Solaris
社区管理员
  • Solaris
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧