ZLIB FreeBSD 9.1 version + deflateInit_ Symbol not found
Nagesh Akula
Nagesh.Akula at Emulex.Com
Mon Nov 3 06:43:48 UTC 2014
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 at 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
More information about the freebsd-drivers
mailing list