1 /* Copyright (C) 1991 Free Software Foundation, Inc.
3 This file is part of GLD, the Gnu Linker.
5 GLD is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 1, or (at your option)
10 GLD is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GLD; see the file COPYING. If not, write to
17 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 info("%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
72 boolean fatal
= false;
75 fmt
= va_arg(arg
, char *);
77 while (*fmt
!= '%' && *fmt
!= '\0') {
85 config
.make_executable
= false;
88 fprintf(stderr
,"%08lx", va_arg(arg
, bfd_vma
));
92 asymbol
*symbol
= va_arg(arg
, asymbol
*);
94 asection
*section
= symbol
->section
;
95 if ((symbol
->flags
& BSF_UNDEFINED
) == 0) {
96 CONST
char *section_name
= section
== (asection
*)NULL
?
97 "absolute" : section
->name
;
98 fprintf(stderr
,"%s (%s)", symbol
->name
, section_name
);
101 fprintf(stderr
,"%s", symbol
->name
);
105 fprintf(stderr
,"no symbol");
111 bfd
*abfd
= va_arg(arg
, bfd
*);
112 if (abfd
->my_archive
) {
113 fprintf(stderr
,"%s(%s)", abfd
->my_archive
->filename
,
117 fprintf(stderr
,"%s", abfd
->filename
);
126 fprintf(stderr
,"%s", program_name
);
129 /* Replace with the most recent errno explanation */
132 fprintf(stderr
, bfd_errmsg(bfd_error
));
138 lang_input_statement_type
*i
=
139 va_arg(arg
,lang_input_statement_type
*);
141 fprintf(stderr
,"%s", i
->local_sym_name
);
145 /* Print source script file and line number */
147 if (ldlex_input_stack
) {
148 extern unsigned int lineno
;
149 if (ldfile_input_filename
== (char *)NULL
) {
150 fprintf(stderr
,"command line");
153 fprintf(stderr
,"%s:%u", ldfile_input_filename
, lineno
);
159 fprintf(stderr
,"command (just before \"");
161 while (ch
!= 0 && n
< 10) {
162 fprintf(stderr
, "%c", ch
);
166 fprintf(stderr
,"\")");
172 CONST
char *filename
;
173 CONST
char *functionname
;
174 unsigned int linenumber
;
175 bfd
*abfd
= va_arg(arg
, bfd
*);
176 asection
*section
= va_arg(arg
, asection
*);
177 asymbol
**symbols
= va_arg(arg
, asymbol
**);
178 bfd_vma offset
= va_arg(arg
, bfd_vma
);
180 if (bfd_find_nearest_line(abfd
,
188 if (filename
== (char *)NULL
)
189 filename
= abfd
->filename
;
190 if (functionname
!= (char *)NULL
)
191 fprintf(stderr
,"%s:%u: (%s)", filename
, linenumber
, functionname
);
192 else if (linenumber
!= 0)
193 fprintf(stderr
,"%s:%u", filename
, linenumber
);
195 fprintf(stderr
,"%s", filename
);
199 fprintf(stderr
,"%s", abfd
->filename
);
205 fprintf(stderr
,"%s", va_arg(arg
, char *));
208 fprintf(stderr
,"%d", va_arg(arg
, int));
211 fprintf(stderr
,"%s", va_arg(arg
, char *));
217 extern char *output_filename
;
219 unlink(output_filename
);
227 info_assert(file
, line
)
231 info("%F%P internal error %s %d\n", file
,line
);
234 /* Return a newly-allocated string
235 whose contents concatenate those of S1, S2, S3. */
238 DEFUN(concat
, (s1
, s2
, s3
),
243 size_t len1
= strlen (s1
);
244 size_t len2
= strlen (s2
);
245 size_t len3
= strlen (s3
);
246 char *result
= ldmalloc (len1
+ len2
+ len3
+ 1);
249 memcpy(result
, s1
, len1
);
251 memcpy(result
+len1
, s2
, len2
);
253 memcpy(result
+len1
+len2
, s2
, len3
);
254 *(result
+ len1
+ len2
+ len3
) = 0;
261 char *ldmalloc (size
)
264 char * result
= malloc (size
);
266 if (result
== (char *)NULL
&& size
!= 0)
267 info("%F%P virtual memory exhausted\n");
274 char *DEFUN(buystring
,(x
),
277 size_t l
= strlen(x
)+1;
278 char *r
= ldmalloc(l
);