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