]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/ldmisc.c
Support APX zero-upper
[thirdparty/binutils-gdb.git] / ld / ldmisc.c
CommitLineData
252b5132 1/* ldmisc.c
fd67aa11 2 Copyright (C) 1991-2024 Free Software Foundation, Inc.
252b5132
RH
3 Written by Steve Chamberlain of Cygnus Support.
4
f96b4a7b 5 This file is part of the GNU Binutils.
252b5132 6
f96b4a7b 7 This program is free software; you can redistribute it and/or modify
5ed6aba4 8 it under the terms of the GNU General Public License as published by
f96b4a7b
NC
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
252b5132 11
f96b4a7b 12 This program is distributed in the hope that it will be useful,
5ed6aba4
NC
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
252b5132 16
5ed6aba4 17 You should have received a copy of the GNU General Public License
f96b4a7b
NC
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
252b5132 21
3db64b00 22#include "sysdep.h"
252b5132 23#include "bfd.h"
6f6f27f8 24#include "bfdlink.h"
252b5132 25#include "libiberty.h"
1ff6de03 26#include "ctf-api.h"
99847db8 27#include "safe-ctype.h"
42627821 28#include "filenames.h"
252b5132 29#include "demangle.h"
252b5132 30#include <stdarg.h>
252b5132
RH
31#include "ld.h"
32#include "ldmisc.h"
33#include "ldexp.h"
34#include "ldlang.h"
df2a7313 35#include <ldgram.h>
252b5132
RH
36#include "ldlex.h"
37#include "ldmain.h"
38#include "ldfile.h"
39
252b5132
RH
40/*
41 %% literal %
d003868e
AM
42 %C clever filename:linenumber with function
43 %D like %C, but no function name
44 %E current bfd error or errno
252b5132 45 %F error is fatal
d003868e 46 %G like %D, but only function name
270396f2 47 %H like %C but in addition emit section+offset
252b5132 48 %P print program name
252b5132 49 %V hex bfd_vma
6b9bd54c 50 %W hex bfd_vma with 0x with no leading zeros taking up 10 spaces
d003868e 51 %X no object output, fail return
252b5132 52 %d integer, like printf
94b50910
AM
53 %ld long, like printf
54 %lu unsigned long, like printf
c386bf4d 55 %lx unsigned long, like printf
5d3236ee 56 %p native (host) void* pointer, like printf
871b3ab2
AM
57 %pA section name from a section
58 %pB filename from a bfd
c1c8c1ef
AM
59 %pI filename from a lang_input_statement_type
60 %pR info about a relent
61 %pS print script file and linenumber from etree_type.
62 %pT symbol name
87870682 63 %pU print script file without linenumber from etree_type.
d003868e 64 %s arbitrary string, like printf
252b5132 65 %u integer, like printf
d003868e 66 %v hex bfd_vma, no leading zeros
c386bf4d 67 %x integer, like printf
252b5132
RH
68*/
69
5d3236ee 70void
f38a2680 71vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
252b5132 72{
f38a2680 73 bool fatal = false;
99847db8
AM
74 const char *scan;
75 int arg_type;
76 unsigned int arg_count = 0;
77 unsigned int arg_no;
78 union vfinfo_args
79 {
80 int i;
81 long l;
82 void *p;
83 bfd_vma v;
84 struct {
85 bfd *abfd;
86 asection *sec;
87 bfd_vma off;
88 } reladdr;
89 enum
90 {
91 Bad,
92 Int,
93 Long,
94 Ptr,
95 Vma,
96 RelAddr
97 } type;
98 } args[9];
99
4b2e7a57
NC
100 if (is_warning && config.no_warnings)
101 return;
102
99847db8
AM
103 for (arg_no = 0; arg_no < sizeof (args) / sizeof (args[0]); arg_no++)
104 args[arg_no].type = Bad;
105
106 arg_count = 0;
107 scan = fmt;
108 while (*scan != '\0')
109 {
110 while (*scan != '%' && *scan != '\0')
111 scan++;
112
113 if (*scan == '%')
114 {
115 scan++;
116
117 arg_no = arg_count;
118 if (*scan != '0' && ISDIGIT (*scan) && scan[1] == '$')
119 {
120 arg_no = *scan - '1';
121 scan += 2;
122 }
123
124 arg_type = Bad;
125 switch (*scan++)
126 {
127 case '\0':
128 --scan;
129 break;
130
131 case 'V':
132 case 'v':
133 case 'W':
134 arg_type = Vma;
135 break;
136
99847db8
AM
137 case 's':
138 arg_type = Ptr;
139 break;
140
871b3ab2 141 case 'p':
c1c8c1ef
AM
142 if (*scan == 'A' || *scan == 'B' || *scan == 'I'
143 || *scan == 'R' || *scan == 'S' || *scan == 'T')
871b3ab2
AM
144 scan++;
145 arg_type = Ptr;
146 break;
147
99847db8
AM
148 case 'C':
149 case 'D':
150 case 'G':
151 case 'H':
152 arg_type = RelAddr;
153 break;
154
155 case 'd':
156 case 'u':
c386bf4d 157 case 'x':
99847db8
AM
158 arg_type = Int;
159 break;
160
161 case 'l':
c386bf4d 162 if (*scan == 'd' || *scan == 'u' || *scan == 'x')
99847db8
AM
163 {
164 ++scan;
165 arg_type = Long;
166 }
167 break;
168
169 default:
170 break;
171 }
172 if (arg_type != Bad)
173 {
174 if (arg_no >= sizeof (args) / sizeof (args[0]))
175 abort ();
176 args[arg_no].type = arg_type;
177 ++arg_count;
178 }
179 }
180 }
252b5132 181
99847db8
AM
182 for (arg_no = 0; arg_no < arg_count; arg_no++)
183 {
184 switch (args[arg_no].type)
185 {
186 case Int:
187 args[arg_no].i = va_arg (ap, int);
188 break;
189 case Long:
190 args[arg_no].l = va_arg (ap, long);
191 break;
192 case Ptr:
193 args[arg_no].p = va_arg (ap, void *);
194 break;
195 case Vma:
196 args[arg_no].v = va_arg (ap, bfd_vma);
197 break;
198 case RelAddr:
199 args[arg_no].reladdr.abfd = va_arg (ap, bfd *);
200 args[arg_no].reladdr.sec = va_arg (ap, asection *);
201 args[arg_no].reladdr.off = va_arg (ap, bfd_vma);
202 break;
203 default:
204 abort ();
205 }
206 }
207
208 arg_count = 0;
252b5132
RH
209 while (*fmt != '\0')
210 {
23916fff 211 const char *str = fmt;
6d5e62f8 212 while (*fmt != '%' && *fmt != '\0')
23916fff
MF
213 fmt++;
214 if (fmt != str)
215 if (fwrite (str, 1, fmt - str, fp))
216 {
217 /* Ignore. */
218 }
252b5132 219
6d5e62f8 220 if (*fmt == '%')
252b5132 221 {
6d5e62f8 222 fmt++;
99847db8
AM
223
224 arg_no = arg_count;
225 if (*fmt != '0' && ISDIGIT (*fmt) && fmt[1] == '$')
226 {
227 arg_no = *fmt - '1';
228 fmt += 2;
229 }
230
6d5e62f8 231 switch (*fmt++)
252b5132 232 {
99847db8
AM
233 case '\0':
234 --fmt;
235 /* Fall through. */
236
252b5132
RH
237 case '%':
238 /* literal % */
239 putc ('%', fp);
240 break;
241
242 case 'X':
243 /* no object output, fail return */
f38a2680 244 config.make_executable = false;
252b5132
RH
245 break;
246
247 case 'V':
248 /* hex bfd_vma */
249 {
6b9bd54c
AM
250 char buf[32];
251 bfd_vma value;
252
253 value = args[arg_no].v;
99847db8 254 ++arg_count;
6b9bd54c
AM
255 bfd_sprintf_vma (link_info.output_bfd, buf, value);
256 fprintf (fp, "%s", buf);
252b5132
RH
257 }
258 break;
259
260 case 'v':
261 /* hex bfd_vma, no leading zeros */
262 {
f493c217 263 uint64_t value = args[arg_no].v;
99847db8 264 ++arg_count;
f493c217 265 fprintf (fp, "%" PRIx64, value);
252b5132
RH
266 }
267 break;
268
269 case 'W':
270 /* hex bfd_vma with 0x with no leading zeroes taking up
6b9bd54c 271 10 spaces (including the 0x). */
252b5132 272 {
6b9bd54c 273 char buf[32];
f493c217 274 uint64_t value;
252b5132 275
99847db8
AM
276 value = args[arg_no].v;
277 ++arg_count;
6b9bd54c
AM
278 sprintf (buf, "0x%" PRIx64, value);
279 fprintf (fp, "%10s", buf);
252b5132
RH
280 }
281 break;
282
252b5132 283 case 'F':
6d5e62f8 284 /* Error is fatal. */
f38a2680 285 fatal = true;
252b5132
RH
286 break;
287
288 case 'P':
6d5e62f8 289 /* Print program name. */
252b5132
RH
290 fprintf (fp, "%s", program_name);
291 break;
292
293 case 'E':
294 /* current bfd error or errno */
305c7206 295 fprintf (fp, "%s", bfd_errmsg (bfd_get_error ()));
252b5132
RH
296 break;
297
252b5132
RH
298 case 'C':
299 case 'D':
300 case 'G':
270396f2 301 case 'H':
5cfb2bb2
AM
302 /* Clever filename:linenumber with function name if possible.
303 The arguments are a BFD, a section, and an offset. */
252b5132
RH
304 {
305 static bfd *last_bfd;
befe814d
MR
306 static char *last_file;
307 static char *last_function;
252b5132
RH
308 bfd *abfd;
309 asection *section;
310 bfd_vma offset;
5c1d2f5f 311 asymbol **asymbols = NULL;
252b5132
RH
312 const char *filename;
313 const char *functionname;
314 unsigned int linenumber;
f38a2680
AM
315 bool discard_last;
316 bool done;
847d5183 317 bfd_error_type last_bfd_error = bfd_get_error ();
252b5132 318
99847db8
AM
319 abfd = args[arg_no].reladdr.abfd;
320 section = args[arg_no].reladdr.sec;
321 offset = args[arg_no].reladdr.off;
322 ++arg_count;
252b5132 323
5c1d2f5f 324 if (abfd != NULL)
252b5132 325 {
5c1d2f5f 326 if (!bfd_generic_link_read_symbols (abfd))
df5f2391 327 einfo (_("%F%P: %pB: could not read symbols: %E\n"), abfd);
5c1d2f5f
AM
328
329 asymbols = bfd_get_outsymbols (abfd);
252b5132
RH
330 }
331
e1fffbe6
AM
332 /* The GNU Coding Standard requires that error messages
333 be of the form:
e4492aa0 334
98d87ee7 335 source-file-name:lineno: message
5cfb2bb2 336
e1fffbe6
AM
337 We do not always have a line number available so if
338 we cannot find them we print out the section name and
270396f2 339 offset instead. */
f38a2680 340 discard_last = true;
e1fffbe6
AM
341 if (abfd != NULL
342 && bfd_find_nearest_line (abfd, section, asymbols, offset,
343 &filename, &functionname,
344 &linenumber))
252b5132 345 {
270396f2
AM
346 if (functionname != NULL
347 && (fmt[-1] == 'C' || fmt[-1] == 'H'))
5cfb2bb2 348 {
e1fffbe6
AM
349 /* Detect the case where we are printing out a
350 message for the same function as the last
351 call to vinfo ("%C"). In this situation do
352 not print out the ABFD filename or the
353 function name again. Note - we do still
354 print out the source filename, as this will
355 allow programs that parse the linker's output
356 (eg emacs) to correctly locate multiple
357 errors in the same source file. */
252b5132 358 if (last_bfd == NULL
252b5132
RH
359 || last_function == NULL
360 || last_bfd != abfd
ebf0b03c 361 || (last_file == NULL) != (filename == NULL)
5cfb2bb2 362 || (filename != NULL
42627821 363 && filename_cmp (last_file, filename) != 0)
252b5132
RH
364 || strcmp (last_function, functionname) != 0)
365 {
df5f2391 366 lfinfo (fp, _("%pB: in function `%pT':\n"),
98d87ee7 367 abfd, functionname);
252b5132
RH
368
369 last_bfd = abfd;
5e2ab612 370 free (last_file);
5cfb2bb2
AM
371 last_file = NULL;
372 if (filename)
373 last_file = xstrdup (filename);
5e2ab612 374 free (last_function);
d1b2b2dc 375 last_function = xstrdup (functionname);
252b5132 376 }
f38a2680 377 discard_last = false;
252b5132 378 }
98d87ee7 379 else
871b3ab2 380 lfinfo (fp, "%pB:", abfd);
5cfb2bb2
AM
381
382 if (filename != NULL)
a1c16379 383 fprintf (fp, "%s:", filename);
5cfb2bb2 384
270396f2 385 done = fmt[-1] != 'H';
5cfb2bb2 386 if (functionname != NULL && fmt[-1] == 'G')
c1c8c1ef 387 lfinfo (fp, "%pT", functionname);
a1c16379 388 else if (filename != NULL && linenumber != 0)
18ff9b9b 389 fprintf (fp, "%u%s", linenumber, done ? "" : ":");
a1c16379 390 else
f38a2680 391 done = false;
252b5132 392 }
98d87ee7 393 else
270396f2 394 {
871b3ab2 395 lfinfo (fp, "%pB:", abfd);
f38a2680 396 done = false;
270396f2
AM
397 }
398 if (!done)
871b3ab2 399 lfinfo (fp, "(%pA+0x%v)", section, offset);
847d5183 400 bfd_set_error (last_bfd_error);
252b5132
RH
401
402 if (discard_last)
403 {
404 last_bfd = NULL;
5e2ab612
AM
405 free (last_file);
406 last_file = NULL;
407 free (last_function);
408 last_function = NULL;
252b5132
RH
409 }
410 }
411 break;
6d5e62f8 412
5d3236ee 413 case 'p':
871b3ab2
AM
414 if (*fmt == 'A')
415 {
416 /* section name from a section */
417 asection *sec;
418 bfd *abfd;
871b3ab2
AM
419
420 fmt++;
421 sec = (asection *) args[arg_no].p;
422 ++arg_count;
871b3ab2 423 fprintf (fp, "%s", sec->name);
cb7f4b29
AM
424 abfd = sec->owner;
425 if (abfd != NULL)
426 {
427 const char *group = bfd_group_name (abfd, sec);
428 if (group != NULL)
429 fprintf (fp, "[%s]", group);
430 }
871b3ab2
AM
431 }
432 else if (*fmt == 'B')
433 {
434 /* filename from a bfd */
435 bfd *abfd = (bfd *) args[arg_no].p;
436
437 fmt++;
438 ++arg_count;
439 if (abfd == NULL)
440 fprintf (fp, "%s generated", program_name);
441 else if (abfd->my_archive != NULL
442 && !bfd_is_thin_archive (abfd->my_archive))
607b4833
AM
443 fprintf (fp, "%s(%s)",
444 bfd_get_filename (abfd->my_archive),
445 bfd_get_filename (abfd));
871b3ab2 446 else
607b4833 447 fprintf (fp, "%s", bfd_get_filename (abfd));
871b3ab2 448 }
c1c8c1ef
AM
449 else if (*fmt == 'I')
450 {
451 /* filename from a lang_input_statement_type */
452 lang_input_statement_type *i;
453
454 fmt++;
455 i = (lang_input_statement_type *) args[arg_no].p;
456 ++arg_count;
727a29ba
AM
457 if (i->the_bfd != NULL
458 && i->the_bfd->my_archive != NULL
c1c8c1ef 459 && !bfd_is_thin_archive (i->the_bfd->my_archive))
607b4833
AM
460 fprintf (fp, "(%s)%s",
461 bfd_get_filename (i->the_bfd->my_archive),
727a29ba
AM
462 i->local_sym_name);
463 else
464 fprintf (fp, "%s", i->filename);
c1c8c1ef
AM
465 }
466 else if (*fmt == 'R')
467 {
468 /* Print all that's interesting about a relent. */
469 arelent *relent = (arelent *) args[arg_no].p;
470
471 fmt++;
472 ++arg_count;
473 lfinfo (fp, "%s+0x%v (type %s)",
474 (*(relent->sym_ptr_ptr))->name,
475 relent->addend,
476 relent->howto->name);
477 }
87870682 478 else if (*fmt == 'S' || *fmt == 'U')
c1c8c1ef 479 {
87870682 480 /* Print script file and perhaps the associated linenumber. */
c1c8c1ef
AM
481 etree_type node;
482 etree_type *tp = (etree_type *) args[arg_no].p;
483
484 fmt++;
485 ++arg_count;
486 if (tp == NULL)
487 {
488 tp = &node;
489 tp->type.filename = ldlex_filename ();
490 tp->type.lineno = lineno;
491 }
87870682 492 if (tp->type.filename != NULL && fmt[-1] == 'S')
c1c8c1ef 493 fprintf (fp, "%s:%u", tp->type.filename, tp->type.lineno);
87870682
JL
494 else if (tp->type.filename != NULL && fmt[-1] == 'U')
495 fprintf (fp, "%s", tp->type.filename);
c1c8c1ef
AM
496 }
497 else if (*fmt == 'T')
498 {
499 /* Symbol name. */
500 const char *name = (const char *) args[arg_no].p;
501
502 fmt++;
503 ++arg_count;
504 if (name == NULL || *name == 0)
505 {
506 fprintf (fp, _("no symbol"));
507 break;
508 }
509 else if (demangling)
510 {
511 char *demangled;
512
513 demangled = bfd_demangle (link_info.output_bfd, name,
514 DMGL_ANSI | DMGL_PARAMS);
515 if (demangled != NULL)
516 {
517 fprintf (fp, "%s", demangled);
518 free (demangled);
519 break;
520 }
521 }
522 fprintf (fp, "%s", name);
523 }
871b3ab2
AM
524 else
525 {
526 /* native (host) void* pointer, like printf */
527 fprintf (fp, "%p", args[arg_no].p);
528 ++arg_count;
529 }
5d3236ee
DK
530 break;
531
252b5132
RH
532 case 's':
533 /* arbitrary string, like printf */
99847db8
AM
534 fprintf (fp, "%s", (char *) args[arg_no].p);
535 ++arg_count;
252b5132
RH
536 break;
537
538 case 'd':
539 /* integer, like printf */
99847db8
AM
540 fprintf (fp, "%d", args[arg_no].i);
541 ++arg_count;
252b5132
RH
542 break;
543
544 case 'u':
545 /* unsigned integer, like printf */
99847db8
AM
546 fprintf (fp, "%u", args[arg_no].i);
547 ++arg_count;
252b5132 548 break;
94b50910 549
c386bf4d
NC
550 case 'x':
551 /* unsigned integer, like printf */
552 fprintf (fp, "%x", args[arg_no].i);
553 ++arg_count;
554 break;
555
94b50910
AM
556 case 'l':
557 if (*fmt == 'd')
558 {
99847db8
AM
559 fprintf (fp, "%ld", args[arg_no].l);
560 ++arg_count;
94b50910
AM
561 ++fmt;
562 break;
563 }
564 else if (*fmt == 'u')
565 {
99847db8
AM
566 fprintf (fp, "%lu", args[arg_no].l);
567 ++arg_count;
94b50910
AM
568 ++fmt;
569 break;
570 }
c386bf4d
NC
571 else if (*fmt == 'x')
572 {
573 fprintf (fp, "%lx", args[arg_no].l);
574 ++arg_count;
575 ++fmt;
576 break;
577 }
370dfff4 578 /* Fallthru */
94b50910
AM
579
580 default:
581 fprintf (fp, "%%%c", fmt[-1]);
582 break;
252b5132
RH
583 }
584 }
585 }
586
59ef2528 587 if (is_warning && config.fatal_warnings)
f38a2680 588 config.make_executable = false;
7ce691ae 589
b34976b6 590 if (fatal)
6d5e62f8 591 xexit (1);
252b5132
RH
592}
593
6d5e62f8 594/* Format info message and print on stdout. */
252b5132
RH
595
596/* (You would think this should be called just "info", but then you
1579bae1 597 would be hosed by LynxOS, which defines that name in its libc.) */
252b5132
RH
598
599void
1579bae1 600info_msg (const char *fmt, ...)
252b5132 601{
1579bae1 602 va_list arg;
252b5132 603
1579bae1 604 va_start (arg, fmt);
f38a2680 605 vfinfo (stdout, fmt, arg, false);
1579bae1 606 va_end (arg);
252b5132
RH
607}
608
6d5e62f8 609/* ('e' for error.) Format info message and print on stderr. */
252b5132
RH
610
611void
1579bae1 612einfo (const char *fmt, ...)
252b5132 613{
1579bae1 614 va_list arg;
252b5132 615
e922bcab 616 fflush (stdout);
1579bae1 617 va_start (arg, fmt);
f38a2680 618 vfinfo (stderr, fmt, arg, true);
1579bae1 619 va_end (arg);
e922bcab 620 fflush (stderr);
252b5132
RH
621}
622
3eb33b88
L
623/* The buffer size for each command-line option warning. */
624#define CMDLINE_WARNING_SIZE 256
625
626/* A linked list of command-line option warnings. */
627
628struct cmdline_warning_list
629{
630 struct cmdline_warning_list *next;
631 char *warning;
632};
633
634/* The head of the linked list of command-line option warnings. */
635static struct cmdline_warning_list *cmdline_warning_head = NULL;
636
637/* The tail of the linked list of command-line option warnings. */
638static struct cmdline_warning_list **cmdline_warning_tail
639 = &cmdline_warning_head;
640
641/* Queue an unknown command-line option warning. */
642
643void
644queue_unknown_cmdline_warning (const char *fmt, ...)
645{
646 va_list arg;
647 struct cmdline_warning_list *warning_ptr
648 = xmalloc (sizeof (*warning_ptr));
649 warning_ptr->warning = xmalloc (CMDLINE_WARNING_SIZE);
650 warning_ptr->next = NULL;
651 int written;
652
653 va_start (arg, fmt);
654 written = vsnprintf (warning_ptr->warning, CMDLINE_WARNING_SIZE, fmt,
655 arg);
656 if (written < 0 || written >= CMDLINE_WARNING_SIZE)
657 {
658 /* If vsnprintf fails or truncates, output the warning directly. */
659 fflush (stdout);
660 va_start (arg, fmt);
661 vfinfo (stderr, fmt, arg, true);
662 fflush (stderr);
663 }
664 else
665 {
666 *cmdline_warning_tail = warning_ptr;
667 cmdline_warning_tail = &warning_ptr->next;
668 }
669 va_end (arg);
670}
671
672/* Output queued unknown command-line option warnings. */
673
674void
675output_unknown_cmdline_warnings (void)
676{
677 struct cmdline_warning_list *list = cmdline_warning_head;
678 struct cmdline_warning_list *next;
679 if (list == NULL)
680 return;
681
682 fflush (stdout);
683
684 for (; list != NULL; list = next)
685 {
686 next = list->next;
687 if (config.fatal_warnings)
688 einfo (_("%P: error: unsupported option: %s\n"), list->warning);
689 else
690 einfo (_("%P: warning: %s ignored\n"), list->warning);
691 free (list->warning);
692 free (list);
693 }
694
695 fflush (stderr);
696}
697
6d5e62f8 698void
1579bae1 699info_assert (const char *file, unsigned int line)
252b5132
RH
700{
701 einfo (_("%F%P: internal error %s %d\n"), file, line);
702}
703
6d5e62f8 704/* ('m' for map) Format info message and print on map. */
252b5132
RH
705
706void
1579bae1 707minfo (const char *fmt, ...)
252b5132 708{
49fa1e15
AM
709 if (config.map_file != NULL)
710 {
711 va_list arg;
252b5132 712
49fa1e15 713 va_start (arg, fmt);
16e4ecc0
AM
714 if (fmt[0] == '%' && fmt[1] == '!' && fmt[2] == 0)
715 {
716 /* Stash info about --as-needed shared libraries. Print
717 later so they don't appear intermingled with archive
718 library info. */
719 struct asneeded_minfo *m = xmalloc (sizeof *m);
720
721 m->next = NULL;
722 m->soname = va_arg (arg, const char *);
723 m->ref = va_arg (arg, bfd *);
724 m->name = va_arg (arg, const char *);
725 *asneeded_list_tail = m;
726 asneeded_list_tail = &m->next;
727 }
728 else
f38a2680 729 vfinfo (config.map_file, fmt, arg, false);
49fa1e15
AM
730 va_end (arg);
731 }
252b5132
RH
732}
733
734void
1579bae1 735lfinfo (FILE *file, const char *fmt, ...)
252b5132 736{
1579bae1 737 va_list arg;
252b5132 738
1579bae1 739 va_start (arg, fmt);
f38a2680 740 vfinfo (file, fmt, arg, false);
1579bae1 741 va_end (arg);
252b5132
RH
742}
743\f
744/* Functions to print the link map. */
745
6d5e62f8 746void
6b9bd54c 747print_spaces (int count)
252b5132 748{
6b9bd54c 749 fprintf (config.map_file, "%*s", count, "");
252b5132
RH
750}
751
6d5e62f8 752void
1579bae1 753print_nl (void)
252b5132
RH
754{
755 fprintf (config.map_file, "\n");
756}
45455cdd
ILT
757
758/* A more or less friendly abort message. In ld.h abort is defined to
759 call this function. */
760
761void
1579bae1 762ld_abort (const char *file, int line, const char *fn)
45455cdd
ILT
763{
764 if (fn != NULL)
7ac01895 765 einfo (_("%P: internal error: aborting at %s:%d in %s\n"),
45455cdd
ILT
766 file, line, fn);
767 else
7ac01895 768 einfo (_("%P: internal error: aborting at %s:%d\n"),
45455cdd 769 file, line);
df5f2391 770 einfo (_("%F%P: please report this bug\n"));
45455cdd
ILT
771 xexit (1);
772}