map.c revision 4f680cc668fa6cf678c531083400ade9a9c7934c
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/*
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * CDDL HEADER START
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap *
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * The contents of this file are subject to the terms of the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Common Development and Distribution License (the "License").
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * You may not use this file except in compliance with the License.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap *
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * or http://www.opensolaris.org/os/licensing.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * See the License for the specific language governing permissions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * and limitations under the License.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap *
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * When distributing Covered Code, include this CDDL HEADER in each
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * If applicable, add the following below this CDDL HEADER, with the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * fields enclosed by brackets "[]" replaced with your own identifying
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * information: Portions Copyright [yyyy] [name of copyright owner]
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap *
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * CDDL HEADER END
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan/*
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Use is subject to license terms.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap#include "msg.h"
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap#include "_debug.h"
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap#include "libld.h"
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap *Dbg_decl = NULL;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapvoid
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter DunlapDbg_map_set_atsign(Boolean new)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap{
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (DBG_NOTCLASS(DBG_C_MAP))
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (new)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_4);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap else
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_5);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap}
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapvoid
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter DunlapDbg_map_set_equal(Boolean new)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap{
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (DBG_NOTCLASS(DBG_C_MAP))
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (new)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_1);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap else
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_2);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap}
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapvoid
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter DunlapDbg_map_version(Lm_list *lml, const char *version, const char *name, int scope)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap{
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning const char *str, *scp;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_SYMBOLS))
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe str = MSG_INTL(MSG_MAP_SYM_SCOPE);
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe if (scope)
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe scp = MSG_ORIG(MSG_SYM_GLOBAL);
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe else
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap scp = MSG_ORIG(MSG_SYM_LOCAL);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (version)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap dbg_print(lml, MSG_INTL(MSG_MAP_SYM_VER_1), str, version,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap Dbg_demangle_name(name), scp);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap else
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap dbg_print(lml, MSG_INTL(MSG_MAP_SYM_VER_2), str,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap Dbg_demangle_name(name), scp);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap}
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapvoid
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter DunlapDbg_map_size_new(Lm_list *lml, const char *name)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap{
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (DBG_NOTCLASS(DBG_C_MAP))
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap dbg_print(lml, MSG_INTL(MSG_MAP_SYM_SIZE), Dbg_demangle_name(name),
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap MSG_INTL(MSG_STR_ADD));
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap}
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapvoid
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter DunlapDbg_map_size_old(Ofl_desc *ofl, Sym_desc *sdp)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap{
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap Conv_inv_buf_t inv_buf;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap Lm_list *lml = ofl->ofl_lml;
if (DBG_NOTCLASS(DBG_C_MAP))
return;
dbg_print(lml, MSG_INTL(MSG_MAP_SYM_SIZE), sdp->sd_name,
MSG_INTL(MSG_STR_UP_1));
if (DBG_NOTDETAIL())
return;
Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_UP_2),
ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
conv_def_tag(sdp->sd_ref, &inv_buf));
}
void
Dbg_map_symbol(Ofl_desc *ofl, Sym_desc *sdp)
{
Conv_inv_buf_t inv_buf;
Lm_list *lml = ofl->ofl_lml;
if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_SYMBOLS))
return;
if (DBG_NOTDETAIL())
return;
Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_ENTERED),
ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
conv_def_tag(sdp->sd_ref, &inv_buf));
}
void
Dbg_map_dash(Lm_list *lml, const char *name, Sdf_desc *sdf)
{
const char *str;
if (DBG_NOTCLASS(DBG_C_MAP))
return;
if (sdf->sdf_flags & FLG_SDF_SONAME)
str = MSG_INTL(MSG_MAP_CNT_DEF_1);
else
str = MSG_INTL(MSG_MAP_CNT_DEF_2);
dbg_print(lml, str, name, sdf->sdf_soname);
}
void
Dbg_map_sort(Lm_list *lml)
{
if (DBG_NOTCLASS(DBG_C_MAP))
return;
if (DBG_NOTDETAIL())
return;
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_MAP_SORT_TITLE));
}
void
Dbg_map_sort_seg(Lm_list *lml, Sg_desc *sgp, int orig)
{
const char *str;
if (DBG_NOTCLASS(DBG_C_MAP))
return;
if (DBG_NOTDETAIL())
return;
if (sgp->sg_name && *sgp->sg_name)
str = sgp->sg_name;
else
str = MSG_INTL(MSG_STR_NULL);
if (orig)
dbg_print(lml, MSG_INTL(MSG_MAP_SORT_ORIG), str);
else
dbg_print(lml, MSG_INTL(MSG_MAP_SORT_FINAL), str);
}
void
Dbg_map_parse(Lm_list *lml, const char *file)
{
if (DBG_NOTCLASS(DBG_C_MAP))
return;
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_MAP_MAPFILE), file);
}
void
Dbg_map_ent(Lm_list *lml, Boolean new, Ent_desc *enp, Ofl_desc *ofl)
{
if (DBG_NOTCLASS(DBG_C_MAP))
return;
dbg_print(lml, MSG_INTL(MSG_MAP_MAP_DIR));
Dbg_ent_entry(lml, ofl->ofl_dehdr->e_ident[EI_OSABI],
ofl->ofl_dehdr->e_machine, enp);
if (new)
Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_3);
}
void
Dbg_map_pipe(Lm_list *lml, Sg_desc *sgp, const char *sec_name, const Word ndx)
{
if (DBG_NOTCLASS(DBG_C_MAP))
return;
dbg_print(lml, MSG_INTL(MSG_MAP_SEC_ORDER), sgp->sg_name, sec_name,
EC_WORD(ndx));
}
void
Dbg_map_seg(Ofl_desc *ofl, int ndx, Sg_desc *sgp)
{
Lm_list *lml = ofl->ofl_lml;
if (DBG_NOTCLASS(DBG_C_MAP))
return;
if (Dbg_decl) {
dbg_print(lml, MSG_ORIG(MSG_FMT_STR), Dbg_decl);
Dbg_seg_desc_entry(ofl->ofl_lml,
ofl->ofl_dehdr->e_ident[EI_OSABI],
ofl->ofl_dehdr->e_machine, ndx, sgp);
Dbg_util_nl(lml, DBG_NL_STD);
Dbg_decl = NULL;
}
}