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>

index | next in thread | raw e-mail

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_ symbol.



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, and module is working fine.





Please let me know, if there is any way to link ZLIB with our module in FreeBSD 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/GENERIC  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 = 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 = (alloc_func)z_alloc;

      zInfo.zfree = (free_func)z_free;

      zInfo.opaque = NULL;



      rc = 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 = 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 = EOPNOTSUPP;

    break;

 }

  return(err);

}

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



static moduledata_t skel_mod = {

  "skel",

  skel_loader,

  NULL

};



DECLARE_MODULE(skeleton, skel_mod, SI_SUB_KLD, SI_ORDER_ANY);

---



Makefile:



SRCS=skel.c

KMOD=skel



.include <bsd.kmod.mk>



Error:



# kldload ./skel.ko

# dmesg

link_elf_obj: symbol deflateInit_ undefined

linker_load_file: Unsupported file type



help

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