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