Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Nov 2014 06:28:26 +0000
From:      Nagesh Akula <Nagesh.Akula@Emulex.Com>
To:        "freebsd-drivers@freebsd.org" <freebsd-drivers@freebsd.org>
Subject:   ZLIB FreeBSD 9.1 version + deflateInit_ Symbol not found
Message-ID:  <383FAC81A1B4D54E8BF7C31A699555FF11DE48DA@CMEXMB1.ad.emulex.com>

next in thread | raw e-mail | index | archive | help
Hi,



I am trying to add compression algorithm within the kernel module.

For this, I have included <net/zlib.h> library calls.



With this getting an linker error,

in FreeBSD 9.1 OS version, getting kldload linker error on deflateInit_ sym=
bol.



link_elf_obj: symbol deflateInit_ undefined

linker_load_file: Unsupported file type



But, in FreeBSD 10.0 version, the zlib library is able to link properly, an=
d module is working fine.





Please let me know, if there is any way to link ZLIB with our module in Fre=
eBSD 9.1 ?



Thank you.

-NAKULA.



Below are additional details:



Tested OS revision:

# uname -a

FreeBSD FreeBSD-170 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 =
09:23:10 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GEN=
ERIC  amd64





Tested module file used for ZLIB issue reproduction:



#include <sys/types.h>

#include <sys/module.h>

#include <sys/systm.h>  /* uprintf */

#include <sys/errno.h>

#include <sys/param.h>  /* defines used in kernel.h */

#include <sys/kernel.h> /* types used in module initialization */

#include <sys/fcntl.h>

#include <sys/malloc.h>



#include <net/zlib.h>



void skel_zlib_test(void);



static void *

z_alloc(void *unused, uint32_t items, uint32_t size)

{

        void *ptr;

        ptr =3D malloc(items * size, M_DEVBUF, M_NOWAIT|M_ZERO);

        return ptr;

}



static void

z_free(void *opaque, void *ptr)

{

        free(ptr, M_DEVBUF);

}



void skel_zlib_test(void)

{

      z_stream zInfo;

      int rc;

      zInfo.zalloc =3D (alloc_func)z_alloc;

      zInfo.zfree =3D (free_func)z_free;

      zInfo.opaque =3D NULL;



      rc =3D deflateInit(&zInfo, Z_DEFAULT_COMPRESSION);

      deflateEnd(&zInfo);

}

/*

* Load handler that deals with the loading and unloading of a KLD.

*/



static int

skel_loader(struct module *m, int what, void *arg)

{

  int err =3D 0;



  switch (what) {

  case MOD_LOAD:                /* kldload */

    uprintf("Skeleton KLD loaded.\n");

      skel_zlib_test();

    break;

  case MOD_UNLOAD:

    uprintf("Skeleton KLD unloaded.\n");

    break;

  default:

    err =3D EOPNOTSUPP;

    break;

 }

  return(err);

}

/* Declare this module to the rest of the kernel */



static moduledata_t skel_mod =3D {

  "skel",

  skel_loader,

  NULL

};



DECLARE_MODULE(skeleton, skel_mod, SI_SUB_KLD, SI_ORDER_ANY);

---



Makefile:



SRCS=3Dskel.c

KMOD=3Dskel



.include <bsd.kmod.mk>



Error:



# kldload ./skel.ko

# dmesg

link_elf_obj: symbol deflateInit_ undefined

linker_load_file: Unsupported file type




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?383FAC81A1B4D54E8BF7C31A699555FF11DE48DA>