Try adding "-xmodel=kernel" to the cc.

max

Peter Teoh wrote:
After I wrote a simple kernel module, upon modload, I got the following errors 
(from dmesg output):

Aug 19 15:46:44 sunnyman genunix: [ID 286029 kern.notice] relocation error: R_AMD64_32: Aug 19 15:46:44 sunnyman genunix: [ID 720415 kern.notice] file /export/home/root/solaris/kmod/mod: Aug 19 15:46:44 sunnyman genunix: [ID 370954 kern.notice] symbol : Aug 19 15:46:44 sunnyman genunix: [ID 780480 kern.notice] value 0xfffffffff7960fb8 does not fit Aug 19 15:46:44 sunnyman genunix: [ID 286029 kern.notice] relocation error: R_AMD64_32: Aug 19 15:46:44 sunnyman genunix: [ID 720415 kern.notice] file /export/home/root/solaris/kmod/mod: Aug 19 15:46:44 sunnyman genunix: [ID 370954 kern.notice] symbol .XAAjaAZI36iKE2L.modlinkage: Aug 19 15:46:44 sunnyman genunix: [ID 780480 kern.notice] value 0xffffffffc043e8f8 does not fit Aug 19 15:46:44 sunnyman genunix: [ID 286029 kern.notice] relocation error: R_AMD64_32: Aug 19 15:46:44 sunnyman genunix: [ID 720415 kern.notice] file /export/home/root/solaris/kmod/mod: Aug 19 15:46:44 sunnyman genunix: [ID 370954 kern.notice] symbol .XAAjaAZI36iKE2L.modlinkage: Aug 19 15:46:44 sunnyman genunix: [ID 780480 kern.notice] value 0xffffffffc043e8f8 does not fit Aug 19 15:46:44 sunnyman genunix: [ID 286029 kern.notice] relocation error: R_AMD64_32: Aug 19 15:46:44 sunnyman genunix: [ID 720415 kern.notice] file /export/home/root/solaris/kmod/mod: Aug 19 15:46:44 sunnyman genunix: [ID 370954 kern.notice] symbol .XAAjaAZI36iKE2L.modlinkage: Aug 19 15:46:44 sunnyman genunix: [ID 780480 kern.notice] value 0xffffffffc043e8f8 does not fit
Aug 19 15:46:44 sunnyman genunix: [ID 399259 kern.notice] do_relocations: 
/export/home/root/solaris/kmod/mod do_relocate failed
Aug 19 15:46:44 sunnyman genunix: [ID 603676 kern.notice] mod error doing 
relocations

Can anyone tell me why?

My source are as follows:

extern struct mod_ops mod_miscops;
static struct modlmisc modlmisc =
{
      &mod_miscops,
      "it's me"
};
static struct modlinkage modlinkage =
{
      MODREV_1,
      {&modlmisc,NULL}
};

int _init(void)
{
      int i;
      i = mod_install(&modlinkage);
      cmn_err(CE_NOTE,"this is message.....\n");
      return i;
}
int _info(struct modinfo *modinfop)
{
      return (mod_info (&modlinkage, modinfop));
}
int _fini(void)
{
      int i;
      i = mod_remove(&modlinkage);
      return i;
}

And during compilation I encountered the warnings:

cc -g -m64 -D_KERNEL_ -c mod.c
"mod.c", line 25: warning: implicit function declaration: mod_install
"mod.c", line 26: warning: implicit function declaration: cmn_err
"mod.c", line 31: warning: implicit function declaration: mod_info
"mod.c", line 36: warning: implicit function declaration: mod_remove
ld -o mod -r mod.o

Any clue?   Thanks.

_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to