Changeset 609 for branches/GNU/src/binutils/ld/ldcref.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/ld/ldcref.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* ldcref.c -- output a cross reference table 2 Copyright 1996, 1997, 1998, 2000 Free Software Foundation, Inc.2 Copyright 1996, 1997, 1998, 2000, 2002 Free Software Foundation, Inc. 3 3 Written by Ian Lance Taylor <ian@cygnus.com> 4 4 … … 70 70 static struct bfd_hash_entry *cref_hash_newfunc 71 71 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 72 static b oolean cref_fill_array PARAMS ((struct cref_hash_entry *, PTR));72 static bfd_boolean cref_fill_array PARAMS ((struct cref_hash_entry *, PTR)); 73 73 static int cref_sort_array PARAMS ((const PTR, const PTR)); 74 74 static void output_one_cref PARAMS ((FILE *, struct cref_hash_entry *)); 75 static boolean check_nocrossref PARAMS ((struct cref_hash_entry *, PTR)); 75 static bfd_boolean check_nocrossref PARAMS ((struct cref_hash_entry *, PTR)); 76 static void check_section_sym_xref PARAMS ((lang_input_statement_type *)); 76 77 static void check_refs 77 PARAMS ((struct cref_hash_entry *, struct bfd_link_hash_entry *, 78 struct lang_nocrossrefs *)); 78 PARAMS ((const char *, asection *, bfd *, struct lang_nocrossrefs *)); 79 79 static void check_reloc_refs PARAMS ((bfd *, asection *, PTR)); 80 80 … … 90 90 (bfd_hash_traverse \ 91 91 (&(table)->root, \ 92 (b oolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \92 (bfd_boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \ 93 93 (info))) 94 94 … … 99 99 /* Whether the cref hash table has been initialized. */ 100 100 101 static b oolean cref_initialized;101 static bfd_boolean cref_initialized; 102 102 103 103 /* The number of symbols seen so far. */ … … 157 157 if (! bfd_hash_table_init (&cref_table.root, cref_hash_newfunc)) 158 158 einfo (_("%X%P: bfd_hash_table_init of cref table failed: %E\n")); 159 cref_initialized = true;160 } 161 162 h = cref_hash_lookup (&cref_table, name, true, false);159 cref_initialized = TRUE; 160 } 161 162 h = cref_hash_lookup (&cref_table, name, TRUE, FALSE); 163 163 if (h == NULL) 164 164 einfo (_("%X%P: cref_hash_lookup failed: %E\n")); … … 174 174 h->refs = r; 175 175 r->abfd = abfd; 176 r->def = false;177 r->common = false;178 r->undef = false;176 r->def = FALSE; 177 r->common = FALSE; 178 r->undef = FALSE; 179 179 } 180 180 181 181 if (bfd_is_und_section (section)) 182 r->undef = true;182 r->undef = TRUE; 183 183 else if (bfd_is_com_section (section)) 184 r->common = true;184 r->common = TRUE; 185 185 else 186 r->def = true;186 r->def = TRUE; 187 187 } 188 188 … … 191 191 name. */ 192 192 193 static b oolean193 static bfd_boolean 194 194 cref_fill_array (h, data) 195 195 struct cref_hash_entry *h; … … 205 205 ++*pph; 206 206 207 return true;207 return TRUE; 208 208 } 209 209 … … 275 275 struct cref_ref *r; 276 276 277 hl = bfd_link_hash_lookup (link_info.hash, h->root.string, false,278 false, true);277 hl = bfd_link_hash_lookup (link_info.hash, h->root.string, FALSE, 278 FALSE, TRUE); 279 279 if (hl == NULL) 280 280 einfo ("%P: symbol `%T' missing from main hash table\n", … … 343 343 344 344 cref_hash_traverse (&cref_table, check_nocrossref, (PTR) NULL); 345 346 lang_for_each_file (check_section_sym_xref); 347 } 348 349 /* Checks for prohibited cross references to section symbols. */ 350 351 static void 352 check_section_sym_xref (statement) 353 lang_input_statement_type *statement; 354 { 355 bfd *abfd; 356 asection *sec; 357 358 abfd = statement->the_bfd; 359 if (abfd == NULL) 360 return; 361 362 for (sec = abfd->sections; sec != NULL; sec = sec->next) 363 { 364 asection *outsec; 365 366 outsec = sec->output_section; 367 if (outsec != NULL) 368 { 369 const char *outsecname; 370 struct lang_nocrossrefs *ncrs; 371 struct lang_nocrossref *ncr; 372 373 outsecname = outsec->name; 374 for (ncrs = nocrossref_list; ncrs != NULL; ncrs = ncrs->next) 375 for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next) 376 if (strcmp (ncr->name, outsecname) == 0) 377 check_refs (NULL, sec, abfd, ncrs); 378 } 379 } 345 380 } 346 381 347 382 /* Check one symbol to see if it is a prohibited cross reference. */ 348 383 349 static b oolean384 static bfd_boolean 350 385 check_nocrossref (h, ignore) 351 386 struct cref_hash_entry *h; … … 357 392 struct lang_nocrossrefs *ncrs; 358 393 struct lang_nocrossref *ncr; 359 360 hl = bfd_link_hash_lookup (link_info.hash, h->root.string, false, 361 false, true); 394 struct cref_ref *ref; 395 396 hl = bfd_link_hash_lookup (link_info.hash, h->root.string, FALSE, 397 FALSE, TRUE); 362 398 if (hl == NULL) 363 399 { 364 400 einfo (_("%P: symbol `%T' missing from main hash table\n"), 365 401 h->root.string); 366 return true;402 return TRUE; 367 403 } 368 404 369 405 if (hl->type != bfd_link_hash_defined 370 406 && hl->type != bfd_link_hash_defweak) 371 return true;407 return TRUE; 372 408 373 409 defsec = hl->u.def.section->output_section; 374 410 if (defsec == NULL) 375 return true;411 return TRUE; 376 412 defsecname = bfd_get_section_name (defsec->owner, defsec); 377 413 … … 379 415 for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next) 380 416 if (strcmp (ncr->name, defsecname) == 0) 381 check_refs (h, hl, ncrs); 382 383 return true; 417 for (ref = h->refs; ref != NULL; ref = ref->next) 418 check_refs (hl->root.string, hl->u.def.section, ref->abfd, ncrs); 419 420 return TRUE; 384 421 } 385 422 … … 388 425 389 426 struct check_refs_info { 390 struct cref_hash_entry *h;427 const char *sym_name; 391 428 asection *defsec; 392 429 struct lang_nocrossrefs *ncrs; 393 430 asymbol **asymbols; 394 boolean same;395 431 }; 396 432 … … 401 437 402 438 static void 403 check_refs (h, hl, ncrs) 404 struct cref_hash_entry *h; 405 struct bfd_link_hash_entry *hl; 439 check_refs (name, sec, abfd, ncrs) 440 const char *name; 441 asection *sec; 442 bfd *abfd; 406 443 struct lang_nocrossrefs *ncrs; 407 444 { 408 struct cref_ref *ref; 409 410 for (ref = h->refs; ref != NULL; ref = ref->next) 411 { 412 lang_input_statement_type *li; 413 asymbol **asymbols; 414 struct check_refs_info info; 415 416 /* We need to look through the relocations for this BFD, to see 417 if any of the relocations which refer to this symbol are from 418 a prohibited section. Note that we need to do this even for 419 the BFD in which the symbol is defined, since even a single 420 BFD might contain a prohibited cross reference; for this 421 case, we set the SAME field in INFO, which will cause 422 CHECK_RELOCS_REFS to check for relocations against the 423 section as well as against the symbol. */ 424 425 li = (lang_input_statement_type *) ref->abfd->usrdata; 426 if (li != NULL && li->asymbols != NULL) 427 asymbols = li->asymbols; 428 else 445 lang_input_statement_type *li; 446 asymbol **asymbols; 447 struct check_refs_info info; 448 449 /* We need to look through the relocations for this BFD, to see 450 if any of the relocations which refer to this symbol are from 451 a prohibited section. Note that we need to do this even for 452 the BFD in which the symbol is defined, since even a single 453 BFD might contain a prohibited cross reference. */ 454 455 li = (lang_input_statement_type *) abfd->usrdata; 456 if (li != NULL && li->asymbols != NULL) 457 asymbols = li->asymbols; 458 else 459 { 460 long symsize; 461 long symbol_count; 462 463 symsize = bfd_get_symtab_upper_bound (abfd); 464 if (symsize < 0) 465 einfo (_("%B%F: could not read symbols; %E\n"), abfd); 466 asymbols = (asymbol **) xmalloc (symsize); 467 symbol_count = bfd_canonicalize_symtab (abfd, asymbols); 468 if (symbol_count < 0) 469 einfo (_("%B%F: could not read symbols: %E\n"), abfd); 470 if (li != NULL) 429 471 { 430 long symsize; 431 long symbol_count; 432 433 symsize = bfd_get_symtab_upper_bound (ref->abfd); 434 if (symsize < 0) 435 einfo (_("%B%F: could not read symbols; %E\n"), ref->abfd); 436 asymbols = (asymbol **) xmalloc (symsize); 437 symbol_count = bfd_canonicalize_symtab (ref->abfd, asymbols); 438 if (symbol_count < 0) 439 einfo (_("%B%F: could not read symbols: %E\n"), ref->abfd); 440 if (li != NULL) 441 { 442 li->asymbols = asymbols; 443 li->symbol_count = symbol_count; 444 } 472 li->asymbols = asymbols; 473 li->symbol_count = symbol_count; 445 474 } 446 447 info.h = h; 448 info.defsec = hl->u.def.section; 449 info.ncrs = ncrs; 450 info.asymbols = asymbols; 451 if (ref->abfd == hl->u.def.section->owner) 452 info.same = true; 453 else 454 info.same = false; 455 bfd_map_over_sections (ref->abfd, check_reloc_refs, (PTR) &info); 456 457 if (li == NULL) 458 free (asymbols); 459 } 460 } 461 462 /* This is called via bfd_map_over_sections. INFO->H is a symbol 475 } 476 477 info.sym_name = name; 478 info.defsec = sec; 479 info.ncrs = ncrs; 480 info.asymbols = asymbols; 481 bfd_map_over_sections (abfd, check_reloc_refs, (PTR) &info); 482 483 if (li == NULL) 484 free (asymbols); 485 } 486 487 /* This is called via bfd_map_over_sections. INFO->SYM_NAME is a symbol 463 488 defined in INFO->DEFSECNAME. If this section maps into any of the 464 489 sections listed in INFO->NCRS, other than INFO->DEFSECNAME, then we 465 490 look through the relocations. If any of the relocations are to 466 INFO-> H, then we report a prohibited cross reference error. */491 INFO->SYM_NAME, then we report a prohibited cross reference error. */ 467 492 468 493 static void … … 503 528 /* This section is one for which cross references are prohibited. 504 529 Look through the relocations, and see if any of them are to 505 INFO->H. */ 506 507 symname = info->h->root.string; 530 INFO->SYM_NAME. If INFO->SYMNAME is NULL, check for relocations 531 against the section symbol. */ 532 533 symname = info->sym_name; 508 534 509 535 relsize = bfd_get_reloc_upper_bound (abfd, sec); … … 526 552 if (q->sym_ptr_ptr != NULL 527 553 && *q->sym_ptr_ptr != NULL 528 && (strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), symname) == 0 529 || (info->same 530 && bfd_get_section (*q->sym_ptr_ptr) == info->defsec))) 554 && (symname != NULL 555 ? strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), symname) == 0 556 : (((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0 557 && bfd_get_section (*q->sym_ptr_ptr) == info->defsec))) 531 558 { 532 559 /* We found a reloc for the symbol. The symbol is defined -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.