aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib/libctf
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libctf')
-rw-r--r--cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c35
-rw-r--r--cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c5
2 files changed, 10 insertions, 30 deletions
diff --git a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c
index 6cd003663cac..6e599540a4f6 100644
--- a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c
+++ b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c
@@ -29,25 +29,18 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include <sys/zmod.h>
#include <ctf_impl.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
-#if defined(sun)
#include <dlfcn.h>
-#else
-#include <zlib.h>
-#endif
#include <gelf.h>
-#if defined(sun)
#ifdef _LP64
static const char *_libctf_zlib = "/usr/lib/64/libz.so";
#else
static const char *_libctf_zlib = "/usr/lib/libz.so";
#endif
-#endif
static struct {
int (*z_uncompress)(uchar_t *, ulong_t *, const uchar_t *, ulong_t);
@@ -58,20 +51,14 @@ static struct {
static size_t _PAGESIZE;
static size_t _PAGEMASK;
-#if defined(sun)
#pragma init(_libctf_init)
-#else
-void _libctf_init(void) __attribute__ ((constructor));
-#endif
void
_libctf_init(void)
{
-#if defined(sun)
const char *p = getenv("LIBCTF_DECOMPRESSOR");
if (p != NULL)
_libctf_zlib = p; /* use alternate decompression library */
-#endif
_libctf_debug = getenv("LIBCTF_DEBUG") != NULL;
@@ -87,7 +74,6 @@ _libctf_init(void)
void *
ctf_zopen(int *errp)
{
-#if defined(sun)
ctf_dprintf("decompressing CTF data using %s\n", _libctf_zlib);
if (zlib.z_dlp != NULL)
@@ -99,21 +85,14 @@ ctf_zopen(int *errp)
if ((zlib.z_dlp = dlopen(_libctf_zlib, RTLD_LAZY | RTLD_LOCAL)) == NULL)
return (ctf_set_open_errno(errp, ECTF_ZINIT));
- zlib.z_uncompress = (int (*)(uchar_t *, ulong_t *, const uchar_t *, ulong_t)) dlsym(zlib.z_dlp, "uncompress");
- zlib.z_error = (const char *(*)(int)) dlsym(zlib.z_dlp, "zError");
+ zlib.z_uncompress = (int (*)()) dlsym(zlib.z_dlp, "uncompress");
+ zlib.z_error = (const char *(*)()) dlsym(zlib.z_dlp, "zError");
if (zlib.z_uncompress == NULL || zlib.z_error == NULL) {
(void) dlclose(zlib.z_dlp);
bzero(&zlib, sizeof (zlib));
return (ctf_set_open_errno(errp, ECTF_ZINIT));
}
-#else
- zlib.z_uncompress = uncompress;
- zlib.z_error = zError;
-
- /* Dummy return variable as 'no error' */
- zlib.z_dlp = (void *) (uintptr_t) 1;
-#endif
return (zlib.z_dlp);
}
@@ -241,7 +220,7 @@ ctf_fdopen(int fd, int *errp)
* If we have read enough bytes to form a CTF header and the magic
* string matches, attempt to interpret the file as raw CTF.
*/
- if (nbytes >= (ssize_t) sizeof (ctf_preamble_t) &&
+ if (nbytes >= sizeof (ctf_preamble_t) &&
hdr.ctf.ctp_magic == CTF_MAGIC) {
if (hdr.ctf.ctp_version > CTF_VERSION)
return (ctf_set_open_errno(errp, ECTF_CTFVERS));
@@ -271,7 +250,7 @@ ctf_fdopen(int fd, int *errp)
* do our own largefile ELF processing, and convert everything to
* GElf structures so that clients can operate on any data model.
*/
- if (nbytes >= (ssize_t) sizeof (Elf32_Ehdr) &&
+ if (nbytes >= sizeof (Elf32_Ehdr) &&
bcmp(&hdr.e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
#ifdef _BIG_ENDIAN
uchar_t order = ELFDATA2MSB;
@@ -283,7 +262,7 @@ ctf_fdopen(int fd, int *errp)
void *strs_map;
size_t strs_mapsz;
- char *strs;
+ const char *strs;
if (hdr.e32.e_ident[EI_DATA] != order)
return (ctf_set_open_errno(errp, ECTF_ENDIAN));
@@ -291,7 +270,7 @@ ctf_fdopen(int fd, int *errp)
return (ctf_set_open_errno(errp, ECTF_ELFVERS));
if (hdr.e32.e_ident[EI_CLASS] == ELFCLASS64) {
- if (nbytes < (ssize_t) sizeof (GElf_Ehdr))
+ if (nbytes < sizeof (GElf_Ehdr))
return (ctf_set_open_errno(errp, ECTF_FMT));
} else {
Elf32_Ehdr e32 = hdr.e32;
@@ -342,7 +321,7 @@ ctf_fdopen(int fd, int *errp)
strs_map = mmap64(NULL, strs_mapsz, PROT_READ, MAP_PRIVATE,
fd, sp[hdr.e64.e_shstrndx].sh_offset & _PAGEMASK);
- strs = (char *)strs_map +
+ strs = (const char *)strs_map +
(sp[hdr.e64.e_shstrndx].sh_offset & ~_PAGEMASK);
if (strs_map == MAP_FAILED) {
diff --git a/cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c b/cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c
index e9f5ad7a1f71..467b6a8181a8 100644
--- a/cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c
+++ b/cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c
@@ -27,6 +27,7 @@
#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctf_impl.h>
+#include <libctf.h>
#include <sys/mman.h>
#include <stdarg.h>
@@ -57,7 +58,7 @@ ctf_alloc(size_t size)
/*ARGSUSED*/
void
-ctf_free(void *buf, __unused size_t size)
+ctf_free(void *buf, size_t size)
{
free(buf);
}
@@ -65,7 +66,7 @@ ctf_free(void *buf, __unused size_t size)
const char *
ctf_strerror(int err)
{
- return ((const char *) strerror(err));
+ return (strerror(err));
}
/*PRINTFLIKE1*/