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. */
23 * Revision 1.1 1991/03/21 21:28:55 gumby
26 * Revision 1.2 1991/03/15 18:45:55 rich
29 * Revision 1.1 1991/03/13 00:48:30 chrisb
32 * Revision 1.7 1991/03/10 09:31:34 rich
34 * Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
35 * ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
36 * ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
37 * ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
38 * ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
40 * As of this round of changes, ld now builds on all hosts of (Intel960)
41 * interest and copy passes my copy test on big endian hosts again.
43 * Revision 1.6 1991/03/09 03:31:01 sac
44 * After a fatal info message, the output file is deleted.
46 * Revision 1.5 1991/03/06 21:59:54 sac
47 * Made %C print function name if available
49 * Revision 1.4 1991/03/06 02:27:45 sac
50 * Added support for linenumber printing via %C
52 * Revision 1.3 1991/02/22 17:15:03 sac
53 * Added RCS keywords and copyrights
72 extern char *program_name
;
74 extern FILE *ldlex_input_stack
;
75 extern char *ldfile_input_filename
;
76 extern ld_config_type config
;
82 info("%P%F: %S %s\n",arg
);
87 extern char *sys_errlist
[];
92 %S print script file and linenumber
93 %E current bfd error or errno
94 %I filename from a lang_input_statement_type
95 %B filename from a bfd
97 %X no object output, fail return
99 %C Clever filename:linenumber
106 boolean fatal
= false;
109 fmt
= va_arg(arg
, char *);
111 while (*fmt
!= '%' && *fmt
!= '\0') {
119 config
.make_executable
= false;
122 fprintf(stderr
,"%08lx", va_arg(arg
, bfd_vma
));
126 asymbol
*symbol
= va_arg(arg
, asymbol
*);
128 asection
*section
= symbol
->section
;
129 if ((symbol
->flags
& BSF_UNDEFINED
) == 0) {
130 char *section_name
= section
== (asection
*)NULL
?
131 "absolute" : section
->name
;
132 fprintf(stderr
,"%s (%s)", symbol
->name
, section_name
);
135 fprintf(stderr
,"%s", symbol
->name
);
139 fprintf(stderr
,"no symbol");
145 bfd
*abfd
= va_arg(arg
, bfd
*);
146 if (abfd
->my_archive
) {
147 fprintf(stderr
,"%s(%s)", abfd
->my_archive
->filename
,
151 fprintf(stderr
,"%s", abfd
->filename
);
160 fprintf(stderr
,"%s", program_name
);
163 /* Replace with the most recent errno explanation */
166 fprintf(stderr
, bfd_errmsg(bfd_error
));
172 lang_input_statement_type
*i
=
173 va_arg(arg
,lang_input_statement_type
*);
175 fprintf(stderr
,"%s", i
->local_sym_name
);
179 /* Print source script file and line number */
181 if (ldlex_input_stack
) {
182 extern unsigned int lineno
;
183 if (ldfile_input_filename
== (char *)NULL
) {
184 fprintf(stderr
,"command line");
187 fprintf(stderr
,"%s:%u", ldfile_input_filename
, lineno
+ 1);
191 fprintf(stderr
,"command line ");
198 unsigned int linenumber
;
199 bfd
*abfd
= va_arg(arg
, bfd
*);
200 asection
*section
= va_arg(arg
, asection
*);
201 asymbol
**symbols
= va_arg(arg
, asymbol
**);
202 bfd_vma offset
= va_arg(arg
, bfd_vma
);
204 if (bfd_find_nearest_line(abfd
,
212 if (filename
== (char *)NULL
)
213 filename
= abfd
->filename
;
214 if (functionname
!= (char *)NULL
)
215 fprintf(stderr
,"%s:%u: (%s)", filename
, linenumber
, functionname
);
216 else if (linenumber
!= 0)
217 fprintf(stderr
,"%s:%u", filename
, linenumber
);
219 fprintf(stderr
,"%s", filename
);
223 fprintf(stderr
,"%s", abfd
->filename
);
229 fprintf(stderr
,"%s", va_arg(arg
, char *));
232 fprintf(stderr
,"%d", va_arg(arg
, int));
235 fprintf(stderr
,"%s", va_arg(arg
, char *));
241 extern char *output_filename
;
243 unlink(output_filename
);
251 info_assert(file
, line
)
255 info("%F%P internal error %s %d\n", file
,line
);
258 /* Return a newly-allocated string
259 whose contents concatenate those of S1, S2, S3. */
265 size_t len1
= strlen (s1
);
266 size_t len2
= strlen (s2
);
267 size_t len3
= strlen (s3
);
268 char *result
= ldmalloc (len1
+ len2
+ len3
+ 1);
271 memcpy(result
, s1
, len1
);
273 memcpy(result
+len1
, s2
, len2
);
275 memcpy(result
+len1
+len2
, s2
, len3
);
276 *(result
+ len1
+ len2
+ len3
) = 0;
283 char *ldmalloc (size
)
286 char * result
= malloc (size
);
288 if (result
== (char *)NULL
&& size
!= 0)
289 info("%F%P virtual memory exhausted\n");
299 size_t l
= strlen(x
)+1;
300 char *r
= ldmalloc(l
);