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