dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / sgs / liblddbg / common / files.c
blob39482c6d362389ff319c6a16b9cdd73535287a4d
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
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"
38 void
39 Dbg_file_analyze(Rt_map *lmp)
41 Conv_dl_mode_buf_t dl_mode_buf;
42 Lm_list *lml = LIST(lmp);
44 if (DBG_NOTCLASS(DBG_C_FILES))
45 return;
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));
52 void
53 Dbg_file_mmapobj(Lm_list *lml, const char *name, mmapobj_result_t *ompp,
54 uint_t onum)
56 mmapobj_result_t *mpp;
57 uint_t mnum;
59 if (DBG_NOTCLASS(DBG_C_FILES))
60 return;
61 if (DBG_NOTDETAIL())
62 return;
64 Dbg_util_nl(lml, DBG_NL_STD);
65 dbg_print(lml, MSG_INTL(MSG_FIL_MMAPOBJ), name, onum);
67 for (mnum = 0, mpp = ompp; mnum < onum; mnum++, mpp++) {
68 const char *str;
69 uint_t type = MR_GET_TYPE(mpp->mr_flags);
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);
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));
85 Dbg_util_nl(lml, DBG_NL_STD);
88 void
89 Dbg_file_aout(Lm_list *lml, const char *name, Addr addr, size_t size,
90 const char *lmid, Aliste lmco)
92 if (DBG_NOTCLASS(DBG_C_FILES))
93 return;
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));
100 void
101 Dbg_file_elf(Lm_list *lml, const char *name, Addr addr, size_t size,
102 const char *lmid, Aliste lmco)
104 const char *str;
106 if (DBG_NOTCLASS(DBG_C_FILES))
107 return;
109 if (addr == 0)
110 str = MSG_INTL(MSG_STR_TEMPORARY);
111 else
112 str = MSG_ORIG(MSG_STR_EMPTY);
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));
119 void
120 Dbg_file_ldso(Rt_map *lmp, char **envp, auxv_t *auxv, const char *lmid,
121 Aliste lmco)
123 Lm_list *lml = LIST(lmp);
125 if (DBG_NOTCLASS(DBG_C_FILES))
126 return;
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);
139 void
140 Dbg_file_prot(Rt_map *lmp, int prot)
142 Lm_list *lml = LIST(lmp);
144 if (DBG_NOTCLASS(DBG_C_FILES))
145 return;
147 Dbg_util_nl(lml, DBG_NL_STD);
148 dbg_print(lml, MSG_INTL(MSG_FIL_PROT), NAME(lmp), (prot ? '+' : '-'));
151 void
152 Dbg_file_delete(Rt_map *lmp)
154 Lm_list *lml = LIST(lmp);
156 if (DBG_NOTCLASS(DBG_C_FILES))
157 return;
159 Dbg_util_nl(lml, DBG_NL_STD);
160 dbg_print(lml, MSG_INTL(MSG_FIL_DELETE), NAME(lmp));
163 static int hdl_title = 0;
164 static Msg hdl_str = 0;
166 void
167 Dbg_file_hdl_title(int type)
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) */
177 if (DBG_NOTCLASS(DBG_C_FILES))
178 return;
179 if (DBG_NOTDETAIL())
180 return;
183 * Establish a binding title for later use in Dbg_file_hdl_action.
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;
194 void
195 Dbg_file_hdl_collect(Grp_hdl *ghp, const char *name)
197 Conv_grphdl_flags_buf_t grphdl_flags_buf;
198 Lm_list *lml = ghp->gh_ownlml;
199 const char *str;
201 if (DBG_NOTCLASS(DBG_C_FILES))
202 return;
203 if (DBG_NOTDETAIL())
204 return;
206 if (ghp->gh_ownlmp)
207 str = NAME(ghp->gh_ownlmp);
208 else
209 str = MSG_INTL(MSG_STR_ORPHAN);
211 if (hdl_title) {
212 hdl_title = 0;
213 Dbg_util_nl(lml, DBG_NL_STD);
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));
222 void
223 Dbg_file_hdl_action(Grp_hdl *ghp, Rt_map *lmp, int type, uint_t flags)
225 Conv_grpdesc_flags_buf_t grpdesc_flags_buf;
226 const char *mode, *group;
227 Lm_list *lml = LIST(lmp);
228 Msg str;
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) */
239 if (DBG_NOTCLASS(DBG_C_FILES))
240 return;
241 if (DBG_NOTDETAIL())
242 return;
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;
251 * Protect ourselves in case this handle has no
252 * originating owner.
254 if (ghp->gh_ownlmp)
255 name = NAME(ghp->gh_ownlmp);
256 else
257 name = MSG_INTL(MSG_STR_UNKNOWN);
259 dbg_print(lml, MSG_INTL(hdl_str), name,
260 conv_grphdl_flags(ghp->gh_flags, &grphdl_flags_buf),
261 EC_NATPTR(ghp));
263 hdl_title = 0;
267 * Establish a binding descriptor format string.
269 if (type > DBG_DEP_REINST)
270 return;
272 str = fmt[type];
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);
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);
289 dbg_print(lml, MSG_INTL(str), NAME(lmp), mode, group);
292 void
293 Dbg_file_bind_entry(Lm_list *lml, Bnd_desc *bdp)
295 Conv_bnd_type_buf_t bnd_type_buf;
297 if (DBG_NOTCLASS(DBG_C_FILES))
298 return;
299 if (DBG_NOTDETAIL())
300 return;
303 * Print the dependency together with the modes of the binding.
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));
311 void
312 Dbg_file_bindings(Rt_map *lmp, int flag)
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;
321 if (DBG_NOTCLASS(DBG_C_INIT))
322 return;
323 if (DBG_NOTDETAIL())
324 return;
326 if (flag & RT_SORT_REV)
327 str = MSG_ORIG(MSG_SCN_INIT);
328 else
329 str = MSG_ORIG(MSG_SCN_FINI);
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));
335 /* LINTED */
336 for (tlmp = lmp; tlmp; tlmp = (Rt_map *)NEXT(tlmp)) {
337 Bnd_desc *bdp;
338 Aliste idx;
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.
347 if (flag & RT_SORT_REV) {
348 if ((FLAGS(tlmp) & (FLG_RT_RELOCED |
349 FLG_RT_INITCLCT)) != FLG_RT_RELOCED)
350 continue;
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;
362 if (next++)
363 Dbg_util_nl(lml, DBG_NL_STD);
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));
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));
378 Dbg_util_nl(lml, DBG_NL_STD);
381 void
382 Dbg_file_bindings_done(Lm_list *lml)
384 if (DBG_NOTCLASS(DBG_C_INIT))
385 return;
386 if (DBG_NOTDETAIL())
387 return;
389 DBG_CALL(Dbg_util_nl(lml, DBG_NL_STD));
392 void
393 Dbg_file_lazyload(Rt_map *clmp, const char *fname, const char *sname)
395 Lm_list *lml = LIST(clmp);
397 if (DBG_NOTCLASS(DBG_C_FILES))
398 return;
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));
405 void
406 Dbg_file_preload(Lm_list *lml, const char *name)
408 if (DBG_NOTCLASS(DBG_C_FILES))
409 return;
411 Dbg_util_nl(lml, DBG_NL_STD);
412 dbg_print(lml, MSG_INTL(MSG_FIL_PRELOAD), name);
415 void
416 Dbg_file_needed(Rt_map *lmp, const char *name)
418 Lm_list *lml = LIST(lmp);
420 if (DBG_NOTCLASS(DBG_C_FILES))
421 return;
423 Dbg_util_nl(lml, DBG_NL_STD);
424 dbg_print(lml, MSG_INTL(MSG_FIL_NEEDED), name, NAME(lmp));
427 void
428 Dbg_file_filter(Lm_list *lml, const char *filter, const char *filtee,
429 int config)
431 if (DBG_NOTCLASS(DBG_C_FILES))
432 return;
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);
441 void
442 Dbg_file_filtee(Lm_list *lml, const char *filter, const char *filtee, int audit)
444 if (DBG_NOTCLASS(DBG_C_FILES))
445 return;
447 Dbg_util_nl(lml, DBG_NL_STD);
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);
457 void
458 Dbg_file_fixname(Lm_list *lml, const char *oname, const char *nname)
460 if (DBG_NOTCLASS(DBG_C_FILES))
461 return;
463 Dbg_util_nl(lml, DBG_NL_STD);
464 dbg_print(lml, MSG_INTL(MSG_FIL_FIXNAME), oname, nname);
467 void
468 Dbg_file_output(Ofl_desc *ofl)
470 const char *prefix = MSG_ORIG(MSG_PTH_OBJECT);
471 char *oname, *nname, *ofile;
472 int fd;
474 if (DBG_NOTCLASS(DBG_C_FILES))
475 return;
476 if (DBG_NOTDETAIL())
477 return;
480 * Obtain the present input object filename for concatenation to the
481 * prefix name.
483 oname = (char *)ofl->ofl_name;
484 if ((ofile = strrchr(oname, '/')) == NULL)
485 ofile = oname;
486 else
487 ofile++;
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.
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);
502 free(nname);
506 void
507 Dbg_file_config_dis(Lm_list *lml, const char *config, int features)
509 Conv_config_feat_buf_t config_feat_buf;
510 const char *str;
512 if (features == 0)
513 return;
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;
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);
541 void
542 Dbg_file_config_obj(Lm_list *lml, const char *dir, const char *file,
543 const char *config)
545 char *name, _name[PATH_MAX];
547 if (DBG_NOTCLASS(DBG_C_FILES))
548 return;
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;
557 dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG), name, config);
560 void
561 Dbg_file_del_rescan(Lm_list *lml)
563 if (DBG_NOTCLASS(DBG_C_FILES))
564 return;
566 Dbg_util_nl(lml, DBG_NL_STD);
567 dbg_print(lml, MSG_INTL(MSG_FIL_DEL_RESCAN));
570 void
571 Dbg_file_mode_promote(Rt_map *lmp, int mode)
573 Conv_dl_mode_buf_t dl_mode_buf;
574 Lm_list *lml = LIST(lmp);
576 if (DBG_NOTCLASS(DBG_C_FILES))
577 return;
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);
585 void
586 Dbg_file_deferred(Lm_list *lml, const char *oname, const char *nname)
588 if (DBG_NOTCLASS(DBG_C_FILES))
589 return;
591 Dbg_util_nl(lml, DBG_NL_STD);
592 dbg_print(lml, MSG_INTL(MSG_FIL_DEFERRED), oname, nname);
595 void
596 Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco)
598 Lm_cntl *lmc;
599 Aliste off;
601 if (DBG_NOTCLASS(DBG_C_FILES))
602 return;
603 if (DBG_NOTDETAIL())
604 return;
606 Dbg_util_nl(lml, DBG_NL_STD);
607 dbg_print(lml, MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco),
608 EC_XWORD(tlmco));
610 for (ALIST_TRAVERSE_BY_OFFSET(lml->lm_lists, off, lmc)) {
611 Rt_map *lmp;
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));
618 Dbg_util_nl(lml, DBG_NL_STD);
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.
626 void
627 Dbg_file_ar_rescan(Lm_list *lml, int argv_start_ndx, int argv_end_ndx)
629 if (DBG_NOTCLASS(DBG_C_FILES))
630 return;
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);
638 void
639 Dbg_file_ar(Lm_list *lml, const char *name, Boolean again)
641 const char *str;
643 if (DBG_NOTCLASS(DBG_C_FILES))
644 return;
646 if (again)
647 str = MSG_INTL(MSG_STR_AGAIN);
648 else
649 str = MSG_ORIG(MSG_STR_EMPTY);
651 Dbg_util_nl(lml, DBG_NL_STD);
652 dbg_print(lml, MSG_INTL(MSG_FIL_ARCHIVE), name, str);
655 void
656 Dbg_file_generic(Lm_list *lml, Ifl_desc *ifl)
658 Conv_inv_buf_t inv_buf;
660 if (DBG_NOTCLASS(DBG_C_FILES))
661 return;
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));
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) */
691 void
692 Dbg_file_rejected(Lm_list *lml, Rej_desc *rej, Half mach)
694 Conv_reject_desc_buf_t rej_buf;
696 if (DBG_NOTCLASS(DBG_C_FILES))
697 return;
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);
706 void
707 Dbg_file_reuse(Lm_list *lml, const char *nname, const char *oname)
709 if (DBG_NOTCLASS(DBG_C_FILES))
710 return;
712 Dbg_util_nl(lml, DBG_NL_STD);
713 dbg_print(lml, MSG_INTL(MSG_FIL_REUSE), nname, oname);
716 void
717 Dbg_file_skip(Lm_list *lml, const char *oname, const char *nname)
719 if (DBG_NOTCLASS(DBG_C_FILES))
720 return;
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);
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)
732 const char *str;
734 if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_SUPPORT))
735 return;
736 if (DBG_NOTDETAIL())
737 return;
739 Dbg_util_nl(lml, DBG_NL_STD);
740 dbg_print(lml, MSG_INTL(MSG_FIL_MODIFIED), oname, obj);
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);
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);
759 Dbg_util_nl(lml, DBG_NL_STD);
762 void
763 Dbg_file_cleanup(Lm_list *lml, const char *name, Aliste lmco)
765 if (DBG_NOTCLASS(DBG_C_FILES))
766 return;
768 Dbg_util_nl(lml, DBG_NL_STD);
769 dbg_print(lml, MSG_INTL(MSG_FIL_CLEANUP), name, EC_XWORD(lmco));