summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorRod Evans <Rod.Evans@Sun.COM>2010-03-29 11:14:55 -0700
committerRod Evans <Rod.Evans@Sun.COM>2010-03-29 11:14:55 -0700
commit98c080d502548e68bb9815459ea56e6ae282c430 (patch)
tree3205ed8ac19ce7a86f024a0cd2450640aa8ebdba /usr/src
parentc7f2fd24c9b933d8806de9016fb9bca3f269a8af (diff)
downloadillumos-joyent-98c080d502548e68bb9815459ea56e6ae282c430.tar.gz
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
--HG-- rename : usr/src/cmd/sgs/liblddbg/common/callback.c => usr/src/cmd/sgs/liblddbg/common/dlfcns.c
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/sgs/elfedit/common/elfedit.msg2
-rw-r--r--usr/src/cmd/sgs/elfedit/modules/common/cap.c19
-rw-r--r--usr/src/cmd/sgs/include/conv.h1
-rw-r--r--usr/src/cmd/sgs/include/debug.h59
-rw-r--r--usr/src/cmd/sgs/ld/common/ld.c4
-rw-r--r--usr/src/cmd/sgs/libconv/common/dl.c32
-rw-r--r--usr/src/cmd/sgs/libconv/common/dl.msg18
-rw-r--r--usr/src/cmd/sgs/libconv/common/llib-lconv1
-rw-r--r--usr/src/cmd/sgs/libld/common/ldlibs.c4
-rw-r--r--usr/src/cmd/sgs/libld/common/ldmain.c7
-rw-r--r--usr/src/cmd/sgs/libld/common/update.c39
-rw-r--r--usr/src/cmd/sgs/libld/common/version.c2
-rw-r--r--usr/src/cmd/sgs/liblddbg/Makefile.com4
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/_debug.h10
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/callback.c75
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/debug.c3
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/dlfcns.c220
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/files.c58
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/liblddbg.msg58
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/llib-llddbg38
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/mapfile-vers40
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/syms.c52
-rw-r--r--usr/src/cmd/sgs/packages/common/SUNWonld-README3
-rw-r--r--usr/src/cmd/sgs/rtld/common/dlfcns.c205
24 files changed, 566 insertions, 388 deletions
diff --git a/usr/src/cmd/sgs/elfedit/common/elfedit.msg b/usr/src/cmd/sgs/elfedit/common/elfedit.msg
index 726f56ca10..2ce14c9c49 100644
--- a/usr/src/cmd/sgs/elfedit/common/elfedit.msg
+++ b/usr/src/cmd/sgs/elfedit/common/elfedit.msg
@@ -635,7 +635,7 @@
@ MSG_STR_ARG "arg"
@ MSG_STR_SP_BAR_SP " | "
@ MSG_STR_ELIPSES "..."
-@ MSG_STR_OPTIONS "ade:L:o:rw"
+@ MSG_STR_OPTIONS "ade:L:o:r"
@ MSG_STR_ELFEDIT "elfedit: "
@ MSG_STR_PROMPT "> "
@ MSG_STR_NL "\n"
diff --git a/usr/src/cmd/sgs/elfedit/modules/common/cap.c b/usr/src/cmd/sgs/elfedit/modules/common/cap.c
index ce3d4a6b70..fd55b563fc 100644
--- a/usr/src/cmd/sgs/elfedit/modules/common/cap.c
+++ b/usr/src/cmd/sgs/elfedit/modules/common/cap.c
@@ -384,9 +384,11 @@ print_cap(CAP_CMD_T cmd, int autoprint, ARGSTATE *argstate,
PRINT_CAP_T print_type, Word arg)
{
elfedit_outstyle_t outstyle;
- Word cnt, ndx, printed = 0;
- Cap *cap;
- Boolean header_done = FALSE, null_seen = FALSE;
+ Word cnt, ndx, printed = 0;
+ Cap *cap;
+ Boolean header_done = FALSE, null_seen = FALSE;
+ const char *str;
+ size_t str_size;
if (autoprint && ((elfedit_flags() & ELFEDIT_F_AUTOPRINT) == 0))
return;
@@ -411,6 +413,13 @@ print_cap(CAP_CMD_T cmd, int autoprint, ARGSTATE *argstate,
/* Load string table if there is one */
argstate_add_str(argstate, FALSE);
+ if (argstate->str.sec == NULL) {
+ str = NULL;
+ str_size = 0;
+ } else {
+ str = (const char *)argstate->str.sec->sec_data->d_buf;
+ str_size = argstate->str.sec->sec_data->d_size;
+ }
cap = &argstate->cap.data[ndx];
for (; cnt--; cap++, ndx++) {
@@ -452,9 +461,7 @@ print_cap(CAP_CMD_T cmd, int autoprint, ARGSTATE *argstate,
group_title(argstate, ndx);
Elf_cap_title(0);
}
- Elf_cap_entry(NULL, cap, ndx,
- (const char *)argstate->str.sec->sec_data->d_buf,
- argstate->str.sec->sec_data->d_size,
+ Elf_cap_entry(NULL, cap, ndx, str, str_size,
argstate->obj_state->os_ehdr->e_machine);
} else {
/*
diff --git a/usr/src/cmd/sgs/include/conv.h b/usr/src/cmd/sgs/include/conv.h
index 55cbef7314..bfdf9f8317 100644
--- a/usr/src/cmd/sgs/include/conv.h
+++ b/usr/src/cmd/sgs/include/conv.h
@@ -817,6 +817,7 @@ extern const char *conv_def_tag(Symref, Conv_inv_buf_t *);
extern const char *conv_demangle_name(const char *);
extern const char *conv_dl_flag(int, Conv_fmt_flags_t,
Conv_dl_flag_buf_t *);
+extern const char *conv_dl_info(int);
extern const char *conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
extern const char *conv_dwarf_cfa(uchar_t, Conv_fmt_flags_t,
Conv_inv_buf_t *);
diff --git a/usr/src/cmd/sgs/include/debug.h b/usr/src/cmd/sgs/include/debug.h
index 3f66cd6269..6c3ed64c6a 100644
--- a/usr/src/cmd/sgs/include/debug.h
+++ b/usr/src/cmd/sgs/include/debug.h
@@ -85,6 +85,7 @@ extern "C" {
#define DBG_DLSYM_SELF 3
#define DBG_DLSYM_PROBE 4
#define DBG_DLSYM_SINGLETON 5
+#define DBG_DLSYM_NUM DBG_DLSYM_SINGLETON + 1
#define DBG_DLCLOSE_NULL 0
#define DBG_DLCLOSE_IGNORE 1
@@ -302,10 +303,17 @@ extern void Dbg_help(void);
#define Dbg_cap_ptr_entry Dbg64_cap_ptr_entry
#define Dbg_cap_val_entry Dbg64_cap_val_entry
-#define Dbg_cb_iphdr_enter Dbg64_cb_iphdr_enter
-#define Dbg_cb_iphdr_callback Dbg64_cb_iphdr_callback
-#define Dbg_cb_iphdr_mapchange Dbg64_cb_iphdr_mapchange
-#define Dbg_cb_iphdr_unmap_ret Dbg64_cb_iphdr_unmap_ret
+#define Dbg_dl_dladdr Dbg64_dl_dladdr
+#define Dbg_dl_dlclose Dbg64_dl_dlclose
+#define Dbg_dl_dldump Dbg64_dl_dldump
+#define Dbg_dl_dlerror Dbg64_dl_dlerror
+#define Dbg_dl_dlinfo Dbg64_dl_dlinfo
+#define Dbg_dl_dlopen Dbg64_dl_dlopen
+#define Dbg_dl_dlsym Dbg64_dl_dlsym
+#define Dbg_dl_iphdr_enter Dbg64_dl_iphdr_enter
+#define Dbg_dl_iphdr_callback Dbg64_dl_iphdr_callback
+#define Dbg_dl_iphdr_mapchange Dbg64_dl_iphdr_mapchange
+#define Dbg_dl_iphdr_unmap_ret Dbg64_dl_iphdr_unmap_ret
#define Dbg_ent_entry Dbg64_ent_entry
#define Dbg_ent_print Dbg64_ent_print
@@ -323,9 +331,6 @@ extern void Dbg_help(void);
#define Dbg_file_config_obj Dbg64_file_config_obj
#define Dbg_file_del_rescan Dbg64_file_del_rescan
#define Dbg_file_delete Dbg64_file_delete
-#define Dbg_file_dlclose Dbg64_file_dlclose
-#define Dbg_file_dldump Dbg64_file_dldump
-#define Dbg_file_dlopen Dbg64_file_dlopen
#define Dbg_file_elf Dbg64_file_elf
#define Dbg_file_filtee Dbg64_file_filtee
#define Dbg_file_filter Dbg64_file_filter
@@ -454,7 +459,6 @@ extern void Dbg_help(void);
#define Dbg_syms_cap_title Dbg64_syms_cap_title
#define Dbg_syms_created Dbg64_syms_created
#define Dbg_syms_discarded Dbg64_syms_discarded
-#define Dbg_syms_dlsym Dbg64_syms_dlsym
#define Dbg_syms_dup_discarded Dbg64_syms_dup_discarded
#define Dbg_syms_dup_sort_addr Dbg64_syms_dup_sort_addr
#define Dbg_syms_entered Dbg64_syms_entered
@@ -529,10 +533,17 @@ extern void Dbg_help(void);
#define Dbg_cap_ptr_entry Dbg32_cap_ptr_entry
#define Dbg_cap_val_entry Dbg32_cap_val_entry
-#define Dbg_cb_iphdr_enter Dbg32_cb_iphdr_enter
-#define Dbg_cb_iphdr_callback Dbg32_cb_iphdr_callback
-#define Dbg_cb_iphdr_mapchange Dbg32_cb_iphdr_mapchange
-#define Dbg_cb_iphdr_unmap_ret Dbg32_cb_iphdr_unmap_ret
+#define Dbg_dl_dladdr Dbg32_dl_dladdr
+#define Dbg_dl_dlclose Dbg32_dl_dlclose
+#define Dbg_dl_dldump Dbg32_dl_dldump
+#define Dbg_dl_dlerror Dbg32_dl_dlerror
+#define Dbg_dl_dlinfo Dbg32_dl_dlinfo
+#define Dbg_dl_dlopen Dbg32_dl_dlopen
+#define Dbg_dl_dlsym Dbg32_dl_dlsym
+#define Dbg_dl_iphdr_enter Dbg32_dl_iphdr_enter
+#define Dbg_dl_iphdr_callback Dbg32_dl_iphdr_callback
+#define Dbg_dl_iphdr_mapchange Dbg32_dl_iphdr_mapchange
+#define Dbg_dl_iphdr_unmap_ret Dbg32_dl_iphdr_unmap_ret
#define Dbg_ent_entry Dbg32_ent_entry
#define Dbg_ent_print Dbg32_ent_print
@@ -550,9 +561,6 @@ extern void Dbg_help(void);
#define Dbg_file_config_obj Dbg32_file_config_obj
#define Dbg_file_del_rescan Dbg32_file_del_rescan
#define Dbg_file_delete Dbg32_file_delete
-#define Dbg_file_dlclose Dbg32_file_dlclose
-#define Dbg_file_dldump Dbg32_file_dldump
-#define Dbg_file_dlopen Dbg32_file_dlopen
#define Dbg_file_elf Dbg32_file_elf
#define Dbg_file_filtee Dbg32_file_filtee
#define Dbg_file_filter Dbg32_file_filter
@@ -681,7 +689,6 @@ extern void Dbg_help(void);
#define Dbg_syms_cap_title Dbg32_syms_cap_title
#define Dbg_syms_created Dbg32_syms_created
#define Dbg_syms_discarded Dbg32_syms_discarded
-#define Dbg_syms_dlsym Dbg32_syms_dlsym
#define Dbg_syms_dup_discarded Dbg32_syms_dup_discarded
#define Dbg_syms_dup_sort_addr Dbg32_syms_dup_sort_addr
#define Dbg_syms_entered Dbg32_syms_entered
@@ -786,10 +793,17 @@ extern void Dbg_cap_val(Lm_list *, Syscapset *, Syscapset *, Half);
extern void Dbg_cap_ptr_entry(Lm_list *, dbg_state_t, Xword, const char *);
extern void Dbg_cap_val_entry(Lm_list *, dbg_state_t, Xword, Xword, Half);
-extern void Dbg_cb_iphdr_enter(Lm_list *, u_longlong_t, u_longlong_t);
-extern void Dbg_cb_iphdr_callback(Lm_list *, struct dl_phdr_info *);
-extern void Dbg_cb_iphdr_mapchange(Lm_list *, u_longlong_t, u_longlong_t);
-extern void Dbg_cb_iphdr_unmap_ret(Lm_list *);
+extern void Dbg_dl_dladdr(Rt_map *, void *);
+extern void Dbg_dl_dlclose(Rt_map *, const char *, int);
+extern void Dbg_dl_dldump(Rt_map *, const char *, const char *, int);
+extern void Dbg_dl_dlerror(Rt_map *, const char *);
+extern void Dbg_dl_dlinfo(Rt_map *, const char *, int, void *);
+extern void Dbg_dl_dlopen(Rt_map *, const char *, int *, int);
+extern void Dbg_dl_dlsym(Rt_map *, const char *, int *, const char *, int);
+extern void Dbg_dl_iphdr_enter(Rt_map *, u_longlong_t, u_longlong_t);
+extern void Dbg_dl_iphdr_callback(Lm_list *, struct dl_phdr_info *);
+extern void Dbg_dl_iphdr_mapchange(Lm_list *, u_longlong_t, u_longlong_t);
+extern void Dbg_dl_iphdr_unmap_ret(Lm_list *);
extern const char *
Dbg_demangle_name(const char *);
@@ -812,9 +826,6 @@ extern void Dbg_file_config_obj(Lm_list *, const char *, const char *,
const char *);
extern void Dbg_file_del_rescan(Lm_list *);
extern void Dbg_file_delete(Rt_map *);
-extern void Dbg_file_dlclose(Lm_list *, const char *, int);
-extern void Dbg_file_dldump(Rt_map *, const char *, int);
-extern void Dbg_file_dlopen(Rt_map *, const char *, int *, int);
extern void Dbg_file_elf(Lm_list *, const char *, Addr, size_t,
const char *, Aliste);
extern void Dbg_file_filtee(Lm_list *, const char *, const char *, int);
@@ -966,8 +977,6 @@ extern void Dbg_syms_cap_lookup(Rt_map *, uint_t, const char *, uint_t,
extern void Dbg_syms_cap_title(Ofl_desc *);
extern void Dbg_syms_created(Lm_list *, const char *);
extern void Dbg_syms_discarded(Lm_list *, Sym_desc *);
-extern void Dbg_syms_dlsym(Rt_map *, const char *, int *, const char *,
- int);
extern void Dbg_syms_dup_discarded(Lm_list *, Word ndx, Sym_desc *);
extern void Dbg_syms_dup_sort_addr(Lm_list *, const char *, const char *,
const char *, Addr);
diff --git a/usr/src/cmd/sgs/ld/common/ld.c b/usr/src/cmd/sgs/ld/common/ld.c
index d364a001db..4b2cdd706d 100644
--- a/usr/src/cmd/sgs/ld/common/ld.c
+++ b/usr/src/cmd/sgs/ld/common/ld.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -519,7 +519,7 @@ prepend_ldoptions(int *argcp, char ***argvp)
*/
while (isspace(*ld_options))
ld_options++;
- if (*ld_options == '\0')
+ if (ld_options[0] == '\0')
return (0);
/*
diff --git a/usr/src/cmd/sgs/libconv/common/dl.c b/usr/src/cmd/sgs/libconv/common/dl.c
index b72d4f8bf7..1ab2507ef6 100644
--- a/usr/src/cmd/sgs/libconv/common/dl.c
+++ b/usr/src/cmd/sgs/libconv/common/dl.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -186,3 +186,33 @@ conv_dl_flag(int flags, Conv_fmt_flags_t fmt_flags,
return ((const char *)dl_flag_buf->buf);
}
+
+const char *
+conv_dl_info(int request)
+{
+ static const Msg requests[RTLD_DI_MAX] = {
+ MSG_RTLD_DI_LMID, /* MSG_ORIG(MSG_RTLD_DI_LMID) */
+ MSG_RTLD_DI_LINKMAP, /* MSG_ORIG(MSG_RTLD_DI_LINKMAP) */
+ MSG_RTLD_DI_CONFIGADDR, /* MSG_ORIG(MSG_RTLD_DI_CONFIGADDR) */
+ MSG_RTLD_DI_SERINFO, /* MSG_ORIG(MSG_RTLD_DI_SERINFO) */
+ MSG_RTLD_DI_SERINFOSIZE, /* MSG_ORIG(MSG_RTLD_DI_SERINFOSIZE) */
+ MSG_RTLD_DI_ORIGIN, /* MSG_ORIG(MSG_RTLD_DI_ORIGIN) */
+ MSG_RTLD_DI_PROFILENAME, /* MSG_ORIG(MSG_RTLD_DI_PROFILENAME) */
+ MSG_RTLD_DI_PROFILEOUT, /* MSG_ORIG(MSG_RTLD_DI_PROFILEOUT) */
+ MSG_RTLD_DI_GETSIGNAL, /* MSG_ORIG(MSG_RTLD_DI_GETSIGNAL) */
+ MSG_RTLD_DI_SETSIGNAL, /* MSG_ORIG(MSG_RTLD_DI_SETSIGNAL) */
+ MSG_RTLD_DI_ARGSINFO, /* MSG_ORIG(MSG_RTLD_DI_ARGSINFO) */
+ MSG_RTLD_DI_MMAPS, /* MSG_ORIG(MSG_RTLD_DI_MMAPS) */
+ MSG_RTLD_DI_MMAPCNT /* MSG_ORIG(MSG_RTLD_DI_MMAPCNT) */
+ };
+ static Conv_inv_buf_t inv_buf;
+
+#if (RTLD_DI_MAX != RTLD_DI_MMAPCNT)
+#error "RTLD_DI_MAX has grown"
+#endif
+ if (request && (request <= RTLD_DI_MAX))
+ return (MSG_ORIG(requests[request - 1]));
+
+ (void) conv_invalid_val(&inv_buf, EC_NATPTR(request), 0);
+ return (inv_buf.buf);
+}
diff --git a/usr/src/cmd/sgs/libconv/common/dl.msg b/usr/src/cmd/sgs/libconv/common/dl.msg
index 41d7937261..fc09b02b28 100644
--- a/usr/src/cmd/sgs/libconv/common/dl.msg
+++ b/usr/src/cmd/sgs/libconv/common/dl.msg
@@ -1,5 +1,5 @@
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# CDDL HEADER START
@@ -21,8 +21,6 @@
#
# CDDL HEADER END
#
-# ident "%Z%%M% %I% %E% SMI"
-#
# Message file for cmd/sgs/libconv/common/dl.c
@ MSG_RTLD_LAZY "RTLD_LAZY"
@@ -50,6 +48,20 @@
@ MSG_RTLD_NOHEAP "RTLD_NOHEAP"
@ MSG_RTLD_CONFSET "RTLD_CONFSET"
+@ MSG_RTLD_DI_LMID "RTLD_DI_LMID"
+@ MSG_RTLD_DI_LINKMAP "RTLD_DI_LINKMAP"
+@ MSG_RTLD_DI_CONFIGADDR "RTLD_DI_CONFIGADDR"
+@ MSG_RTLD_DI_SERINFO "RTLD_DI_SERINFO"
+@ MSG_RTLD_DI_SERINFOSIZE "RTLD_DI_SERINFOSIZE"
+@ MSG_RTLD_DI_ORIGIN "RTLD_DI_ORIGIN"
+@ MSG_RTLD_DI_PROFILENAME "RTLD_DI_PROFILENAME"
+@ MSG_RTLD_DI_PROFILEOUT "RTLD_DI_PROFILEOUT"
+@ MSG_RTLD_DI_GETSIGNAL "RTLD_DI_GETSIGNAL"
+@ MSG_RTLD_DI_SETSIGNAL "RTLD_DI_SETSIGNAL"
+@ MSG_RTLD_DI_ARGSINFO "RTLD_DI_ARGSINFO"
+@ MSG_RTLD_DI_MMAPS "RTLD_DI_MMAPS"
+@ MSG_RTLD_DI_MMAPCNT "RTLD_DI_MMAPCNT"
+
@ MSG_GBL_SEP " | "
@ MSG_GBL_QUOTE "\""
@ MSG_GBL_ZERO "0"
diff --git a/usr/src/cmd/sgs/libconv/common/llib-lconv b/usr/src/cmd/sgs/libconv/common/llib-lconv
index 39ed6bf50a..27851fd306 100644
--- a/usr/src/cmd/sgs/libconv/common/llib-lconv
+++ b/usr/src/cmd/sgs/libconv/common/llib-lconv
@@ -119,6 +119,7 @@ const char *conv_cnote_type(Word, Conv_fmt_flags_t, Conv_inv_buf_t *);
const char *conv_def_tag(Symref, Conv_inv_buf_t *);
const char *conv_demangle_name(const char *);
const char *conv_dl_flag(int, Conv_fmt_flags_t, Conv_dl_flag_buf_t *);
+const char *conv_dl_info(int);
const char *conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
const char *conv_dwarf_cfa(uchar_t, Conv_fmt_flags_t, Conv_inv_buf_t *);
const char *conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *);
diff --git a/usr/src/cmd/sgs/libld/common/ldlibs.c b/usr/src/cmd/sgs/libld/common/ldlibs.c
index 78b2c71240..8fbccac6e9 100644
--- a/usr/src/cmd/sgs/libld/common/ldlibs.c
+++ b/usr/src/cmd/sgs/libld/common/ldlibs.c
@@ -23,7 +23,7 @@
* Copyright (c) 1988 AT&T
* All Rights Reserved
*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -358,7 +358,7 @@ ld_lib_setup(Ofl_desc *ofl)
cp = getenv(MSG_ORIG(MSG_LD_LIBPATH));
}
- if ((cp != NULL) && (*cp != '\0')) {
+ if (cp && cp[0]) {
if ((path = libld_malloc(strlen(cp) + 1)) == NULL)
return (S_ERROR);
(void) strcpy(path, cp);
diff --git a/usr/src/cmd/sgs/libld/common/ldmain.c b/usr/src/cmd/sgs/libld/common/ldmain.c
index 826fd798f3..a0174c9c45 100644
--- a/usr/src/cmd/sgs/libld/common/ldmain.c
+++ b/usr/src/cmd/sgs/libld/common/ldmain.c
@@ -181,7 +181,7 @@ ld_main(int argc, char **argv, Half mach)
#endif
sgs_support = getenv(MSG_ORIG(MSG_SGS_SUPPORT));
- if (sgs_support && (*sgs_support != '\0')) {
+ if (sgs_support && sgs_support[0]) {
const char *sep = MSG_ORIG(MSG_STR_COLON);
char *lib;
char *lasts;
@@ -240,9 +240,10 @@ ld_main(int argc, char **argv, Half mach)
Plibpath = def_Plibpath;
if (ofl->ofl_rpath == NULL) {
- char *rpath;
+ char *rpath;
+
if (((rpath = getenv(MSG_ORIG(MSG_LD_RUN_PATH))) != NULL) &&
- (strcmp((const char *)rpath, MSG_ORIG(MSG_STR_EMPTY))))
+ rpath[0])
ofl->ofl_rpath = rpath;
}
diff --git a/usr/src/cmd/sgs/libld/common/update.c b/usr/src/cmd/sgs/libld/common/update.c
index 4c781eccde..5a309aa8c8 100644
--- a/usr/src/cmd/sgs/libld/common/update.c
+++ b/usr/src/cmd/sgs/libld/common/update.c
@@ -2944,20 +2944,37 @@ update_oehdr(Ofl_desc * ofl)
ehdr->e_entry =
((Sym_desc *)(ofl->ofl_entry))->sd_sym->st_value;
- /*
- * Note. it may be necessary to update the `e_flags' field in the
- * machine dependent section.
- */
ehdr->e_ident[EI_DATA] = ld_targ.t_m.m_data;
- ehdr->e_machine = ofl->ofl_dehdr->e_machine;
- ehdr->e_flags = ofl->ofl_dehdr->e_flags;
ehdr->e_version = ofl->ofl_dehdr->e_version;
- if (ehdr->e_machine != ld_targ.t_m.m_mach) {
- if (ehdr->e_machine != ld_targ.t_m.m_machplus)
- return (S_ERROR);
- if ((ehdr->e_flags & ld_targ.t_m.m_flagsplus) == 0)
- return (S_ERROR);
+ /*
+ * When generating a relocatable object under -z symbolcap, set the
+ * e_machine to be generic, and remove any e_flags. Input relocatable
+ * objects may identify alternative e_machine (m.machplus) and e_flags
+ * values. However, the functions within the created output object
+ * are selected at runtime using the capabilities mechanism, which
+ * supersedes the e-machine and e_flags information. Therefore,
+ * e_machine and e_flag values are not propagated to the output object,
+ * as these values might prevent the kernel from loading the object
+ * before the runtime linker gets control.
+ */
+ if (ofl->ofl_flags & FLG_OF_OTOSCAP) {
+ ehdr->e_machine = ld_targ.t_m.m_mach;
+ ehdr->e_flags = 0;
+ } else {
+ /*
+ * Note. it may be necessary to update the e_flags field in the
+ * machine dependent section.
+ */
+ ehdr->e_machine = ofl->ofl_dehdr->e_machine;
+ ehdr->e_flags = ofl->ofl_dehdr->e_flags;
+
+ if (ehdr->e_machine != ld_targ.t_m.m_mach) {
+ if (ehdr->e_machine != ld_targ.t_m.m_machplus)
+ return (S_ERROR);
+ if ((ehdr->e_flags & ld_targ.t_m.m_flagsplus) == 0)
+ return (S_ERROR);
+ }
}
if (ofl->ofl_flags & FLG_OF_SHAROBJ)
diff --git a/usr/src/cmd/sgs/libld/common/version.c b/usr/src/cmd/sgs/libld/common/version.c
index 5504f838aa..c625fb2c25 100644
--- a/usr/src/cmd/sgs/libld/common/version.c
+++ b/usr/src/cmd/sgs/libld/common/version.c
@@ -1023,7 +1023,7 @@ ld_vers_verify(Ofl_desc *ofl)
#endif
nv = getenv(MSG_ORIG(MSG_LD_NOVERSION));
- if (nv && (*nv != '\0'))
+ if (nv && nv[0])
return (1);
for (APLIST_TRAVERSE(ofl->ofl_soneed, idx1, sdf)) {
diff --git a/usr/src/cmd/sgs/liblddbg/Makefile.com b/usr/src/cmd/sgs/liblddbg/Makefile.com
index 9693d208c2..23ff27a7b8 100644
--- a/usr/src/cmd/sgs/liblddbg/Makefile.com
+++ b/usr/src/cmd/sgs/liblddbg/Makefile.com
@@ -30,14 +30,14 @@ VERS = .4
COMOBJS = args.o audit.o basic.o debug.o \
syminfo.o tls.o
-COMOBJS32 = bindings32.o cap32.o callback32.o dynamic32.o \
+COMOBJS32 = bindings32.o cap32.o dlfcns32.o dynamic32.o \
elf32.o entry32.o files32.o got32.o \
libs32.o map32.o move32.o phdr32.o \
relocate32.o sections32.o segments32.o shdr32.o \
statistics32.o support32.o syms32.o unused32.o \
util32.o version32.o
-COMOBJS64 = bindings64.o cap64.o callback64.o dynamic64.o \
+COMOBJS64 = bindings64.o cap64.o dlfcns64.o dynamic64.o \
elf64.o entry64.o files64.o got64.o \
libs64.o map64.o move64.o phdr64.o \
relocate64.o sections64.o segments64.o shdr64.o \
diff --git a/usr/src/cmd/sgs/liblddbg/common/_debug.h b/usr/src/cmd/sgs/liblddbg/common/_debug.h
index 0c6109eaac..bc04005e2c 100644
--- a/usr/src/cmd/sgs/liblddbg/common/_debug.h
+++ b/usr/src/cmd/sgs/liblddbg/common/_debug.h
@@ -66,7 +66,7 @@ extern "C" {
#define DBG_C_TLS 0x00100000
#define DBG_C_UNUSED 0x00200000
#define DBG_C_VERSIONS 0x00400000
-#define DBG_C_CALLBACK 0x00800000
+#define DBG_C_DL 0x00800000
#define DBG_C_ALL 0xffffffff
@@ -101,8 +101,8 @@ typedef struct {
*/
#if defined(_ELF64)
-#define MSG_CB_IPHDR_ADDR MSG_CB_IPHDR_ADDR_64
-#define MSG_CB_IPHDR_PHDR MSG_CB_IPHDR_PHDR_64
+#define MSG_DL_IPHDR_ADDR MSG_DL_IPHDR_ADDR_64
+#define MSG_DL_IPHDR_PHDR MSG_DL_IPHDR_PHDR_64
#define MSG_GOT_TITLE MSG_GOT_TITLE_64
#define MSG_GOT_ENTRY_RE MSG_GOT_ENTRY_RE_64
@@ -161,8 +161,8 @@ typedef struct {
#else
-#define MSG_CB_IPHDR_ADDR MSG_CB_IPHDR_ADDR_32
-#define MSG_CB_IPHDR_PHDR MSG_CB_IPHDR_PHDR_32
+#define MSG_DL_IPHDR_ADDR MSG_DL_IPHDR_ADDR_32
+#define MSG_DL_IPHDR_PHDR MSG_DL_IPHDR_PHDR_32
#define MSG_GOT_TITLE MSG_GOT_TITLE_32
#define MSG_GOT_ENTRY_RE MSG_GOT_ENTRY_RE_32
diff --git a/usr/src/cmd/sgs/liblddbg/common/callback.c b/usr/src/cmd/sgs/liblddbg/common/callback.c
deleted file mode 100644
index b23c3f4aa8..0000000000
--- a/usr/src/cmd/sgs/liblddbg/common/callback.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include "msg.h"
-#include "_debug.h"
-#include "libld.h"
-
-void
-Dbg_cb_iphdr_enter(Lm_list *lml, u_longlong_t cnt_map, u_longlong_t cnt_unmap)
-{
- if (DBG_NOTCLASS(DBG_C_CALLBACK))
- return;
-
- Dbg_util_nl(lml, DBG_NL_STD);
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_ENTER));
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_MAPCNT), cnt_map, cnt_unmap);
-}
-
-void
-Dbg_cb_iphdr_callback(Lm_list *lml, struct dl_phdr_info *info)
-{
- if (DBG_NOTCLASS(DBG_C_CALLBACK))
- return;
-
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_CALLBACK));
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_NAME), info->dlpi_name);
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_ADDR), EC_ADDR(info->dlpi_addr));
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_PHDR),
- EC_ADDR(CAST_PTRINT(Addr, info->dlpi_phdr)),
- EC_WORD(info->dlpi_phnum));
-
-}
-
-void
-Dbg_cb_iphdr_mapchange(Lm_list *lml, u_longlong_t cnt_map,
- u_longlong_t cnt_unmap)
-{
- if (DBG_NOTCLASS(DBG_C_CALLBACK))
- return;
-
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_MAPCNG));
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_MAPCNT), cnt_map, cnt_unmap);
-}
-
-void
-Dbg_cb_iphdr_unmap_ret(Lm_list *lml)
-{
- if (DBG_NOTCLASS(DBG_C_CALLBACK))
- return;
-
- dbg_print(lml, MSG_INTL(MSG_CB_IPHDR_UNMAP));
-}
diff --git a/usr/src/cmd/sgs/liblddbg/common/debug.c b/usr/src/cmd/sgs/liblddbg/common/debug.c
index 1f2b449959..bc7428596e 100644
--- a/usr/src/cmd/sgs/liblddbg/common/debug.c
+++ b/usr/src/cmd/sgs/liblddbg/common/debug.c
@@ -92,7 +92,7 @@ static DBG_options _Dbg_options_ld[] = { /* ld only options */
static DBG_options _Dbg_options_rtld[] = { /* ld.so.1 only options */
{MSG_ORIG(MSG_TOK_AUDIT), DBG_C_AUDITING, 0},
{MSG_ORIG(MSG_TOK_BINDINGS), DBG_C_BINDINGS, 0},
- {MSG_ORIG(MSG_TOK_CALLBACK), DBG_C_CALLBACK, 0},
+ {MSG_ORIG(MSG_TOK_DL), DBG_C_DL, 0},
{MSG_ORIG(MSG_TOK_INIT), DBG_C_INIT, 0},
{NULL, 0, 0},
};
@@ -261,7 +261,6 @@ Dbg_help(void)
dbg_print(0, MSG_INTL(MSG_USE_R8_B));
dbg_print(0, MSG_INTL(MSG_USE_R8_B2));
dbg_print(0, MSG_INTL(MSG_USE_R8_C));
- dbg_print(0, MSG_INTL(MSG_USE_R8_C2));
dbg_print(0, MSG_INTL(MSG_USE_R8_D));
Dbg_util_nl(0, DBG_NL_FRC);
diff --git a/usr/src/cmd/sgs/liblddbg/common/dlfcns.c b/usr/src/cmd/sgs/liblddbg/common/dlfcns.c
new file mode 100644
index 0000000000..62a076ebd2
--- /dev/null
+++ b/usr/src/cmd/sgs/liblddbg/common/dlfcns.c
@@ -0,0 +1,220 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include "msg.h"
+#include "_debug.h"
+#include "libld.h"
+
+void
+Dbg_dl_iphdr_enter(Rt_map *clmp, u_longlong_t cnt_map, u_longlong_t cnt_unmap)
+{
+ Lm_list *lml = LIST(clmp);
+
+ if (DBG_NOTCLASS(DBG_C_DL))
+ return;
+
+ Dbg_util_nl(lml, DBG_NL_STD);
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_ENTER), NAME(clmp));
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_MAPCNT), cnt_map, cnt_unmap);
+}
+
+void
+Dbg_dl_iphdr_callback(Lm_list *lml, struct dl_phdr_info *info)
+{
+ if (DBG_NOTCLASS(DBG_C_DL))
+ return;
+
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_CALLBACK));
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_NAME), info->dlpi_name);
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_ADDR), EC_ADDR(info->dlpi_addr));
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_PHDR),
+ EC_ADDR(CAST_PTRINT(Addr, info->dlpi_phdr)),
+ EC_WORD(info->dlpi_phnum));
+}
+
+void
+Dbg_dl_iphdr_mapchange(Lm_list *lml, u_longlong_t cnt_map,
+ u_longlong_t cnt_unmap)
+{
+ if (DBG_NOTCLASS(DBG_C_DL))
+ return;
+
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_MAPCNG));
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_MAPCNT), cnt_map, cnt_unmap);
+}
+
+void
+Dbg_dl_iphdr_unmap_ret(Lm_list *lml)
+{
+ if (DBG_NOTCLASS(DBG_C_DL))
+ return;
+
+ dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_UNMAP));
+}
+
+void
+Dbg_dl_dlopen(Rt_map *clmp, const char *name, int *in_nfavl, int mode)
+{
+ Conv_dl_mode_buf_t dl_mode_buf;
+ Lm_list *lml = LIST(clmp);
+ const char *retry;
+
+ if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_DL))
+ return;
+
+ /*
+ * The core functionality of dlopen() can be called twice. The first
+ * attempt can be affected by path names that exist in the "not-found"
+ * AVL tree. Should a "not-found" path name be found, a second attempt
+ * is made to locate the required file (in_nfavl is NULL). This fall-
+ * back provides for file system changes while a process executes.
+ */
+ if (in_nfavl)
+ retry = MSG_ORIG(MSG_STR_EMPTY);
+ else
+ retry = MSG_INTL(MSG_STR_RETRY);
+
+ Dbg_util_nl(lml, DBG_NL_STD);
+ dbg_print(lml, MSG_INTL(MSG_DL_DLOPEN), name, NAME(clmp), retry,
+ conv_dl_mode(mode, 0, &dl_mode_buf));
+}
+
+void
+Dbg_dl_dlclose(Rt_map *clmp, const char *name, int flag)
+{
+ const char *str;
+ Lm_list *lml = LIST(clmp);
+
+ if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_DL))
+ return;
+
+ if (flag == DBG_DLCLOSE_IGNORE)
+ str = MSG_INTL(MSG_STR_IGNORE);
+ else
+ str = MSG_ORIG(MSG_STR_EMPTY);
+
+ Dbg_util_nl(lml, DBG_NL_STD);
+ dbg_print(lml, MSG_INTL(MSG_DL_DLCLOSE), name, NAME(clmp), str);
+}
+
+void
+Dbg_dl_dldump(Rt_map *clmp, const char *ipath, const char *opath, int flags)
+{
+ Conv_dl_flag_buf_t dl_flag_buf;
+ Lm_list *lml = LIST(clmp);
+
+ if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_DL))
+ return;
+
+ Dbg_util_nl(lml, DBG_NL_STD);
+ dbg_print(lml, MSG_INTL(MSG_DL_DLDUMP), ipath, NAME(clmp),
+ opath ? opath : MSG_INTL(MSG_STR_NULL),
+ conv_dl_flag(flags, 0, &dl_flag_buf));
+}
+
+void
+Dbg_dl_dlerror(Rt_map *clmp, const char *str)
+{
+ Lm_list *lml = LIST(clmp);
+
+ if (DBG_NOTCLASS(DBG_C_DL))
+ return;
+
+ Dbg_util_nl(lml, DBG_NL_STD);
+ dbg_print(lml, MSG_INTL(MSG_DL_DLERROR), NAME(clmp),
+ str ? str : MSG_INTL(MSG_STR_NULL));
+}
+
+void
+Dbg_dl_dladdr(Rt_map *clmp, void *addr)
+{
+ Lm_list *lml = LIST(clmp);
+
+ if (DBG_NOTCLASS(DBG_C_DL))
+ return;
+
+ Dbg_util_nl(lml, DBG_NL_STD);
+ dbg_print(lml, MSG_INTL(MSG_DL_DLADDR), NAME(clmp), EC_NATPTR(addr));
+}
+
+void
+Dbg_dl_dlsym(Rt_map *clmp, const char *sym, int *in_nfavl, const char *next,
+ int type)
+{
+ const char *str, *retry, *from = NAME(clmp);
+ Lm_list *lml = LIST(clmp);
+
+ static const Msg dlsym_msg[DBG_DLSYM_NUM] = {
+ MSG_STR_EMPTY, /* MSG_ORIG(MSG_STR_EMPTY) */
+ MSG_DLSYM_NEXT, /* MSG_ORIG(MSG_DLSYM_NEXT) */
+ MSG_DLSYM_DEFAULT, /* MSG_ORIG(MSG_DLSYM_DEFAULT) */
+ MSG_DLSYM_SELF, /* MSG_ORIG(MSG_DLSYM_SELF) */
+ MSG_DLSYM_PROBE, /* MSG_ORIG(MSG_DLSYM_PROBE) */
+ MSG_DLSYM_SINGLETON /* MSG_ORIG(MSG_DLSYM_SINGLETON) */
+ };
+#if DBG_DLSYM_NUM != (DBG_DLSYM_SINGLETON + 1)
+#error DBG_DLSYM_NUM has grown
+#endif
+ if (DBG_NOTCLASS(DBG_C_SYMBOLS | DBG_C_DL))
+ return;
+
+ /*
+ * The core functionality of dlsym() can be called twice. The first
+ * attempt can be affected by path names that exist in the "not-found"
+ * AVL tree. Should a "not-found" path name be found, a second attempt
+ * is made to locate the required file (in_nfavl is NULL). This fall-
+ * back provides for file system changes while a process executes.
+ */
+ if (in_nfavl)
+ retry = MSG_ORIG(MSG_STR_EMPTY);
+ else
+ retry = MSG_INTL(MSG_STR_RETRY);
+
+ if (type >= DBG_DLSYM_NUM)
+ type = 0;
+ str = MSG_ORIG(dlsym_msg[type]);
+
+ Dbg_util_nl(lml, DBG_NL_STD);
+ if (next == 0)
+ dbg_print(lml, MSG_INTL(MSG_DLSYM_1), Dbg_demangle_name(sym),
+ from, retry, str);
+ else
+ dbg_print(lml, MSG_INTL(MSG_DLSYM_2), Dbg_demangle_name(sym),
+ from, next, retry, str);
+}
+
+void
+Dbg_dl_dlinfo(Rt_map *clmp, const char *name, int request, void *addr)
+{
+ Lm_list *lml = LIST(clmp);
+
+ if (DBG_NOTCLASS(DBG_C_DL))
+ return;
+
+ Dbg_util_nl(lml, DBG_NL_STD);
+ dbg_print(lml, MSG_INTL(MSG_DL_DLINFO), NAME(clmp), name,
+ conv_dl_info(request), EC_NATPTR(addr));
+}
diff --git a/usr/src/cmd/sgs/liblddbg/common/files.c b/usr/src/cmd/sgs/liblddbg/common/files.c
index 30b43d5851..b205b71ab9 100644
--- a/usr/src/cmd/sgs/liblddbg/common/files.c
+++ b/usr/src/cmd/sgs/liblddbg/common/files.c
@@ -391,64 +391,6 @@ Dbg_file_bindings_done(Lm_list *lml)
}
void
-Dbg_file_dlopen(Rt_map *clmp, const char *name, int *in_nfavl, int mode)
-{
- Conv_dl_mode_buf_t dl_mode_buf;
- Lm_list *lml = LIST(clmp);
- const char *retry;
-
- if (DBG_NOTCLASS(DBG_C_FILES))
- return;
-
- /*
- * The core functionality of dlopen() can be called twice. The first
- * attempt can be affected by path names that exist in the "not-found"
- * AVL tree. Should a "not-found" path name be found, a second attempt
- * is made to locate the required file (in_nfavl is NULL). This fall-
- * back provides for file system changes while a process executes.
- */
- if (in_nfavl)
- retry = MSG_ORIG(MSG_STR_EMPTY);
- else
- retry = MSG_INTL(MSG_STR_RETRY);
-
- Dbg_util_nl(lml, DBG_NL_STD);
- dbg_print(lml, MSG_INTL(MSG_FIL_DLOPEN), name, NAME(clmp), retry,
- conv_dl_mode(mode, 0, &dl_mode_buf));
-}
-
-void
-Dbg_file_dlclose(Lm_list *lml, const char *name, int flag)
-{
- const char *str;
-
- if (DBG_NOTCLASS(DBG_C_FILES))
- return;
-
- if (flag == DBG_DLCLOSE_IGNORE)
- str = MSG_INTL(MSG_STR_IGNORE);
- else
- str = MSG_ORIG(MSG_STR_EMPTY);
-
- Dbg_util_nl(lml, DBG_NL_STD);
- dbg_print(lml, MSG_INTL(MSG_FIL_DLCLOSE), name, str);
-}
-
-void
-Dbg_file_dldump(Rt_map *lmp, const char *path, int flags)
-{
- Conv_dl_flag_buf_t dl_flag_buf;
- Lm_list *lml = LIST(lmp);
-
- if (DBG_NOTCLASS(DBG_C_FILES))
- return;
-
- Dbg_util_nl(lml, DBG_NL_STD);
- dbg_print(lml, MSG_INTL(MSG_FIL_DLDUMP), NAME(lmp), path,
- conv_dl_flag(flags, 0, &dl_flag_buf));
-}
-
-void
Dbg_file_lazyload(Rt_map *clmp, const char *fname, const char *sname)
{
Lm_list *lml = LIST(clmp);
diff --git a/usr/src/cmd/sgs/liblddbg/common/liblddbg.msg b/usr/src/cmd/sgs/liblddbg/common/liblddbg.msg
index c859fa9c25..bbf84e1bd9 100644
--- a/usr/src/cmd/sgs/liblddbg/common/liblddbg.msg
+++ b/usr/src/cmd/sgs/liblddbg/common/liblddbg.msg
@@ -482,9 +482,8 @@
@ MSG_USE_R8_B " bindings symbol binding; detail flag shows"
@ MSG_USE_R8_B2 " absolute:relative addresses"
-# TRANSLATION_NOTE -- do not translate the first token "init".
-@ MSG_USE_R8_C " callback user supplied code executed by ld.so.1"
-@ MSG_USE_R8_C2 " (i.e. dl_iterate_phdr)"
+# TRANSLATION_NOTE -- do not translate the first token "dl".
+@ MSG_USE_R8_C " dl user calls to the dl*() family"
# TRANSLATION_NOTE -- do not translate the first token "init".
@ MSG_USE_R8_D " init init and fini processing"
@@ -655,10 +654,7 @@
@ MSG_FIL_REUSE "file=%s; reusing: originally processed as %s"
@ MSG_FIL_PROT "file=%s; modifying memory protections (%c PROT_WRITE)"
@ MSG_FIL_DELETE "file=%s; deleting"
-@ MSG_FIL_DLOPEN "file=%s; dlopen() called from file=%s %s %s"
-@ MSG_FIL_DLCLOSE "file=%s; dlclose() %s"
@ MSG_FIL_CLEANUP "file=%s; loading failed: cleaning up lmco 0x%llx"
-@ MSG_FIL_DLDUMP "file=%s; dldump() to file=%s %s"
@ MSG_FIL_LAZYLOAD "file=%s; lazy loading from file=%s: symbol=%s"
@ MSG_FIL_PRELOAD "file=%s; preloading"
@ MSG_FIL_NEEDED "file=%s; needed by %s"
@@ -982,8 +978,9 @@
@ MSG_SYM_AOUT "symbol=%s; (original AOUT name)"
@ MSG_SYM_LOOKUP "symbol=%s; lookup in file=%s [ %s ]"
-@ MSG_SYM_DLSYM_1 "symbol=%s; dlsym() called from file=%s %s %s"
-@ MSG_SYM_DLSYM_2 "symbol=%s; dlsym() called from file=%s; starting \
+
+@ MSG_DLSYM_1 "symbol=%s; dlsym() called from file=%s %s %s"
+@ MSG_DLSYM_2 "symbol=%s; dlsym() called from file=%s; starting \
at file=%s %s %s"
@ MSG_CAP_SYM_DEFAULT " symbol=%s[%u]: capability family default"
@@ -1434,20 +1431,30 @@
@ MSG_REL_LDLV_TITLE_64 " type \
offset value section / symbol"
-# Callback messages
+# dl*() family messages
+
+@ MSG_DL_IPHDR_ENTER "dl_iterate_phdr() called from file=%s"
+@ MSG_DL_IPHDR_MAPCNG "dl_iterate_phdr() object map/unmap in callback"
+@ MSG_DL_IPHDR_UNMAP "dl_iterate_phdr() early return due to object unmap"
+@ MSG_DL_IPHDR_CALLBACK "dl_iterate_phdr() callback"
+@ MSG_DL_IPHDR_NAME " dlpi_name: %s"
+@ MSG_DL_IPHDR_MAPCNT " dlpi_adds: %-18llu dlpi_subs: %-18llu"
-@ MSG_CB_IPHDR_ENTER "dl_iterate_phdr enter:"
-@ MSG_CB_IPHDR_MAPCNG "dl_iterate_phdr object map/unmap in callback:"
-@ MSG_CB_IPHDR_UNMAP "dl_iterate_phdr early return due to object unmap"
-@ MSG_CB_IPHDR_CALLBACK "dl_iterate_phdr callback:"
-@ MSG_CB_IPHDR_NAME " dlpi_name: %s"
-@ MSG_CB_IPHDR_MAPCNT " dlpi_adds: %-18llu dlpi_subs: %-18llu"
+@ MSG_DL_IPHDR_ADDR_32 " dlpi_addr: %#-10llx"
+@ MSG_DL_IPHDR_PHDR_32 " dlpi_phdr: %#-10llx dlpi_phnum: %u"
-@ MSG_CB_IPHDR_ADDR_32 " dlpi_addr: %#-10llx"
-@ MSG_CB_IPHDR_PHDR_32 " dlpi_phdr: %#-10llx dlpi_phnum: %u"
+@ MSG_DL_IPHDR_ADDR_64 " dlpi_addr: %#-18llx"
+@ MSG_DL_IPHDR_PHDR_64 " dlpi_phdr: %#-18llx dlpi_phnum: %u"
-@ MSG_CB_IPHDR_ADDR_64 " dlpi_addr: %#-18llx"
-@ MSG_CB_IPHDR_PHDR_64 " dlpi_phdr: %#-18llx dlpi_phnum: %u"
+@ MSG_DL_DLCLOSE "file=%s; dlclose() called from file=%s %s"
+@ MSG_DL_DLDUMP "file=%s; dldump() called from file=%s: dumping to \
+ file=%s %s"
+@ MSG_DL_DLOPEN "file=%s; dlopen() called from file=%s %s %s"
+
+@ MSG_DL_DLADDR "dladdr() called from file=%s: %#llx"
+@ MSG_DL_DLERROR "dlerror() called from file=%s: %s"
+@ MSG_DL_DLINFO "dlinfo() called from file=%s: handle=%s, request=%s, \
+ user data=%#llx"
@ _END_
@@ -1456,7 +1463,7 @@
@ MSG_TOK_ALL "all"
@ MSG_TOK_ARGS "args"
@ MSG_TOK_BINDINGS "bindings"
-@ MSG_TOK_CALLBACK "callback"
+@ MSG_TOK_DL "dl"
@ MSG_TOK_CAP "cap"
@ MSG_TOK_BASIC "basic"
@ MSG_TOK_ENTRY "entry"
@@ -1579,11 +1586,12 @@
@ MSG_SYM_GLOBAL "global"
@ MSG_SYM_LOCAL "local"
@ MSG_SYM_COPY "copy rel"
-@ MSG_SYM_NEXT "[ RTLD_NEXT ]"
-@ MSG_SYM_DEFAULT "[ RTLD_DEFAULT ]"
-@ MSG_SYM_SELF "[ RTLD_SELF ]"
-@ MSG_SYM_PROBE "[ RTLD_PROBE ]"
-@ MSG_SYM_SINGLETON "( singleton reference )"
+
+@ MSG_DLSYM_NEXT "[ RTLD_NEXT ]"
+@ MSG_DLSYM_DEFAULT "[ RTLD_DEFAULT ]"
+@ MSG_DLSYM_SELF "[ RTLD_SELF ]"
+@ MSG_DLSYM_PROBE "[ RTLD_PROBE ]"
+@ MSG_DLSYM_SINGLETON "( singleton reference )"
# Link-map mode strings
diff --git a/usr/src/cmd/sgs/liblddbg/common/llib-llddbg b/usr/src/cmd/sgs/liblddbg/common/llib-llddbg
index ffd8884108..ef91898f64 100644
--- a/usr/src/cmd/sgs/liblddbg/common/llib-llddbg
+++ b/usr/src/cmd/sgs/liblddbg/common/llib-llddbg
@@ -90,14 +90,28 @@ void Dbg64_cap_sec_title(Lm_list *, const char *);
void Dbg32_cap_val(Lm_list *, Syscapset *, Syscapset *, Elf32_Half);
void Dbg64_cap_val(Lm_list *, Syscapset *, Syscapset *, Elf64_Half);
-void Dbg32_cb_iphdr_callback(Lm_list *, struct dl_phdr_info *);
-void Dbg64_cb_iphdr_callback(Lm_list *, struct dl_phdr_info *);
-void Dbg32_cb_iphdr_enter(Lm_list *, u_longlong_t, u_longlong_t);
-void Dbg64_cb_iphdr_enter(Lm_list *, u_longlong_t, u_longlong_t);
-void Dbg32_cb_iphdr_mapchange(Lm_list *, u_longlong_t, u_longlong_t);
-void Dbg64_cb_iphdr_mapchange(Lm_list *, u_longlong_t, u_longlong_t);
-void Dbg32_cb_iphdr_unmap_ret(Lm_list *);
-void Dbg64_cb_iphdr_unmap_ret(Lm_list *);
+void Dbg32_dl_dladdr(Rt_map *, void *);
+void Dbg64_dl_dladdr(Rt_map *, void *);
+void Dbg32_dl_dlclose(Rt_map *, const char *, int);
+void Dbg64_dl_dlclose(Rt_map *, const char *, int);
+void Dbg32_dl_dldump(Rt_map *, const char *, const char *, int);
+void Dbg64_dl_dldump(Rt_map *, const char *, const char *, int);
+void Dbg32_dl_dlerror(Rt_map *, const char *);
+void Dbg64_dl_dlerror(Rt_map *, const char *);
+void Dbg32_dl_dlinfo(Rt_map *, const char *, int, void *);
+void Dbg64_dl_dlinfo(Rt_map *, const char *, int, void *);
+void Dbg32_dl_dlopen(Rt_map *, const char *, int *, int);
+void Dbg64_dl_dlopen(Rt_map *, const char *, int *, int);
+void Dbg32_dl_dlsym(Rt_map *, const char *, int *, const char *, int);
+void Dbg64_dl_dlsym(Rt_map *, const char *, int *, const char *, int);
+void Dbg32_dl_iphdr_callback(Lm_list *, struct dl_phdr_info *);
+void Dbg64_dl_iphdr_callback(Lm_list *, struct dl_phdr_info *);
+void Dbg32_dl_iphdr_enter(Rt_map *, u_longlong_t, u_longlong_t);
+void Dbg64_dl_iphdr_enter(Rt_map *, u_longlong_t, u_longlong_t);
+void Dbg32_dl_iphdr_mapchange(Lm_list *, u_longlong_t, u_longlong_t);
+void Dbg64_dl_iphdr_mapchange(Lm_list *, u_longlong_t, u_longlong_t);
+void Dbg32_dl_iphdr_unmap_ret(Lm_list *);
+void Dbg64_dl_iphdr_unmap_ret(Lm_list *);
void Dbg32_ent_print(Lm_list *, uchar_t, Elf32_Half, APlist *);
void Dbg64_ent_print(Lm_list *, uchar_t, Elf64_Half, APlist *);
@@ -130,12 +144,6 @@ void Dbg32_file_del_rescan(Lm_list *);
void Dbg64_file_del_rescan(Lm_list *);
void Dbg32_file_delete(Rt_map *);
void Dbg64_file_delete(Rt_map *);
-void Dbg32_file_dlclose(Lm_list *, const char *, int);
-void Dbg64_file_dlclose(Lm_list *, const char *, int);
-void Dbg32_file_dldump(Rt_map *, const char *, int);
-void Dbg64_file_dldump(Rt_map *, const char *, int);
-void Dbg32_file_dlopen(Rt_map *, const char *, int *, int);
-void Dbg64_file_dlopen(Rt_map *, const char *, int *, int);
void Dbg32_file_elf(Lm_list *, const char *, Addr, size_t, const char *,
Aliste);
void Dbg64_file_elf(Lm_list *, const char *, Addr, size_t, const char *,
@@ -402,8 +410,6 @@ void Dbg32_syms_created(Lm_list *, const char *);
void Dbg64_syms_created(Lm_list *, const char *);
void Dbg32_syms_discarded(Lm_list *, Sym_desc *);
void Dbg64_syms_discarded(Lm_list *, Sym_desc *);
-void Dbg32_syms_dlsym(Rt_map *, const char *, int *, const char *, int);
-void Dbg64_syms_dlsym(Rt_map *, const char *, int *, const char *, int);
void Dbg32_syms_entered(Ofl_desc *, Sym *, Sym_desc *);
void Dbg64_syms_entered(Ofl_desc *, Sym *, Sym_desc *);
void Dbg32_syms_entry(Lm_list *, Elf32_Word, Sym_desc *);
diff --git a/usr/src/cmd/sgs/liblddbg/common/mapfile-vers b/usr/src/cmd/sgs/liblddbg/common/mapfile-vers
index bf3dec8e57..3d422b4c18 100644
--- a/usr/src/cmd/sgs/liblddbg/common/mapfile-vers
+++ b/usr/src/cmd/sgs/liblddbg/common/mapfile-vers
@@ -41,7 +41,7 @@
# MAPFILE HEADER END
#
-SUNWprivate_4.77 {
+SUNWprivate_4.78 {
global:
dbg_desc = NODIRECT; # interposed - ld.so.1(1)
dbg_print = NODIRECT; # interposed - ld(1) and ld.so.1(1)
@@ -102,14 +102,28 @@ SUNWprivate_4.77 {
Dbg32_cap_val_entry;
Dbg64_cap_val_entry;
- Dbg32_cb_iphdr_callback;
- Dbg64_cb_iphdr_callback;
- Dbg32_cb_iphdr_enter;
- Dbg64_cb_iphdr_enter;
- Dbg32_cb_iphdr_mapchange;
- Dbg64_cb_iphdr_mapchange;
- Dbg32_cb_iphdr_unmap_ret;
- Dbg64_cb_iphdr_unmap_ret;
+ Dbg32_dl_dladdr;
+ Dbg64_dl_dladdr;
+ Dbg32_dl_dlclose;
+ Dbg64_dl_dlclose;
+ Dbg32_dl_dldump;
+ Dbg64_dl_dldump;
+ Dbg32_dl_dlerror;
+ Dbg64_dl_dlerror;
+ Dbg32_dl_dlinfo;
+ Dbg64_dl_dlinfo;
+ Dbg32_dl_dlopen;
+ Dbg64_dl_dlopen;
+ Dbg32_dl_dlsym;
+ Dbg64_dl_dlsym;
+ Dbg32_dl_iphdr_callback;
+ Dbg64_dl_iphdr_callback;
+ Dbg32_dl_iphdr_enter;
+ Dbg64_dl_iphdr_enter;
+ Dbg32_dl_iphdr_mapchange;
+ Dbg64_dl_iphdr_mapchange;
+ Dbg32_dl_iphdr_unmap_ret;
+ Dbg64_dl_iphdr_unmap_ret;
Dbg32_demangle_name;
Dbg64_demangle_name;
@@ -141,12 +155,6 @@ SUNWprivate_4.77 {
Dbg64_file_del_rescan;
Dbg32_file_delete;
Dbg64_file_delete;
- Dbg32_file_dlclose;
- Dbg64_file_dlclose;
- Dbg32_file_dldump;
- Dbg64_file_dldump;
- Dbg32_file_dlopen;
- Dbg64_file_dlopen;
Dbg32_file_elf;
Dbg64_file_elf;
Dbg32_file_cleanup;
@@ -393,8 +401,6 @@ SUNWprivate_4.77 {
Dbg64_syms_discarded;
Dbg32_syms_dup_discarded;
Dbg64_syms_dup_discarded;
- Dbg32_syms_dlsym;
- Dbg64_syms_dlsym;
Dbg32_syms_dup_sort_addr;
Dbg64_syms_dup_sort_addr;
Dbg32_syms_entered;
diff --git a/usr/src/cmd/sgs/liblddbg/common/syms.c b/usr/src/cmd/sgs/liblddbg/common/syms.c
index 8824caf785..e7a7f5252b 100644
--- a/usr/src/cmd/sgs/liblddbg/common/syms.c
+++ b/usr/src/cmd/sgs/liblddbg/common/syms.c
@@ -25,7 +25,6 @@
*/
#include <stdio.h>
-#include <dlfcn.h>
#include "msg.h"
#include "_debug.h"
#include "libld.h"
@@ -117,57 +116,6 @@ Dbg_syms_ignore_gnuver(Rt_map *lmp, const char *name, Word symndx,
}
void
-Dbg_syms_dlsym(Rt_map *clmp, const char *sym, int *in_nfavl, const char *next,
- int flag)
-{
- const char *str, *retry, *from = NAME(clmp);
- Lm_list *lml = LIST(clmp);
-
- if (DBG_NOTCLASS(DBG_C_SYMBOLS))
- return;
-
- /*
- * The core functionality of dlsym() can be called twice. The first
- * attempt can be affected by path names that exist in the "not-found"
- * AVL tree. Should a "not-found" path name be found, a second attempt
- * is made to locate the required file (in_nfavl is NULL). This fall-
- * back provides for file system changes while a process executes.
- */
- if (in_nfavl)
- retry = MSG_ORIG(MSG_STR_EMPTY);
- else
- retry = MSG_INTL(MSG_STR_RETRY);
-
- switch (flag) {
- case DBG_DLSYM_NEXT:
- str = MSG_ORIG(MSG_SYM_NEXT);
- break;
- case DBG_DLSYM_DEFAULT:
- str = MSG_ORIG(MSG_SYM_DEFAULT);
- break;
- case DBG_DLSYM_SELF:
- str = MSG_ORIG(MSG_SYM_SELF);
- break;
- case DBG_DLSYM_PROBE:
- str = MSG_ORIG(MSG_SYM_PROBE);
- break;
- case DBG_DLSYM_SINGLETON:
- str = MSG_ORIG(MSG_SYM_SINGLETON);
- break;
- default:
- str = MSG_ORIG(MSG_STR_EMPTY);
- }
-
- Dbg_util_nl(lml, DBG_NL_STD);
- if (next == 0)
- dbg_print(lml, MSG_INTL(MSG_SYM_DLSYM_1),
- Dbg_demangle_name(sym), from, retry, str);
- else
- dbg_print(lml, MSG_INTL(MSG_SYM_DLSYM_2),
- Dbg_demangle_name(sym), from, next, retry, str);
-}
-
-void
Dbg_syms_lazy_rescan(Lm_list *lml, const char *name)
{
if (DBG_NOTCLASS(DBG_C_SYMBOLS | DBG_C_FILES))
diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README
index e763ffa2c4..fb1903f50b 100644
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README
+++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README
@@ -1502,6 +1502,7 @@ Bugid Risk Synopsis
pfinstall does it again.
6807050 GNU linkonce sections can create duplicate and incompatible
eh_frame FDE entries
+6826513 ldd gets confused by a crle(1) LD_PRELOAD setting
--------------------------------------------------------------------------------
--------------
@@ -1522,7 +1523,6 @@ Bugid Risk Synopsis
6715578 AOUT (BCP) symbol lookup can be compromised with lazy loading.
6752883 ld.so.1 error message should be buffered (not sent to stderr).
6577982 ld.so.1 calls getpid() before it should when any LD_* are set
-6826513 ldd gets confused by a crle(1) LD_PRELOAD setting
6831285 linker LD_DEBUG support needs improvements (D)
6806791 filter builds could be optimized (link-editor components only)
6823371 calloc() uses suboptimal memset() causing 15% regression in SpecCPU2006
@@ -1574,3 +1574,4 @@ Bugid Risk Synopsis
6934123 elfdump -d coredumps on PA-RISC elf
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64 (D)
6931056 pvs -r output can include empty versions in output
+6938628 ld.so.1 should produce diagnostics for all dl*() entry points
diff --git a/usr/src/cmd/sgs/rtld/common/dlfcns.c b/usr/src/cmd/sgs/rtld/common/dlfcns.c
index 140ff1a65a..376da6e75d 100644
--- a/usr/src/cmd/sgs/rtld/common/dlfcns.c
+++ b/usr/src/cmd/sgs/rtld/common/dlfcns.c
@@ -40,6 +40,7 @@
#include <synch.h>
#include <limits.h>
#include <debug.h>
+#include <conv.h>
#include "_rtld.h"
#include "_audit.h"
#include "_elf.h"
@@ -109,6 +110,8 @@ dlerror()
clmp = _caller(caller(), CL_EXECDEF);
+ DBG_CALL(Dbg_dl_dlerror(clmp, lasterr));
+
error = lasterr;
lasterr = NULL;
@@ -468,10 +471,10 @@ dlclose_core(Grp_hdl *ghp, Rt_map *clmp, Lm_list *lml)
* Diagnose what we're up to.
*/
if (ghp->gh_flags & GPH_ZERO) {
- DBG_CALL(Dbg_file_dlclose(LIST(clmp), MSG_ORIG(MSG_STR_ZERO),
+ DBG_CALL(Dbg_dl_dlclose(clmp, MSG_ORIG(MSG_STR_ZERO),
DBG_DLCLOSE_IGNORE));
} else {
- DBG_CALL(Dbg_file_dlclose(LIST(clmp), NAME(ghp->gh_ownlmp),
+ DBG_CALL(Dbg_dl_dlclose(clmp, NAME(ghp->gh_ownlmp),
DBG_DLCLOSE_NULL));
}
@@ -552,6 +555,11 @@ dlclose_check(void *handle, Rt_map *clmp)
Grp_hdl *ghp = (Grp_hdl *)handle;
if (hdl_validate(ghp) == 0) {
+ Conv_inv_buf_t inv_buf;
+
+ (void) conv_invalid_val(&inv_buf, EC_NATPTR(ghp), 0);
+ DBG_CALL(Dbg_dl_dlclose(clmp, inv_buf.buf, DBG_DLCLOSE_NULL));
+
eprintf(LIST(clmp), ERR_FATAL, MSG_INTL(MSG_ARG_INVHNDL),
EC_NATPTR(handle));
return (1);
@@ -621,7 +629,7 @@ dlmopen_core(Lm_list *lml, Lm_list *olml, const char *path, int mode,
Grp_hdl *ghp;
Aliste olmco, nlmco;
- DBG_CALL(Dbg_file_dlopen(clmp,
+ DBG_CALL(Dbg_dl_dlopen(clmp,
(path ? path : MSG_ORIG(MSG_STR_ZERO)), in_nfavl, mode));
/*
@@ -1226,7 +1234,7 @@ dlsym_core(void *handle, const char *name, Rt_map *clmp, Rt_map **dlmp,
* that the symbol is a singleton, then the search for the
* symbol must follow the default search path.
*/
- DBG_CALL(Dbg_syms_dlsym(clmp, name, in_nfavl, 0,
+ DBG_CALL(Dbg_dl_dlsym(clmp, name, in_nfavl, 0,
DBG_DLSYM_SINGLETON));
sl.sl_imap = hlmp;
@@ -1272,7 +1280,7 @@ dlsym_core(void *handle, const char *name, Rt_map *clmp, Rt_map **dlmp,
*/
sl.sl_imap = nlmp = NEXT_RT_MAP(clmp);
- DBG_CALL(Dbg_syms_dlsym(clmp, name, in_nfavl,
+ DBG_CALL(Dbg_dl_dlsym(clmp, name, in_nfavl,
(nlmp ? NAME(nlmp) : MSG_INTL(MSG_STR_NULL)),
DBG_DLSYM_NEXT));
@@ -1286,7 +1294,7 @@ dlsym_core(void *handle, const char *name, Rt_map *clmp, Rt_map **dlmp,
/*
* If the handle is RTLD_SELF start searching from the caller.
*/
- DBG_CALL(Dbg_syms_dlsym(clmp, name, in_nfavl, NAME(clmp),
+ DBG_CALL(Dbg_dl_dlsym(clmp, name, in_nfavl, NAME(clmp),
DBG_DLSYM_SELF));
sl.sl_imap = clmp;
@@ -1300,7 +1308,7 @@ dlsym_core(void *handle, const char *name, Rt_map *clmp, Rt_map **dlmp,
* If the handle is RTLD_DEFAULT mimic the standard symbol
* lookup as would be triggered by a relocation.
*/
- DBG_CALL(Dbg_syms_dlsym(clmp, name, in_nfavl, 0,
+ DBG_CALL(Dbg_dl_dlsym(clmp, name, in_nfavl, 0,
DBG_DLSYM_DEFAULT));
sl.sl_imap = hlmp;
@@ -1319,7 +1327,7 @@ dlsym_core(void *handle, const char *name, Rt_map *clmp, Rt_map **dlmp,
* loaded to satisfy this request, but no exhaustive lazy load
* rescan is carried out.
*/
- DBG_CALL(Dbg_syms_dlsym(clmp, name, in_nfavl, 0,
+ DBG_CALL(Dbg_dl_dlsym(clmp, name, in_nfavl, 0,
DBG_DLSYM_PROBE));
sl.sl_imap = hlmp;
@@ -1333,7 +1341,7 @@ dlsym_core(void *handle, const char *name, Rt_map *clmp, Rt_map **dlmp,
* Look in the shared object specified by the handle and in all
* of its dependencies.
*/
- DBG_CALL(Dbg_syms_dlsym(clmp, name, in_nfavl,
+ DBG_CALL(Dbg_dl_dlsym(clmp, name, in_nfavl,
NAME(ghp->gh_ownlmp), DBG_DLSYM_DEF));
ret = LM_DLSYM(clmp)(ghp, &sl, &sr, &binfo, in_nfavl);
@@ -1499,21 +1507,21 @@ dlsym(void *handle, const char *name)
* Core dladdr activity.
*/
static void
-dladdr_core(Rt_map *clmp, void *addr, Dl_info_t *dlip, void **info, int flags)
+dladdr_core(Rt_map *almp, void *addr, Dl_info_t *dlip, void **info, int flags)
{
/*
* Set up generic information and any defaults.
*/
- dlip->dli_fname = PATHNAME(clmp);
+ dlip->dli_fname = PATHNAME(almp);
- dlip->dli_fbase = (void *)ADDR(clmp);
+ dlip->dli_fbase = (void *)ADDR(almp);
dlip->dli_sname = NULL;
dlip->dli_saddr = NULL;
/*
* Determine the nearest symbol to this address.
*/
- LM_DLADDR(clmp)((ulong_t)addr, clmp, dlip, info, flags);
+ LM_DLADDR(almp)((ulong_t)addr, almp, dlip, info, flags);
}
#pragma weak _dladdr = dladdr
@@ -1526,21 +1534,25 @@ int
dladdr(void *addr, Dl_info_t *dlip)
{
int entry, error;
- Rt_map *clmp;
+ Rt_map *clmp, *almp;
entry = enter(0);
+ clmp = _caller(caller(), CL_EXECDEF);
+
+ DBG_CALL(Dbg_dl_dladdr(clmp, addr));
+
/*
* Use our calling technique to determine what object is associated
* with the supplied address. If a caller can't be determined,
* indicate the failure.
*/
- if ((clmp = _caller(addr, CL_NONE)) == NULL) {
- eprintf(0, ERR_FATAL, MSG_INTL(MSG_ARG_INVADDR),
+ if ((almp = _caller(addr, CL_NONE)) == NULL) {
+ eprintf(LIST(clmp), ERR_FATAL, MSG_INTL(MSG_ARG_INVADDR),
EC_NATPTR(addr));
error = 0;
} else {
- dladdr_core(clmp, addr, dlip, 0, 0);
+ dladdr_core(almp, addr, dlip, 0, 0);
error = 1;
}
@@ -1554,8 +1566,16 @@ dladdr(void *addr, Dl_info_t *dlip)
int
dladdr1(void *addr, Dl_info_t *dlip, void **info, int flags)
{
- int entry, error = 0;
- Rt_map *clmp;
+ int entry, ret = 1;
+ Rt_map *clmp, *almp;
+ Lm_list *clml;
+
+ entry = enter(0);
+
+ clmp = _caller(caller(), CL_EXECDEF);
+ clml = LIST(clmp);
+
+ DBG_CALL(Dbg_dl_dladdr(clmp, addr));
/*
* Validate any flags.
@@ -1565,50 +1585,51 @@ dladdr1(void *addr, Dl_info_t *dlip, void **info, int flags)
if (((request = (flags & RTLD_DL_MASK)) != RTLD_DL_SYMENT) &&
(request != RTLD_DL_LINKMAP)) {
- eprintf(0, ERR_FATAL, MSG_INTL(MSG_ARG_ILLFLAGS),
+ eprintf(clml, ERR_FATAL, MSG_INTL(MSG_ARG_ILLFLAGS),
flags);
- return (0);
- }
- if (info == NULL) {
- eprintf(0, ERR_FATAL, MSG_INTL(MSG_ARG_ILLINFO), flags);
- return (0);
+ ret = 0;
+
+ } else if (info == NULL) {
+ eprintf(clml, ERR_FATAL, MSG_INTL(MSG_ARG_ILLINFO),
+ flags);
+ ret = 0;
}
}
- entry = enter(0);
-
/*
* Use our calling technique to determine what object is associated
* with the supplied address. If a caller can't be determined,
* indicate the failure.
*/
- if ((clmp = _caller(addr, CL_NONE)) == NULL) {
- eprintf(0, ERR_FATAL, MSG_INTL(MSG_ARG_INVADDR),
- EC_NATPTR(addr));
- error = 0;
- } else {
- dladdr_core(clmp, addr, dlip, info, flags);
- error = 1;
+ if (ret) {
+ if ((almp = _caller(addr, CL_NONE)) == NULL) {
+ eprintf(clml, ERR_FATAL, MSG_INTL(MSG_ARG_INVADDR),
+ EC_NATPTR(addr));
+ ret = 0;
+ } else
+ dladdr_core(almp, addr, dlip, info, flags);
}
if (entry)
- leave(0, 0);
- return (error);
+ leave(clml, 0);
+ return (ret);
}
/*
* Core dldump activity.
*/
static int
-dldump_core(Lm_list *lml, const char *ipath, const char *opath, int flags)
+dldump_core(Rt_map *clmp, Rt_map *lmp, const char *ipath, const char *opath,
+ int flags)
{
+ Lm_list *lml = LIST(clmp);
Addr addr = 0;
- Rt_map *lmp;
/*
* Verify any arguments first.
*/
- if ((!opath || (*opath == '\0')) || (ipath && (*ipath == '\0'))) {
+ if ((opath == NULL) || (opath[0] == '\0') ||
+ ((lmp == NULL) && (ipath[0] == '\0'))) {
eprintf(lml, ERR_FATAL, MSG_INTL(MSG_ARG_ILLPATH));
return (1);
}
@@ -1621,7 +1642,7 @@ dldump_core(Lm_list *lml, const char *ipath, const char *opath, int flags)
* dump objects from alternative link-maps, this model is going to
* have to be revisited.
*/
- if (ipath) {
+ if (lmp == NULL) {
if ((lmp = is_so_loaded(&lml_main, ipath, NULL)) == NULL) {
eprintf(lml, ERR_FATAL, MSG_INTL(MSG_GEN_NOFILE),
ipath);
@@ -1636,11 +1657,7 @@ dldump_core(Lm_list *lml, const char *ipath, const char *opath, int flags)
ipath);
return (1);
}
- } else
- lmp = lml_main.lm_head;
-
-
- DBG_CALL(Dbg_file_dldump(lmp, opath, flags));
+ }
/*
* If the object being dump'ed isn't fixed identify its mapping.
@@ -1670,13 +1687,22 @@ int
dldump(const char *ipath, const char *opath, int flags)
{
int error, entry;
- Rt_map *clmp;
+ Rt_map *clmp, *lmp;
entry = enter(0);
clmp = _caller(caller(), CL_EXECDEF);
- error = dldump_core(LIST(clmp), ipath, opath, flags);
+ if (ipath) {
+ lmp = NULL;
+ } else {
+ lmp = lml_main.lm_head;
+ ipath = NAME(lmp);
+ }
+
+ DBG_CALL(Dbg_dl_dldump(clmp, ipath, opath, flags));
+
+ error = dldump_core(clmp, lmp, ipath, opath, flags);
if (entry)
leave(LIST(clmp), 0);
@@ -1710,9 +1736,35 @@ get_linkmap_id(Lm_list *lml)
static int
dlinfo_core(void *handle, int request, void *p, Rt_map *clmp)
{
- Lm_list *lml = LIST(clmp);
- Rt_map *lmp;
+ Conv_inv_buf_t inv_buf;
+ char *handlename;
+ Lm_list *lml = LIST(clmp);
+ Rt_map *lmp = NULL;
+
+ /*
+ * Determine whether a handle is provided. A handle isn't needed for
+ * all operations, but it is validated here for the initial diagnostic.
+ */
+ if (handle == RTLD_SELF) {
+ lmp = clmp;
+ } else {
+ Grp_hdl *ghp = (Grp_hdl *)handle;
+ if (hdl_validate(ghp))
+ lmp = ghp->gh_ownlmp;
+ }
+ if (lmp) {
+ handlename = NAME(lmp);
+ } else {
+ (void) conv_invalid_val(&inv_buf, EC_NATPTR(handle), 0);
+ handlename = inv_buf.buf;
+ }
+
+ DBG_CALL(Dbg_dl_dlinfo(clmp, handlename, request, p));
+
+ /*
+ * Validate the request and return buffer.
+ */
if ((request > RTLD_DI_MAX) || (p == NULL)) {
eprintf(lml, ERR_FATAL, MSG_INTL(MSG_ARG_ILLVAL));
return (-1);
@@ -1786,17 +1838,10 @@ dlinfo_core(void *handle, int request, void *p, Rt_map *clmp)
/*
* For any other request a link-map is required. Verify the handle.
*/
- if (handle == RTLD_SELF)
- lmp = clmp;
- else {
- Grp_hdl *ghp = (Grp_hdl *)handle;
-
- if (!hdl_validate(ghp)) {
- eprintf(lml, ERR_FATAL, MSG_INTL(MSG_ARG_INVHNDL),
- EC_NATPTR(handle));
- return (-1);
- }
- lmp = ghp->gh_ownlmp;
+ if (lmp == NULL) {
+ eprintf(lml, ERR_FATAL, MSG_INTL(MSG_ARG_INVHNDL),
+ EC_NATPTR(handle));
+ return (-1);
}
/*
@@ -2079,7 +2124,7 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *),
struct dl_phdr_info info;
u_longlong_t l_cnt_map = cnt_map;
u_longlong_t l_cnt_unmap = cnt_unmap;
- Lm_list *lml;
+ Lm_list *lml, *clml;
Lm_cntl *lmc;
Rt_map *lmp, *clmp;
Aliste idx1, idx2;
@@ -2087,10 +2132,11 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *),
int ret = 0;
int entry;
-
entry = enter(0);
- clmp = _caller(caller(), CL_EXECDEF);
- DBG_CALL(Dbg_cb_iphdr_enter(LIST(clmp), cnt_map, cnt_unmap));
+ clmp = _caller(caller(), CL_EXECDEF);
+ clml = LIST(clmp);
+
+ DBG_CALL(Dbg_dl_iphdr_enter(clmp, cnt_map, cnt_unmap));
/* Issue a callback for each ELF object in the process */
for (APLIST_TRAVERSE(dynlm_list, idx1, lml)) {
@@ -2104,7 +2150,6 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *),
if (THIS_IS_NOT_ELF(lmp))
continue;
#endif
-
/* Prepare the object information structure */
ehdr = (Ehdr *) ADDR(lmp);
info.dlpi_addr = (ehdr->e_type == ET_EXEC) ?
@@ -2117,9 +2162,8 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *),
info.dlpi_subs = cnt_unmap;
/* Issue the callback */
- DBG_CALL(Dbg_cb_iphdr_callback(LIST(clmp),
- &info));
- leave(LIST(clmp), thr_flg_reenter);
+ DBG_CALL(Dbg_dl_iphdr_callback(clml, &info));
+ leave(clml, thr_flg_reenter);
ret = (* callback)(&info, sizeof (info), data);
(void) enter(thr_flg_reenter);
@@ -2128,21 +2172,22 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *),
goto done;
/* Adapt to object mapping changes */
- if ((cnt_map != l_cnt_map) ||
- (cnt_unmap != l_cnt_unmap)) {
- DBG_CALL(Dbg_cb_iphdr_mapchange(
- LIST(clmp), cnt_map, cnt_unmap));
-
- /* Stop if an object was unmapped */
- if (cnt_unmap != l_cnt_unmap) {
- ret = -1;
- DBG_CALL(Dbg_cb_iphdr_unmap_ret(
- LIST(clmp)));
- goto done;
- }
+ if ((cnt_map == l_cnt_map) &&
+ (cnt_unmap == l_cnt_unmap))
+ continue;
+
+ DBG_CALL(Dbg_dl_iphdr_mapchange(clml, cnt_map,
+ cnt_unmap));
+ /* Stop if an object was unmapped */
+ if (cnt_unmap == l_cnt_unmap) {
l_cnt_map = cnt_map;
+ continue;
}
+
+ ret = -1;
+ DBG_CALL(Dbg_dl_iphdr_unmap_ret(clml));
+ goto done;
}
}
}