Changeset 609 for branches/GNU/src/binutils/ld/ldmisc.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/ld/ldmisc.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* ldmisc.c 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000, 2002, 2003 3 4 Free Software Foundation, Inc. 4 5 Written by Steve Chamberlain of Cygnus Support. 5 6 6 This file is part of GLD, the Gnu Linker.7 8 GLD is free software; you can redistribute it and/or modify9 it under the terms of the GNU General Public License as published by10 the Free Software Foundation; either version 2, or (at your option)11 any later version.12 13 GLD is distributed in the hope that it will be useful,14 but WITHOUT ANY WARRANTY; without even the implied warranty of15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 GNU General Public License for more details.17 18 You should have received a copy of the GNU General Public License19 along with GLD; see the file COPYING. If not, write to the Free20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA21 02111-1307, USA. */7 This file is part of GLD, the Gnu Linker. 8 9 GLD is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2, or (at your option) 12 any later version. 13 14 GLD is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with GLD; see the file COPYING. If not, write to the Free 21 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 22 02111-1307, USA. */ 22 23 23 24 #include "bfd.h" … … 28 29 #ifdef ANSI_PROTOTYPES 29 30 #include <stdarg.h> 30 #define USE_STDARG 131 31 #else 32 32 #include <varargs.h> 33 #define USE_STDARG 034 33 #endif 35 34 … … 38 37 #include "ldexp.h" 39 38 #include "ldlang.h" 40 #include "ldgram.h"39 #include <ldgram.h> 41 40 #include "ldlex.h" 42 41 #include "ldmain.h" … … 67 66 */ 68 67 69 char *70 demangle (string)71 const char *string;72 {73 char *res;74 75 if (output_bfd != NULL76 && bfd_get_symbol_leading_char (output_bfd) == string[0])77 ++string;78 79 /* This is a hack for better error reporting on XCOFF, or the MS PE80 format. Xcoff has a single '.', while the NT PE for PPC has81 '..'. So we remove all of them. */82 while (string[0] == '.')83 ++string;84 85 res = cplus_demangle (string, DMGL_ANSI | DMGL_PARAMS);86 return res ? res : xstrdup (string);87 }88 89 68 static void 90 69 vfinfo (fp, fmt, arg) … … 93 72 va_list arg; 94 73 { 95 b oolean fatal = false;74 bfd_boolean fatal = FALSE; 96 75 97 76 while (*fmt != '\0') … … 119 98 case 'X': 120 99 /* no object output, fail return */ 121 config.make_executable = false;100 config.make_executable = FALSE; 122 101 break; 123 102 … … 204 183 case 'F': 205 184 /* Error is fatal. */ 206 fatal = true;185 fatal = TRUE; 207 186 break; 208 187 … … 258 237 case 'D': 259 238 case 'G': 260 /* Clever filename:linenumber with function name if possible, 261 or section name as a last resort. The arguments are a BFD, 262 a section, and an offset. */ 239 /* Clever filename:linenumber with function name if possible. 240 The arguments are a BFD, a section, and an offset. */ 263 241 { 264 242 static bfd *last_bfd; … … 273 251 const char *functionname; 274 252 unsigned int linenumber; 275 b oolean discard_last;253 bfd_boolean discard_last; 276 254 277 255 abfd = va_arg (arg, bfd *); … … 302 280 } 303 281 304 discard_last = true; 282 lfinfo (fp, "%B(%s+0x%v)", abfd, section->name, offset); 283 284 discard_last = TRUE; 305 285 if (bfd_find_nearest_line (abfd, section, asymbols, offset, 306 286 &filename, &functionname, 307 287 &linenumber)) 308 288 { 309 if (functionname != NULL && fmt[-1] == 'G') 289 bfd_boolean need_colon = TRUE; 290 291 if (functionname != NULL && fmt[-1] == 'C') 310 292 { 311 lfinfo (fp, "%B:", abfd);312 if (filename != NULL313 && strcmp (filename, bfd_get_filename (abfd)) != 0)314 fprintf (fp, "%s:", filename);315 lfinfo (fp, "%T", functionname);316 }317 else if (functionname != NULL && fmt[-1] == 'C')318 {319 if (filename == (char *) NULL)320 filename = abfd->filename;321 322 293 if (last_bfd == NULL 323 294 || last_file == NULL 324 295 || last_function == NULL 325 296 || last_bfd != abfd 326 || strcmp (last_file, filename) != 0 297 || (filename != NULL 298 && strcmp (last_file, filename) != 0) 327 299 || strcmp (last_function, functionname) != 0) 328 300 { 329 /* We use abfd->filename in this initial line, 330 in case filename is a .h file or something 331 similarly unhelpful. */ 332 lfinfo (fp, _("%B: In function `%T':\n"), 333 abfd, functionname); 301 lfinfo (fp, _(": In function `%T':\n"), 302 functionname); 303 need_colon = FALSE; 334 304 335 305 last_bfd = abfd; 336 306 if (last_file != NULL) 337 307 free (last_file); 338 last_file = xstrdup (filename); 308 last_file = NULL; 309 if (filename) 310 last_file = xstrdup (filename); 339 311 if (last_function != NULL) 340 312 free (last_function); 341 313 last_function = xstrdup (functionname); 342 314 } 343 discard_last = false; 344 if (linenumber != 0) 345 fprintf (fp, "%s:%u", filename, linenumber); 346 else 347 lfinfo (fp, "%s(%s+0x%v)", filename, section->name, 348 offset); 315 discard_last = FALSE; 349 316 } 350 else if (filename == NULL 351 || strcmp (filename, abfd->filename) == 0)317 318 if (filename != NULL) 352 319 { 353 lfinfo (fp, "%B(%s+0x%v)", abfd, section->name, 354 offset); 355 if (linenumber != 0) 356 lfinfo (fp, ":%u", linenumber); 320 if (need_colon) 321 putc (':', fp); 322 fputs (filename, fp); 357 323 } 358 else if (linenumber != 0) 359 lfinfo (fp, "%B:%s:%u", abfd, filename, linenumber);360 else361 lfinfo (fp, "%B(%s+0x%v):%s", abfd, section->name,362 offset, filename);324 325 if (functionname != NULL && fmt[-1] == 'G') 326 lfinfo (fp, ":%T", functionname); 327 else if (filename != NULL && linenumber != 0) 328 fprintf (fp, ":%u", linenumber); 363 329 } 364 else 365 lfinfo (fp, "%B(%s+0x%v)", abfd, section->name, offset); 330 331 if (asymbols != NULL && entry == NULL) 332 free (asymbols); 366 333 367 334 if (discard_last) … … 400 367 } 401 368 402 if (fatal == true) 369 if (config.fatal_warnings) 370 config.make_executable = FALSE; 371 372 if (fatal) 403 373 xexit (1); 374 } 375 376 /* Wrapper around cplus_demangle. Strips leading underscores and 377 other such chars that would otherwise confuse the demangler. */ 378 379 char * 380 demangle (name) 381 const char *name; 382 { 383 char *res; 384 const char *p; 385 386 if (output_bfd != NULL 387 && bfd_get_symbol_leading_char (output_bfd) == name[0]) 388 ++name; 389 390 /* This is a hack for better error reporting on XCOFF, PowerPC64-ELF 391 or the MS PE format. These formats have a number of leading '.'s 392 on at least some symbols, so we remove all dots to avoid 393 confusing the demangler. */ 394 p = name; 395 while (*p == '.') 396 ++p; 397 398 res = cplus_demangle (p, DMGL_ANSI | DMGL_PARAMS); 399 if (res) 400 { 401 size_t dots = p - name; 402 403 /* Now put back any stripped dots. */ 404 if (dots != 0) 405 { 406 size_t len = strlen (res) + 1; 407 char *add_dots = xmalloc (len + dots); 408 409 memcpy (add_dots, name, dots); 410 memcpy (add_dots + dots, res, len); 411 free (res); 412 res = add_dots; 413 } 414 return res; 415 } 416 return xstrdup (name); 404 417 } 405 418 … … 410 423 411 424 void 412 #if USE_STDARG 413 info_msg (const char *fmt, ...) 414 #else 415 info_msg (va_alist) 416 va_dcl 417 #endif 418 { 419 va_list arg; 420 421 #if ! USE_STDARG 422 const char *fmt; 423 424 va_start (arg); 425 fmt = va_arg (arg, const char *); 426 #else 427 va_start (arg, fmt); 428 #endif 425 info_msg VPARAMS ((const char *fmt, ...)) 426 { 427 VA_OPEN (arg, fmt); 428 VA_FIXEDARG (arg, const char *, fmt); 429 429 430 430 vfinfo (stdout, fmt, arg); 431 va_end(arg);431 VA_CLOSE (arg); 432 432 } 433 433 … … 435 435 436 436 void 437 #if USE_STDARG 438 einfo (const char *fmt, ...) 439 #else 440 einfo (va_alist) 441 va_dcl 442 #endif 443 { 444 va_list arg; 445 446 #if ! USE_STDARG 447 const char *fmt; 448 449 va_start (arg); 450 fmt = va_arg (arg, const char *); 451 #else 452 va_start (arg, fmt); 453 #endif 437 einfo VPARAMS ((const char *fmt, ...)) 438 { 439 VA_OPEN (arg, fmt); 440 VA_FIXEDARG (arg, const char *, fmt); 454 441 455 442 vfinfo (stderr, fmt, arg); 456 va_end(arg);443 VA_CLOSE (arg); 457 444 } 458 445 … … 468 455 469 456 void 470 #if USE_STDARG 471 minfo (const char *fmt, ...) 472 #else 473 minfo (va_alist) 474 va_dcl 475 #endif 476 { 477 va_list arg; 478 479 #if ! USE_STDARG 480 const char *fmt; 481 va_start (arg); 482 fmt = va_arg (arg, const char *); 483 #else 484 va_start (arg, fmt); 485 #endif 457 minfo VPARAMS ((const char *fmt, ...)) 458 { 459 VA_OPEN (arg, fmt); 460 VA_FIXEDARG (arg, const char *, fmt); 486 461 487 462 vfinfo (config.map_file, fmt, arg); 488 va_end (arg); 489 } 490 491 void 492 #if USE_STDARG 493 lfinfo (FILE *file, const char *fmt, ...) 494 #else 495 lfinfo (va_alist) 496 va_dcl 497 #endif 498 { 499 va_list arg; 500 501 #if ! USE_STDARG 502 FILE *file; 503 const char *fmt; 504 505 va_start (arg); 506 file = va_arg (arg, FILE *); 507 fmt = va_arg (arg, const char *); 508 #else 509 va_start (arg, fmt); 510 #endif 463 VA_CLOSE (arg); 464 } 465 466 void 467 lfinfo VPARAMS ((FILE *file, const char *fmt, ...)) 468 { 469 VA_OPEN (arg, fmt); 470 VA_FIXEDARG (arg, FILE *, file); 471 VA_FIXEDARG (arg, const char *, fmt); 511 472 512 473 vfinfo (file, fmt, arg); 513 va_end(arg);474 VA_CLOSE (arg); 514 475 } 515 476 … … 547 508 xexit (1); 548 509 } 510 511 bfd_boolean 512 error_handler VPARAMS ((int id ATTRIBUTE_UNUSED, const char *fmt, ...)) 513 { 514 VA_OPEN (arg, fmt); 515 VA_FIXEDARG (arg, const char *, fmt); 516 517 vfinfo (stderr, fmt, arg); 518 VA_CLOSE (arg); 519 return TRUE; 520 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.