xref: /titanic_51/usr/src/cmd/sgs/liblddbg/common/files.c (revision 80e2ca8596e3435bc3b76f3c597833ea0a87f85e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include	<sys/auxv.h>
28 #include	<string.h>
29 #include	<unistd.h>
30 #include	<fcntl.h>
31 #include	<limits.h>
32 #include	<stdio.h>
33 #include	<libld.h>
34 #include	<rtld.h>
35 #include	<conv.h>
36 #include	"msg.h"
37 #include	"_debug.h"
38 
39 void
40 Dbg_file_analyze(Rt_map *lmp)
41 {
42 	Conv_dl_mode_buf_t	dl_mode_buf;
43 	Lm_list			*lml = LIST(lmp);
44 
45 	if (DBG_NOTCLASS(DBG_C_FILES))
46 		return;
47 
48 	Dbg_util_nl(lml, DBG_NL_STD);
49 	dbg_print(lml, MSG_INTL(MSG_FIL_ANALYZE), NAME(lmp),
50 	    conv_dl_mode(MODE(lmp), 1, &dl_mode_buf));
51 }
52 
53 void
54 Dbg_file_mmapobj(Lm_list *lml, const char *name, mmapobj_result_t *ompp,
55     uint_t onum)
56 {
57 	mmapobj_result_t	*mpp;
58 	uint_t			mnum;
59 
60 	if (DBG_NOTCLASS(DBG_C_FILES))
61 		return;
62 	if (DBG_NOTDETAIL())
63 		return;
64 
65 	Dbg_util_nl(lml, DBG_NL_STD);
66 	dbg_print(lml, MSG_INTL(MSG_FIL_MMAPOBJ), name, onum);
67 
68 	for (mnum = 0, mpp = ompp; mnum < onum; mnum++, mpp++) {
69 		const char	*str;
70 		uint_t		type = MR_GET_TYPE(mpp->mr_flags);
71 
72 		if (type == MR_PADDING)
73 			str = MSG_ORIG(MSG_MR_PADDING);
74 		else if (type == MR_HDR_ELF)
75 			str = MSG_ORIG(MSG_MR_HDR_ELF);
76 		else if (type == MR_HDR_AOUT)
77 			str = MSG_ORIG(MSG_MR_HDR_AOUT);
78 		else
79 			str = MSG_ORIG(MSG_STR_EMPTY);
80 
81 		dbg_print(lml, MSG_INTL(MSG_FIL_MMAPOBJ_1), mnum,
82 		    EC_NATPTR(mpp->mr_addr), EC_OFF(mpp->mr_fsize), str);
83 		dbg_print(lml, MSG_INTL(MSG_FIL_MMAPOBJ_2),
84 		    EC_OFF(mpp->mr_offset), EC_OFF(mpp->mr_msize));
85 	}
86 	Dbg_util_nl(lml, DBG_NL_STD);
87 }
88 
89 void
90 Dbg_file_aout(Lm_list *lml, const char *name, Addr addr, size_t size,
91     const char *lmid, Aliste lmco)
92 {
93 	if (DBG_NOTCLASS(DBG_C_FILES))
94 		return;
95 
96 	dbg_print(lml, MSG_INTL(MSG_FIL_AOUT), name);
97 	dbg_print(lml, MSG_INTL(MSG_FIL_DATA_AS), EC_ADDR(addr), EC_OFF(size));
98 	dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco));
99 }
100 
101 void
102 Dbg_file_elf(Lm_list *lml, const char *name, Addr addr, size_t size,
103     const char *lmid, Aliste lmco)
104 {
105 	const char	*str;
106 
107 	if (DBG_NOTCLASS(DBG_C_FILES))
108 		return;
109 
110 	if (addr == 0)
111 		str = MSG_INTL(MSG_STR_TEMPORARY);
112 	else
113 		str = MSG_ORIG(MSG_STR_EMPTY);
114 
115 	dbg_print(lml, MSG_INTL(MSG_FIL_ELF), name, str);
116 	dbg_print(lml, MSG_INTL(MSG_FIL_DATA_AS), EC_ADDR(addr), EC_OFF(size));
117 	dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco));
118 }
119 
120 void
121 Dbg_file_ldso(Rt_map *lmp, char **envp, auxv_t *auxv, const char *lmid,
122     Aliste lmco)
123 {
124 	Lm_list	*lml = LIST(lmp);
125 
126 	if (DBG_NOTCLASS(DBG_C_FILES))
127 		return;
128 
129 	Dbg_util_nl(lml, DBG_NL_STD);
130 	dbg_print(lml, MSG_INTL(MSG_FIL_LDSO), PATHNAME(lmp));
131 	dbg_print(lml, MSG_INTL(MSG_FIL_DATA_AS), EC_ADDR(ADDR(lmp)),
132 	    EC_OFF(MSIZE(lmp)));
133 	dbg_print(lml, MSG_INTL(MSG_FIL_DATA_EA), EC_NATPTR(envp),
134 	    EC_NATPTR(auxv));
135 	dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco));
136 	Dbg_util_nl(lml, DBG_NL_STD);
137 }
138 
139 
140 void
141 Dbg_file_prot(Rt_map *lmp, int prot)
142 {
143 	Lm_list	*lml = LIST(lmp);
144 
145 	if (DBG_NOTCLASS(DBG_C_FILES))
146 		return;
147 
148 	Dbg_util_nl(lml, DBG_NL_STD);
149 	dbg_print(lml, MSG_INTL(MSG_FIL_PROT), NAME(lmp), (prot ? '+' : '-'));
150 }
151 
152 void
153 Dbg_file_delete(Rt_map *lmp)
154 {
155 	Lm_list	*lml = LIST(lmp);
156 
157 	if (DBG_NOTCLASS(DBG_C_FILES))
158 		return;
159 
160 	Dbg_util_nl(lml, DBG_NL_STD);
161 	dbg_print(lml, MSG_INTL(MSG_FIL_DELETE), NAME(lmp));
162 }
163 
164 static int	hdl_title = 0;
165 static Msg	hdl_str = 0;
166 
167 void
168 Dbg_file_hdl_title(int type)
169 {
170 	static const Msg titles[] = {
171 		MSG_FIL_HDL_CREATE,	/* MSG_INTL(MSG_FIL_HDL_CREATE) */
172 		MSG_FIL_HDL_ADD,	/* MSG_INTL(MSG_FIL_HDL_ADD) */
173 		MSG_FIL_HDL_DELETE,	/* MSG_INTL(MSG_FIL_HDL_DELETE) */
174 		MSG_FIL_HDL_ORPHAN,	/* MSG_INTL(MSG_FIL_HDL_ORPHAN) */
175 		MSG_FIL_HDL_REINST,	/* MSG_INTL(MSG_FIL_HDL_REINST) */
176 	};
177 
178 	if (DBG_NOTCLASS(DBG_C_FILES))
179 		return;
180 	if (DBG_NOTDETAIL())
181 		return;
182 
183 	/*
184 	 * Establish a binding title for later use in Dbg_file_hdl_action.
185 	 */
186 	if (type <= DBG_HDL_REINST) {
187 		hdl_str = titles[type];
188 		hdl_title = 1;
189 	} else {
190 		hdl_str = 0;
191 		hdl_title = 0;
192 	}
193 }
194 
195 void
196 Dbg_file_hdl_collect(Grp_hdl *ghp, const char *name)
197 {
198 	Conv_grphdl_flags_buf_t	grphdl_flags_buf;
199 	Lm_list		*lml = ghp->gh_ownlml;
200 	const char	*str;
201 
202 	if (DBG_NOTCLASS(DBG_C_FILES))
203 		return;
204 	if (DBG_NOTDETAIL())
205 		return;
206 
207 	if (ghp->gh_ownlmp)
208 		str = NAME(ghp->gh_ownlmp);
209 	else
210 		str = MSG_INTL(MSG_STR_ORPHAN);
211 
212 	if (hdl_title) {
213 		hdl_title = 0;
214 		Dbg_util_nl(lml, DBG_NL_STD);
215 	}
216 	if (name)
217 		dbg_print(lml, MSG_INTL(MSG_FIL_HDL_RETAIN), str, name);
218 	else
219 		dbg_print(lml, MSG_INTL(MSG_FIL_HDL_COLLECT), str,
220 		    conv_grphdl_flags(ghp->gh_flags, &grphdl_flags_buf));
221 }
222 
223 void
224 Dbg_file_hdl_action(Grp_hdl *ghp, Rt_map *lmp, int type, uint_t flags)
225 {
226 	Conv_grpdesc_flags_buf_t grpdesc_flags_buf;
227 	const char	*mode, *group;
228 	Lm_list		*lml = LIST(lmp);
229 	Msg		str;
230 
231 	static const Msg fmt[] = {
232 		MSG_FIL_DEP_ADD,	/* MSG_INTL(MSG_FIL_DEP_ADD) */
233 		MSG_FIL_DEP_UPDATE,	/* MSG_INTL(MSG_FIL_DEP_UPDATE) */
234 		MSG_FIL_DEP_DELETE,	/* MSG_INTL(MSG_FIL_DEP_DELETE) */
235 		MSG_FIL_DEP_REMOVE,	/* MSG_INTL(MSG_FIL_DEP_REMOVE) */
236 		MSG_FIL_DEP_REMAIN,	/* MSG_INTL(MSG_FIL_DEP_REMAIN) */
237 		MSG_FIL_DEP_ORPHAN,	/* MSG_INTL(MSG_FIL_DEP_ORPHAN) */
238 		MSG_FIL_DEP_REINST,	/* MSG_INTL(MSG_FIL_DEP_REINST) */
239 	};
240 	if (DBG_NOTCLASS(DBG_C_FILES))
241 		return;
242 	if (DBG_NOTDETAIL())
243 		return;
244 
245 	if (hdl_title) {
246 		Dbg_util_nl(lml, DBG_NL_STD);
247 		if (hdl_str) {
248 			Conv_grphdl_flags_buf_t grphdl_flags_buf;
249 			const char	*name;
250 
251 			/*
252 			 * Protect ourselves in case this handle has no
253 			 * originating owner.
254 			 */
255 			if (ghp->gh_ownlmp)
256 				name = NAME(ghp->gh_ownlmp);
257 			else
258 				name = MSG_INTL(MSG_STR_UNKNOWN);
259 
260 			dbg_print(lml, MSG_INTL(hdl_str), name,
261 			    conv_grphdl_flags(ghp->gh_flags, &grphdl_flags_buf),
262 			    EC_NATPTR(ghp));
263 		}
264 		hdl_title = 0;
265 	}
266 
267 	/*
268 	 * Establish a binding descriptor format string.
269 	 */
270 	if (type > DBG_DEP_REINST)
271 		return;
272 
273 	str = fmt[type];
274 
275 	if (((type == DBG_DEP_ADD) || (type == DBG_DEP_UPDATE)) && flags)
276 		group = conv_grpdesc_flags(flags, &grpdesc_flags_buf);
277 	else
278 		group = MSG_ORIG(MSG_STR_EMPTY);
279 
280 	if ((MODE(lmp) & (RTLD_GLOBAL | RTLD_NODELETE)) ==
281 	    (RTLD_GLOBAL | RTLD_NODELETE))
282 		mode = MSG_ORIG(MSG_MODE_GLOBNODEL);
283 	else if (MODE(lmp) & RTLD_GLOBAL)
284 		mode = MSG_ORIG(MSG_MODE_GLOB);
285 	else if (MODE(lmp) & RTLD_NODELETE)
286 		mode = MSG_ORIG(MSG_MODE_NODEL);
287 	else
288 		mode = MSG_ORIG(MSG_STR_EMPTY);
289 
290 	dbg_print(lml, MSG_INTL(str), NAME(lmp), mode, group);
291 }
292 
293 void
294 Dbg_file_bind_entry(Lm_list *lml, Bnd_desc *bdp)
295 {
296 	Conv_bnd_type_buf_t bnd_type_buf;
297 
298 	if (DBG_NOTCLASS(DBG_C_FILES))
299 		return;
300 	if (DBG_NOTDETAIL())
301 		return;
302 
303 	/*
304 	 * Print the dependency together with the modes of the binding.
305 	 */
306 	Dbg_util_nl(lml, DBG_NL_STD);
307 	dbg_print(lml, MSG_INTL(MSG_FIL_BND_ADD), NAME(bdp->b_caller));
308 	dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), NAME(bdp->b_depend),
309 	    conv_bnd_type(bdp->b_flags, &bnd_type_buf));
310 }
311 
312 void
313 Dbg_file_bindings(Rt_map *lmp, int flag)
314 {
315 	Conv_bnd_obj_buf_t	bnd_obj_buf;
316 	Conv_bnd_type_buf_t	bnd_type_buf;
317 	const char	*str;
318 	Rt_map		*tlmp;
319 	Lm_list		*lml = LIST(lmp);
320 	int		next = 0;
321 
322 	if (DBG_NOTCLASS(DBG_C_INIT))
323 		return;
324 	if (DBG_NOTDETAIL())
325 		return;
326 
327 	if (flag & RT_SORT_REV)
328 		str = MSG_ORIG(MSG_SCN_INIT);
329 	else
330 		str = MSG_ORIG(MSG_SCN_FINI);
331 
332 	Dbg_util_nl(lml, DBG_NL_STD);
333 	dbg_print(lml, MSG_INTL(MSG_FIL_DEP_TITLE), str,
334 	    conv_bnd_obj(lml->lm_flags, &bnd_obj_buf));
335 
336 	/* LINTED */
337 	for (tlmp = lmp; tlmp; tlmp = (Rt_map *)NEXT(tlmp)) {
338 		Bnd_desc	*bdp;
339 		Aliste		idx;
340 
341 		/*
342 		 * For .init processing, only collect objects that have been
343 		 * relocated and haven't already been collected.
344 		 * For .fini processing, only collect objects that have had
345 		 * their .init collected, and haven't already been .fini
346 		 * collected.
347 		 */
348 		if (flag & RT_SORT_REV) {
349 			if ((FLAGS(tlmp) & (FLG_RT_RELOCED |
350 			    FLG_RT_INITCLCT)) != FLG_RT_RELOCED)
351 				continue;
352 
353 		} else {
354 			if ((flag & RT_SORT_DELETE) &&
355 			    ((FLAGS(tlmp) & FLG_RT_DELETE) == 0))
356 				continue;
357 			if (((FLAGS(tlmp) &
358 			    (FLG_RT_INITCLCT | FLG_RT_FINICLCT)) ==
359 			    FLG_RT_INITCLCT) == 0)
360 				continue;
361 		}
362 
363 		if (next++)
364 			Dbg_util_nl(lml, DBG_NL_STD);
365 
366 		if (DEPENDS(tlmp) == NULL)
367 			dbg_print(lml, MSG_INTL(MSG_FIL_DEP_NONE), NAME(tlmp));
368 		else {
369 			dbg_print(lml, MSG_INTL(MSG_FIL_DEP_ENT), NAME(tlmp));
370 
371 			for (APLIST_TRAVERSE(DEPENDS(tlmp), idx, bdp)) {
372 				dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE),
373 				    NAME(bdp->b_depend),
374 				    conv_bnd_type(bdp->b_flags,
375 				    &bnd_type_buf));
376 			}
377 		}
378 	}
379 	Dbg_util_nl(lml, DBG_NL_STD);
380 }
381 
382 void
383 Dbg_file_bindings_done(Lm_list *lml)
384 {
385 	if (DBG_NOTCLASS(DBG_C_INIT))
386 		return;
387 	if (DBG_NOTDETAIL())
388 		return;
389 
390 	DBG_CALL(Dbg_util_nl(lml, DBG_NL_STD));
391 }
392 
393 void
394 Dbg_file_lazyload(Rt_map *clmp, const char *fname, const char *sname)
395 {
396 	Lm_list	*lml = LIST(clmp);
397 
398 	if (DBG_NOTCLASS(DBG_C_FILES))
399 		return;
400 
401 	Dbg_util_nl(lml, DBG_NL_STD);
402 	dbg_print(lml, MSG_INTL(MSG_FIL_LAZYLOAD), fname, NAME(clmp),
403 	    Dbg_demangle_name(sname));
404 }
405 
406 void
407 Dbg_file_preload(Lm_list *lml, const char *name)
408 {
409 	if (DBG_NOTCLASS(DBG_C_FILES))
410 		return;
411 
412 	Dbg_util_nl(lml, DBG_NL_STD);
413 	dbg_print(lml, MSG_INTL(MSG_FIL_PRELOAD), name);
414 }
415 
416 void
417 Dbg_file_needed(Rt_map *lmp, const char *name)
418 {
419 	Lm_list	*lml = LIST(lmp);
420 
421 	if (DBG_NOTCLASS(DBG_C_FILES))
422 		return;
423 
424 	Dbg_util_nl(lml, DBG_NL_STD);
425 	dbg_print(lml, MSG_INTL(MSG_FIL_NEEDED), name, NAME(lmp));
426 }
427 
428 void
429 Dbg_file_filter(Lm_list *lml, const char *filter, const char *filtee,
430     int config)
431 {
432 	if (DBG_NOTCLASS(DBG_C_FILES))
433 		return;
434 
435 	Dbg_util_nl(lml, DBG_NL_STD);
436 	if (config)
437 		dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_1), filter, filtee);
438 	else
439 		dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_2), filter, filtee);
440 }
441 
442 void
443 Dbg_file_filtee(Lm_list *lml, const char *filter, const char *filtee, int audit)
444 {
445 	if (audit) {
446 		if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES))
447 			return;
448 
449 		Dbg_util_nl(lml, DBG_NL_STD);
450 		dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_3), filtee);
451 	} else {
452 		if (DBG_NOTCLASS(DBG_C_FILES))
453 			return;
454 
455 		Dbg_util_nl(lml, DBG_NL_STD);
456 		if (filter)
457 			dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_1), filtee,
458 			    filter);
459 		else
460 			dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_2), filtee);
461 	}
462 }
463 
464 void
465 Dbg_file_fixname(Lm_list *lml, const char *oname, const char *nname)
466 {
467 	if (DBG_NOTCLASS(DBG_C_FILES))
468 		return;
469 
470 	Dbg_util_nl(lml, DBG_NL_STD);
471 	dbg_print(lml, MSG_INTL(MSG_FIL_FIXNAME), oname, nname);
472 }
473 
474 void
475 Dbg_file_output(Ofl_desc *ofl)
476 {
477 	const char	*prefix = MSG_ORIG(MSG_PTH_OBJECT);
478 	char		*oname, *nname, *ofile;
479 	int		fd;
480 
481 	if (DBG_NOTCLASS(DBG_C_FILES))
482 		return;
483 	if (DBG_NOTDETAIL())
484 		return;
485 
486 	/*
487 	 * Obtain the present input object filename for concatenation to the
488 	 * prefix name.
489 	 */
490 	oname = (char *)ofl->ofl_name;
491 	if ((ofile = strrchr(oname, '/')) == NULL)
492 		ofile = oname;
493 	else
494 		ofile++;
495 
496 	/*
497 	 * Concatenate the prefix with the object filename, open the file and
498 	 * write out the present Elf memory image.  As this is debugging we
499 	 * ignore all errors.
500 	 */
501 	if ((nname = malloc(strlen(prefix) + strlen(ofile) + 1)) != 0) {
502 		(void) strcpy(nname, prefix);
503 		(void) strcat(nname, ofile);
504 		if ((fd = open(nname, O_RDWR | O_CREAT | O_TRUNC,
505 		    0666)) != -1) {
506 			(void) write(fd, ofl->ofl_nehdr, ofl->ofl_size);
507 			(void) close(fd);
508 		}
509 		free(nname);
510 	}
511 }
512 
513 void
514 Dbg_file_config_dis(Lm_list *lml, const char *config, int features)
515 {
516 	Conv_config_feat_buf_t	config_feat_buf;
517 	const char		*str;
518 
519 	if (features == 0)
520 		return;
521 
522 	switch (features & ~CONF_FEATMSK) {
523 	case DBG_CONF_IGNORE:
524 		str = MSG_INTL(MSG_FIL_CONFIG_ERR_1);
525 		break;
526 	case DBG_CONF_VERSION:
527 		str = MSG_INTL(MSG_FIL_CONFIG_ERR_2);
528 		break;
529 	case DBG_CONF_PRCFAIL:
530 		str = MSG_INTL(MSG_FIL_CONFIG_ERR_3);
531 		break;
532 	case DBG_CONF_CORRUPT:
533 		str = MSG_INTL(MSG_FIL_CONFIG_ERR_4);
534 		break;
535 	case DBG_CONF_ABIMISMATCH:
536 		str = MSG_INTL(MSG_FIL_CONFIG_ERR_5);
537 		break;
538 	default:
539 		str = conv_config_feat(features, &config_feat_buf);
540 		break;
541 	}
542 
543 	Dbg_util_nl(lml, DBG_NL_FRC);
544 	dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG_ERR), config, str);
545 	Dbg_util_nl(lml, DBG_NL_FRC);
546 }
547 
548 void
549 Dbg_file_config_obj(Lm_list *lml, const char *dir, const char *file,
550     const char *config)
551 {
552 	char	*name, _name[PATH_MAX];
553 
554 	if (DBG_NOTCLASS(DBG_C_FILES))
555 		return;
556 
557 	if (file) {
558 		(void) snprintf(_name, PATH_MAX, MSG_ORIG(MSG_FMT_PATH),
559 		    dir, file);
560 		name = _name;
561 	} else
562 		name = (char *)dir;
563 
564 	dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG), name, config);
565 }
566 
567 void
568 Dbg_file_del_rescan(Lm_list *lml)
569 {
570 	if (DBG_NOTCLASS(DBG_C_FILES))
571 		return;
572 
573 	Dbg_util_nl(lml, DBG_NL_STD);
574 	dbg_print(lml, MSG_INTL(MSG_FIL_DEL_RESCAN));
575 }
576 
577 void
578 Dbg_file_mode_promote(Rt_map *lmp, int mode)
579 {
580 	Conv_dl_mode_buf_t	dl_mode_buf;
581 	Lm_list			*lml = LIST(lmp);
582 
583 	if (DBG_NOTCLASS(DBG_C_FILES))
584 		return;
585 
586 	Dbg_util_nl(lml, DBG_NL_STD);
587 	dbg_print(lml, MSG_INTL(MSG_FIL_PROMOTE), NAME(lmp),
588 	    conv_dl_mode(mode, 0, &dl_mode_buf));
589 	Dbg_util_nl(lml, DBG_NL_STD);
590 }
591 
592 void
593 Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco)
594 {
595 	Lm_cntl	*lmc;
596 	Aliste	off;
597 
598 	if (DBG_NOTCLASS(DBG_C_FILES))
599 		return;
600 	if (DBG_NOTDETAIL())
601 		return;
602 
603 	Dbg_util_nl(lml, DBG_NL_STD);
604 	dbg_print(lml, MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco),
605 	    EC_XWORD(tlmco));
606 
607 	for (ALIST_TRAVERSE_BY_OFFSET(lml->lm_lists, off, lmc)) {
608 		Rt_map	*lmp;
609 
610 		/* LINTED */
611 		for (lmp = lmc->lc_head; lmp; lmp = (Rt_map *)NEXT(lmp))
612 			dbg_print(lml, MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off),
613 			    NAME(lmp));
614 	}
615 	Dbg_util_nl(lml, DBG_NL_STD);
616 }
617 
618 /*
619  * Report archive rescan operation.
620  *	argv_start_ndx, argv_end_ndx - Index range of command line arguments
621  *		from which archives are to be reprocessed.
622  */
623 void
624 Dbg_file_ar_rescan(Lm_list *lml, int argv_start_ndx, int argv_end_ndx)
625 {
626 	if (DBG_NOTCLASS(DBG_C_FILES))
627 		return;
628 
629 	Dbg_util_nl(lml, DBG_NL_STD);
630 	dbg_print(lml, MSG_INTL(MSG_FIL_AR_RESCAN),
631 	    argv_start_ndx, argv_end_ndx);
632 	Dbg_util_nl(lml, DBG_NL_STD);
633 }
634 
635 void
636 Dbg_file_ar(Lm_list *lml, const char *name, int again)
637 {
638 	const char	*str;
639 
640 	if (DBG_NOTCLASS(DBG_C_FILES))
641 		return;
642 
643 	if (again)
644 		str = MSG_INTL(MSG_STR_AGAIN);
645 	else
646 		str = MSG_ORIG(MSG_STR_EMPTY);
647 
648 	Dbg_util_nl(lml, DBG_NL_STD);
649 	dbg_print(lml, MSG_INTL(MSG_FIL_ARCHIVE), name, str);
650 }
651 
652 void
653 Dbg_file_generic(Lm_list *lml, Ifl_desc *ifl)
654 {
655 	Conv_inv_buf_t inv_buf;
656 
657 	if (DBG_NOTCLASS(DBG_C_FILES))
658 		return;
659 
660 	Dbg_util_nl(lml, DBG_NL_STD);
661 	dbg_print(lml, MSG_INTL(MSG_FIL_BASIC), ifl->ifl_name,
662 	    conv_ehdr_type(ifl->ifl_ehdr->e_ident[EI_OSABI],
663 	    ifl->ifl_ehdr->e_type, 0, &inv_buf));
664 }
665 
666 static const Msg
667 reject[] = {
668 	MSG_STR_EMPTY,
669 	MSG_REJ_MACH,		/* MSG_INTL(MSG_REJ_MACH) */
670 	MSG_REJ_CLASS,		/* MSG_INTL(MSG_REJ_CLASS) */
671 	MSG_REJ_DATA,		/* MSG_INTL(MSG_REJ_DATA) */
672 	MSG_REJ_TYPE,		/* MSG_INTL(MSG_REJ_TYPE) */
673 	MSG_REJ_BADFLAG,	/* MSG_INTL(MSG_REJ_BADFLAG) */
674 	MSG_REJ_MISFLAG,	/* MSG_INTL(MSG_REJ_MISFLAG) */
675 	MSG_REJ_VERSION,	/* MSG_INTL(MSG_REJ_VERSION) */
676 	MSG_REJ_HAL,		/* MSG_INTL(MSG_REJ_HAL) */
677 	MSG_REJ_US3,		/* MSG_INTL(MSG_REJ_US3) */
678 	MSG_REJ_STR,		/* MSG_INTL(MSG_REJ_STR) */
679 	MSG_REJ_UNKFILE,	/* MSG_INTL(MSG_REJ_UNKFILE) */
680 	MSG_REJ_UNKCAP,		/* MSG_INTL(MSG_REJ_UNKCAP) */
681 	MSG_REJ_HWCAP_1,	/* MSG_INTL(MSG_REJ_HWCAP_1) */
682 	MSG_REJ_SFCAP_1,	/* MSG_INTL(MSG_REJ_SFCAP_1) */
683 	MSG_REJ_MACHCAP,	/* MSG_INTL(MSG_REJ_MACHCAP) */
684 	MSG_REJ_PLATCAP,	/* MSG_INTL(MSG_REJ_PLATCAP) */
685 	MSG_REJ_HWCAP_2		/* MSG_INTL(MSG_REJ_HWCAP_2) */
686 };
687 
688 void
689 Dbg_file_rejected(Lm_list *lml, Rej_desc *rej, Half mach)
690 {
691 	Conv_reject_desc_buf_t rej_buf;
692 
693 	if (DBG_NOTCLASS(DBG_C_FILES))
694 		return;
695 
696 	Dbg_util_nl(lml, DBG_NL_STD);
697 	dbg_print(lml, MSG_INTL(reject[rej->rej_type]), rej->rej_name ?
698 	    rej->rej_name : MSG_INTL(MSG_STR_UNKNOWN),
699 	    conv_reject_desc(rej, &rej_buf, mach));
700 	Dbg_util_nl(lml, DBG_NL_STD);
701 }
702 
703 void
704 Dbg_file_reuse(Lm_list *lml, const char *nname, const char *oname)
705 {
706 	if (DBG_NOTCLASS(DBG_C_FILES))
707 		return;
708 
709 	dbg_print(lml, MSG_INTL(MSG_FIL_REUSE), nname, oname);
710 }
711 
712 void
713 Dbg_file_skip(Lm_list *lml, const char *oname, const char *nname)
714 {
715 	if (DBG_NOTCLASS(DBG_C_FILES))
716 		return;
717 
718 	if (oname && strcmp(nname, oname))
719 		dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_1), nname, oname);
720 	else
721 		dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_2), nname);
722 }
723 
724 void
725 Dbg_file_modified(Lm_list *lml, const char *obj, const char *oname,
726     const char *nname, int ofd, int nfd, Elf *oelf, Elf *nelf)
727 {
728 	const char	*str;
729 
730 	if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_SUPPORT))
731 		return;
732 	if (DBG_NOTDETAIL())
733 		return;
734 
735 	Dbg_util_nl(lml, DBG_NL_STD);
736 	dbg_print(lml, MSG_INTL(MSG_FIL_MODIFIED), oname, obj);
737 
738 	if (nname != oname)
739 		dbg_print(lml, MSG_INTL(MSG_FIL_NAMECHANGE), nname);
740 	if (nfd != ofd) {
741 		if (nfd == -1)
742 			str = MSG_INTL(MSG_FIL_IGNORE);
743 		else
744 			str = MSG_ORIG(MSG_STR_EMPTY);
745 		dbg_print(lml, MSG_INTL(MSG_FIL_FDCHANGE), ofd, nfd, str);
746 	}
747 	if (nelf != oelf) {
748 		if (nelf == 0)
749 			str = MSG_INTL(MSG_FIL_IGNORE);
750 		else
751 			str = MSG_ORIG(MSG_STR_EMPTY);
752 		dbg_print(lml, MSG_INTL(MSG_FIL_ELFCHANGE), EC_NATPTR(oelf),
753 		    EC_NATPTR(nelf), str);
754 	}
755 	Dbg_util_nl(lml, DBG_NL_STD);
756 }
757 
758 void
759 Dbg_file_cleanup(Lm_list *lml, const char *name, Aliste lmco)
760 {
761 	if (DBG_NOTCLASS(DBG_C_FILES))
762 		return;
763 
764 	Dbg_util_nl(lml, DBG_NL_STD);
765 	dbg_print(lml, MSG_INTL(MSG_FIL_CLEANUP), name, EC_XWORD(lmco));
766 }
767