diff options
Diffstat (limited to 'usr/src/lib/libctf')
-rw-r--r-- | usr/src/lib/libctf/common/ctf_convert.c | 2 | ||||
-rw-r--r-- | usr/src/lib/libctf/common/ctf_lib.c | 28 | ||||
-rw-r--r-- | usr/src/lib/libctf/common/libctf.h | 3 | ||||
-rw-r--r-- | usr/src/lib/libctf/common/mapfile-vers | 1 |
4 files changed, 30 insertions, 4 deletions
diff --git a/usr/src/lib/libctf/common/ctf_convert.c b/usr/src/lib/libctf/common/ctf_convert.c index cbb4d48c76..1a433d17db 100644 --- a/usr/src/lib/libctf/common/ctf_convert.c +++ b/usr/src/lib/libctf/common/ctf_convert.c @@ -101,7 +101,7 @@ ctf_convert_ftypes(Elf *elf, ctf_convert_source_t *types) } } -static ctf_file_t * +ctf_file_t * ctf_elfconvert(int fd, Elf *elf, const char *label, uint_t nthrs, uint_t flags, int *errp, char *errbuf, size_t errlen) { diff --git a/usr/src/lib/libctf/common/ctf_lib.c b/usr/src/lib/libctf/common/ctf_lib.c index e183b15f52..bc533b766e 100644 --- a/usr/src/lib/libctf/common/ctf_lib.c +++ b/usr/src/lib/libctf/common/ctf_lib.c @@ -37,6 +37,7 @@ #include <dlfcn.h> #include <gelf.h> #include <zlib.h> +#include <zone.h> #include <sys/debug.h> #ifdef _LP64 @@ -92,15 +93,36 @@ _libctf_init(void) void * ctf_zopen(int *errp) { - ctf_dprintf("decompressing CTF data using %s\n", _libctf_zlib); + char buf[MAXPATHLEN]; + const char *path = _libctf_zlib, *zroot; if (zlib.z_dlp != NULL) return (zlib.z_dlp); /* library is already loaded */ - if (access(_libctf_zlib, R_OK) == -1) + /* + * Get the zone native root. For the tools build, we don't need + * this (it seems fair to impose that we always build the system in + * a native zone), and we want to allow build machines that are older + * that the notion of the native root, so we only actually make this + * call if we're not the tools build. + */ +#ifndef CTF_TOOLS_BUILD + zroot = zone_get_nroot(); +#else + zroot = NULL; +#endif + + if (zroot != NULL) { + (void) snprintf(buf, MAXPATHLEN, "%s/%s", zroot, _libctf_zlib); + path = buf; + } + + ctf_dprintf("decompressing CTF data using %s\n", path); + + if (access(path, R_OK) == -1) return (ctf_set_open_errno(errp, ECTF_ZMISSING)); - if ((zlib.z_dlp = dlopen(_libctf_zlib, RTLD_LAZY | RTLD_LOCAL)) == NULL) + if ((zlib.z_dlp = dlopen(path, RTLD_LAZY | RTLD_LOCAL)) == NULL) return (ctf_set_open_errno(errp, ECTF_ZINIT)); zlib.z_uncompress = (int (*)()) dlsym(zlib.z_dlp, "uncompress"); diff --git a/usr/src/lib/libctf/common/libctf.h b/usr/src/lib/libctf/common/libctf.h index 0951ae0606..a5c5027048 100644 --- a/usr/src/lib/libctf/common/libctf.h +++ b/usr/src/lib/libctf/common/libctf.h @@ -44,6 +44,7 @@ #define _LIBCTF_H #include <sys/ctf_api.h> +#include <libelf.h> #ifdef __cplusplus extern "C" { @@ -75,6 +76,8 @@ extern int ctf_diff_objects(ctf_diff_t *, ctf_diff_obj_f, void *); extern void ctf_diff_fini(ctf_diff_t *); #define CTF_CONVERT_F_IGNNONC 0x01 +extern ctf_file_t *ctf_elfconvert(int, Elf *, const char *, uint_t, uint_t, + int *, char *, size_t); extern ctf_file_t *ctf_fdconvert(int, const char *, uint_t, uint_t, int *, char *, size_t); diff --git a/usr/src/lib/libctf/common/mapfile-vers b/usr/src/lib/libctf/common/mapfile-vers index b26ee8ceb4..243f072a3d 100644 --- a/usr/src/lib/libctf/common/mapfile-vers +++ b/usr/src/lib/libctf/common/mapfile-vers @@ -78,6 +78,7 @@ SYMBOL_VERSION SUNWprivate_1.2 { ctf_diff_types; ctf_discard; ctf_dup; + ctf_elfconvert; ctf_elffdwrite; ctf_elfwrite; ctf_enum_value; |