2 Copyright (C) 1991 Free Software Foundation, Inc.
4 Written by Steve Chamberlain of Cygnus Support.
6 This file is part of GLD, the Gnu Linker.
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
38 extern char *program_name;
40 extern FILE *ldlex_input_stack;
41 extern char *ldfile_input_filename;
42 extern ld_config_type config;
48 einfo("%P%F: %S %s\n",arg);
53 extern char *sys_errlist[];
58 %S print script file and linenumber
59 %E current bfd error or errno
60 %I filename from a lang_input_statement_type
61 %B filename from a bfd
63 %X no object output, fail return
65 %C Clever filename:linenumber
66 %R info about a relent
75 boolean fatal = false;
77 while (*fmt != '%' && *fmt != '\0') {
85 config.make_executable = false;
89 bfd_vma value = va_arg(arg, bfd_vma);
90 fprintf_vma(fp, value);
95 asymbol *symbol = va_arg(arg, asymbol *);
98 asection *section = symbol->section;
99 CONST char *section_name = section->name;
100 fprintf(fp,"%s (%s)", symbol->name, section_name);
104 fprintf(fp,"no symbol");
110 bfd *abfd = va_arg(arg, bfd *);
111 if (abfd->my_archive) {
112 fprintf(fp,"%s(%s)", abfd->my_archive->filename,
116 fprintf(fp,"%s", abfd->filename);
125 fprintf(fp,"%s", program_name);
128 /* Replace with the most recent errno explanation */
131 fprintf(fp, bfd_errmsg(bfd_error));
137 lang_input_statement_type *i =
138 va_arg(arg,lang_input_statement_type *);
140 fprintf(fp,"%s", i->local_sym_name);
144 /* Print source script file and line number */
146 if (ldlex_input_stack) {
147 extern unsigned int lineno;
148 if (ldfile_input_filename == (char *)NULL) {
149 fprintf(fp,"command line");
152 fprintf(fp,"%s:%u", ldfile_input_filename, lineno );
158 fprintf(fp,"command (just before \"");
160 while (ch != 0 && n < 10) {
161 fprintf(fp, "%c", ch);
171 /* Print all that's interesting about a relent */
173 arelent *relent = va_arg(arg, arelent *);
175 fprintf(fp,"%s+0x%x (type %s)",
176 (*(relent->sym_ptr_ptr))->name,
178 relent->howto->name);
189 CONST char *filename;
190 CONST char *functionname;
191 unsigned int linenumber;
192 bfd *abfd = va_arg(arg, bfd *);
193 asection *section = va_arg(arg, asection *);
194 asymbol **symbols = va_arg(arg, asymbol **);
195 bfd_vma offset = va_arg(arg, bfd_vma);
197 if (bfd_find_nearest_line(abfd,
205 if (filename == (char *)NULL)
206 filename = abfd->filename;
207 if (functionname != (char *)NULL)
208 fprintf(fp,"%s:%u: (%s)", filename, linenumber, functionname);
209 else if (linenumber != 0)
210 fprintf(fp,"%s:%u", filename, linenumber);
212 fprintf(fp,"%s(%s+%0x)", filename,
218 fprintf(fp,"%s(%s+%0x)", abfd->filename,
226 fprintf(fp,"%s", va_arg(arg, char *));
229 fprintf(fp,"%d", va_arg(arg, int));
232 fprintf(fp,"%s", va_arg(arg, char *));
238 extern char *output_filename;
240 unlink(output_filename);
245 /* Format info message and print on stdout. */
253 fmt = va_arg(arg, char *);
254 vfinfo(stdout, fmt, arg);
258 /* ('e' for error.) Format info message and print on stderr. */
266 fmt = va_arg(arg, char *);
267 vfinfo(stderr, fmt, arg);
272 info_assert(file, line)
276 einfo("%F%P internal error %s %d\n", file,line);
279 /* Return a newly-allocated string
280 whose contents concatenate those of S1, S2, S3. */
283 DEFUN(concat, (s1, s2, s3),
288 bfd_size_type len1 = strlen (s1);
289 bfd_size_type len2 = strlen (s2);
290 bfd_size_type len3 = strlen (s3);
291 char *result = ldmalloc (len1 + len2 + len3 + 1);
294 memcpy(result, s1, len1);
296 memcpy(result+len1, s2, len2);
298 memcpy(result+len1+len2, s2, len3);
299 *(result + len1 + len2 + len3) = 0;
307 DEFUN(ldmalloc, (size),
310 PTR result = malloc ((int)size);
312 if (result == (char *)NULL && size != 0)
313 einfo("%F%P virtual memory exhausted\n");
320 char *DEFUN(buystring,(x),
323 bfd_size_type l = strlen(x)+1;
324 char *r = ldmalloc(l);
330 /*----------------------------------------------------------------------
331 Functions to print the link map
335 DEFUN_VOID(print_space)
345 DEFUN(print_address,(value),