Changeset 609 for branches/GNU/src/binutils/ld/ldlang.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/ld/ldlang.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Linker command language support. 2 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 3 2001 3 2001, 2002, 2003 4 4 Free Software Foundation, Inc. 5 5 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. */6 This file is part of GLD, the Gnu Linker. 7 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) 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 of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 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 the Free 20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 21 02111-1307, USA. */ 22 22 23 23 #include "bfd.h" 24 24 #include "sysdep.h" 25 25 #include "libiberty.h" 26 #include "safe-ctype.h" 26 27 #include "obstack.h" 27 28 #include "bfdlink.h" … … 29 30 #include "ld.h" 30 31 #include "ldmain.h" 31 #include "ldgram.h"32 32 #include "ldexp.h" 33 33 #include "ldlang.h" 34 #include <ldgram.h> 34 35 #include "ldlex.h" 35 36 #include "ldmisc.h" … … 40 41 #include "demangle.h" 41 42 42 #include <ctype.h> 43 44 /* FORWARDS */ 45 static lang_statement_union_type *new_statement 46 PARAMS ((enum statement_enum, size_t, lang_statement_list_type *)); 47 48 /* LOCALS */ 43 #ifndef offsetof 44 #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER)) 45 #endif 46 47 /* Locals variables. */ 49 48 static struct obstack stat_obstack; 50 49 … … 53 52 static const char *startup_file; 54 53 static lang_statement_list_type input_file_chain; 55 static b oolean placed_commons = false;54 static bfd_boolean placed_commons = FALSE; 56 55 static lang_output_section_statement_type *default_common_section; 57 static b oolean map_option_f;56 static bfd_boolean map_option_f; 58 57 static bfd_vma print_dot; 59 58 static lang_input_statement_type *first_file; … … 63 62 static struct lang_phdr *lang_phdr_list; 64 63 64 /* Forward declarations. */ 65 static lang_statement_union_type *new_statement 66 PARAMS ((enum statement_enum, size_t, lang_statement_list_type *)); 65 67 static void lang_for_each_statement_worker 66 68 PARAMS ((void (*) (lang_statement_union_type *), 67 69 lang_statement_union_type *)); 68 70 static lang_input_statement_type *new_afile 69 PARAMS ((const char *, lang_input_file_enum_type, const char *, boolean)); 70 static lang_memory_region_type *lang_memory_default PARAMS ((asection *)); 71 static void lang_map_flags PARAMS ((flagword)); 72 static void init_os PARAMS ((lang_output_section_statement_type *)); 73 static void exp_init_os PARAMS ((etree_type *)); 74 static void section_already_linked PARAMS ((bfd *, asection *, PTR)); 71 PARAMS ((const char *, lang_input_file_enum_type, const char *, 72 bfd_boolean)); 73 static lang_memory_region_type *lang_memory_default 74 PARAMS ((asection *)); 75 static void lang_map_flags 76 PARAMS ((flagword)); 77 static void init_os 78 PARAMS ((lang_output_section_statement_type *)); 79 static void exp_init_os 80 PARAMS ((etree_type *)); 81 static void section_already_linked 82 PARAMS ((bfd *, asection *, PTR)); 75 83 static struct bfd_hash_entry *already_linked_newfunc 76 84 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 77 static void already_linked_table_init PARAMS ((void)); 78 static void already_linked_table_free PARAMS ((void)); 79 static boolean wildcardp PARAMS ((const char *)); 85 static void already_linked_table_init 86 PARAMS ((void)); 87 static void already_linked_table_free 88 PARAMS ((void)); 89 static bfd_boolean wildcardp 90 PARAMS ((const char *)); 80 91 static lang_statement_union_type *wild_sort 81 PARAMS ((lang_wild_statement_type *, lang_input_statement_type*,82 asection *));92 PARAMS ((lang_wild_statement_type *, struct wildcard_list *, 93 lang_input_statement_type *, asection *)); 83 94 static void output_section_callback 84 PARAMS ((lang_wild_statement_type *, asection *,95 PARAMS ((lang_wild_statement_type *, struct wildcard_list *, asection *, 85 96 lang_input_statement_type *, PTR)); 86 static lang_input_statement_type *lookup_name PARAMS ((const char *)); 87 static void load_symbols 97 static lang_input_statement_type *lookup_name 98 PARAMS ((const char *)); 99 static bfd_boolean load_symbols 88 100 PARAMS ((lang_input_statement_type *, lang_statement_list_type *)); 89 101 static void wild 90 PARAMS ((lang_wild_statement_type *, const char *, const char *,102 PARAMS ((lang_wild_statement_type *, 91 103 const char *, lang_output_section_statement_type *)); 92 static bfd *open_output PARAMS ((const char *)); 93 static void ldlang_open_output PARAMS ((lang_statement_union_type *)); 94 static void open_input_bfds PARAMS ((lang_statement_union_type *, boolean)); 95 static void lang_reasonable_defaults PARAMS ((void)); 96 static void lang_place_undefineds PARAMS ((void)); 104 static bfd *open_output 105 PARAMS ((const char *)); 106 static void ldlang_open_output 107 PARAMS ((lang_statement_union_type *)); 108 static void open_input_bfds 109 PARAMS ((lang_statement_union_type *, bfd_boolean)); 110 static void lang_reasonable_defaults 111 PARAMS ((void)); 112 static void insert_undefined 113 PARAMS ((const char *)); 114 static void lang_place_undefineds 115 PARAMS ((void)); 97 116 static void map_input_to_output_sections 98 117 PARAMS ((lang_statement_union_type *, const char *, 99 118 lang_output_section_statement_type *)); 119 static void strip_excluded_output_sections 120 PARAMS ((void)); 100 121 static void print_output_section_statement 101 122 PARAMS ((lang_output_section_statement_type *)); … … 103 124 PARAMS ((lang_assignment_statement_type *, 104 125 lang_output_section_statement_type *)); 105 static void print_input_statement PARAMS ((lang_input_statement_type *)); 106 static boolean print_one_symbol PARAMS ((struct bfd_link_hash_entry *, PTR)); 107 static void print_input_section PARAMS ((lang_input_section_type *)); 108 static void print_fill_statement PARAMS ((lang_fill_statement_type *)); 109 static void print_data_statement PARAMS ((lang_data_statement_type *)); 110 static void print_address_statement PARAMS ((lang_address_statement_type *)); 111 static void print_reloc_statement PARAMS ((lang_reloc_statement_type *)); 112 static void print_padding_statement PARAMS ((lang_padding_statement_type *)); 126 static void print_input_statement 127 PARAMS ((lang_input_statement_type *)); 128 static bfd_boolean print_one_symbol 129 PARAMS ((struct bfd_link_hash_entry *, PTR)); 130 static void print_input_section 131 PARAMS ((lang_input_section_type *)); 132 static void print_fill_statement 133 PARAMS ((lang_fill_statement_type *)); 134 static void print_data_statement 135 PARAMS ((lang_data_statement_type *)); 136 static void print_address_statement 137 PARAMS ((lang_address_statement_type *)); 138 static void print_reloc_statement 139 PARAMS ((lang_reloc_statement_type *)); 140 static void print_padding_statement 141 PARAMS ((lang_padding_statement_type *)); 113 142 static void print_wild_statement 114 143 PARAMS ((lang_wild_statement_type *, lang_output_section_statement_type *)); … … 119 148 static void print_statement_list 120 149 PARAMS ((lang_statement_union_type *, lang_output_section_statement_type *)); 121 static void print_statements PARAMS ((void)); 122 static bfd_vma insert_pad 123 PARAMS ((lang_statement_union_type **, fill_type, 150 static void print_statements 151 PARAMS ((void)); 152 static void insert_pad 153 PARAMS ((lang_statement_union_type **, fill_type *, 124 154 unsigned int, asection *, bfd_vma)); 125 155 static bfd_vma size_input_section 126 156 PARAMS ((lang_statement_union_type **, lang_output_section_statement_type *, 127 fill_type, bfd_vma, boolean)); 128 static void lang_finish PARAMS ((void)); 129 static void ignore_bfd_errors PARAMS ((const char *, ...)); 130 static void lang_check PARAMS ((void)); 131 static void lang_common PARAMS ((void)); 132 static boolean lang_one_common PARAMS ((struct bfd_link_hash_entry *, PTR)); 133 static void lang_place_orphans PARAMS ((void)); 134 static int topower PARAMS ((int)); 135 static void lang_set_startof PARAMS ((void)); 136 static void reset_memory_regions PARAMS ((void)); 157 fill_type *, bfd_vma)); 158 static void lang_finish 159 PARAMS ((void)); 160 static void ignore_bfd_errors 161 PARAMS ((const char *, ...)); 162 static void lang_check 163 PARAMS ((void)); 164 static void lang_common 165 PARAMS ((void)); 166 static bfd_boolean lang_one_common 167 PARAMS ((struct bfd_link_hash_entry *, PTR)); 168 static void lang_place_orphans 169 PARAMS ((void)); 170 static int topower 171 PARAMS ((int)); 172 static void lang_set_startof 173 PARAMS ((void)); 137 174 static void gc_section_callback 138 PARAMS ((lang_wild_statement_type *, asection *,175 PARAMS ((lang_wild_statement_type *, struct wildcard_list *, asection *, 139 176 lang_input_statement_type *, PTR)); 140 static void lang_record_phdrs PARAMS ((void)); 177 static void lang_get_regions 178 PARAMS ((struct memory_region_struct **, struct memory_region_struct **, 179 const char *, const char *, int)); 180 static void lang_record_phdrs 181 PARAMS ((void)); 141 182 static void lang_gc_wild 142 PARAMS ((lang_wild_statement_type *, const char *, const char *)); 143 static void lang_gc_sections_1 PARAMS ((lang_statement_union_type *)); 144 static void lang_gc_sections PARAMS ((void)); 183 PARAMS ((lang_wild_statement_type *)); 184 static void lang_gc_sections_1 185 PARAMS ((lang_statement_union_type *)); 186 static void lang_gc_sections 187 PARAMS ((void)); 145 188 static int lang_vers_match_lang_c 146 189 PARAMS ((struct bfd_elf_version_expr *, const char *)); … … 149 192 static int lang_vers_match_lang_java 150 193 PARAMS ((struct bfd_elf_version_expr *, const char *)); 151 static void lang_do_version_exports_section PARAMS ((void)); 152 static void lang_check_section_addresses PARAMS ((void)); 194 static void lang_do_version_exports_section 195 PARAMS ((void)); 196 static void lang_check_section_addresses 197 PARAMS ((void)); 153 198 static void os_region_check 154 199 PARAMS ((lang_output_section_statement_type *, 155 200 struct memory_region_struct *, etree_type *, bfd_vma)); 156 157 typedef void (*callback_t) PARAMS ((lang_wild_statement_type *, 158 asection *, lang_input_statement_type *, 159 PTR)); 201 static bfd_vma lang_size_sections_1 202 PARAMS ((lang_statement_union_type *, lang_output_section_statement_type *, 203 lang_statement_union_type **, fill_type *, bfd_vma, bfd_boolean *, 204 bfd_boolean)); 205 typedef void (*callback_t) 206 PARAMS ((lang_wild_statement_type *, struct wildcard_list *, asection *, 207 lang_input_statement_type *, PTR)); 160 208 static void walk_wild 161 PARAMS ((lang_wild_statement_type *, const char *, const char *, 162 callback_t, PTR)); 209 PARAMS ((lang_wild_statement_type *, callback_t, PTR)); 163 210 static void walk_wild_section 164 PARAMS ((lang_wild_statement_type *, const char*,165 lang_input_statement_type *,callback_t, PTR));211 PARAMS ((lang_wild_statement_type *, lang_input_statement_type *, 212 callback_t, PTR)); 166 213 static void walk_wild_file 167 PARAMS ((lang_wild_statement_type *, const char *, 168 lang_input_statement_type *, callback_t, PTR)); 169 170 static int get_target PARAMS ((const bfd_target *, PTR)); 171 static void stricpy PARAMS ((char *, char *)); 172 static void strcut PARAMS ((char *, char *)); 173 static int name_compare PARAMS ((char *, char *)); 174 static int closest_target_match PARAMS ((const bfd_target *, PTR)); 175 static char * get_first_input_target PARAMS ((void)); 176 177 /* EXPORTS */ 214 PARAMS ((lang_wild_statement_type *, lang_input_statement_type *, 215 callback_t, PTR)); 216 static int get_target 217 PARAMS ((const bfd_target *, PTR)); 218 static void stricpy 219 PARAMS ((char *, char *)); 220 static void strcut 221 PARAMS ((char *, char *)); 222 static int name_compare 223 PARAMS ((char *, char *)); 224 static int closest_target_match 225 PARAMS ((const bfd_target *, PTR)); 226 static char * get_first_input_target 227 PARAMS ((void)); 228 229 /* Exported variables. */ 178 230 lang_output_section_statement_type *abs_output_section; 179 231 lang_statement_list_type lang_output_section_statement; 180 232 lang_statement_list_type *stat_ptr = &statement_list; 181 233 lang_statement_list_type file_chain = { NULL, NULL }; 182 const char *entry_symbol = NULL; 183 boolean entry_from_cmdline; 184 boolean lang_has_input_file = false; 185 boolean had_output_filename = false; 186 boolean lang_float_flag = false; 187 boolean delete_output_file_on_failure = false; 234 struct bfd_sym_chain entry_symbol = { NULL, NULL }; 235 const char *entry_section = ".text"; 236 bfd_boolean entry_from_cmdline; 237 bfd_boolean lang_has_input_file = FALSE; 238 bfd_boolean had_output_filename = FALSE; 239 bfd_boolean lang_float_flag = FALSE; 240 bfd_boolean delete_output_file_on_failure = FALSE; 188 241 struct lang_nocrossrefs *nocrossref_list; 189 242 struct unique_sections *unique_section_list; 243 static bfd_boolean ldlang_sysrooted_script = FALSE; 190 244 191 245 etree_type *base; /* Relocation base - or null */ … … 217 271 } 218 272 219 b oolean273 bfd_boolean 220 274 unique_section_p (secnam) 221 275 const char *secnam; … … 228 282 : strcmp (unam->name, secnam) == 0) 229 283 { 230 return true;284 return TRUE; 231 285 } 232 286 233 return false;287 return FALSE; 234 288 } 235 289 … … 237 291 238 292 static void 239 walk_wild_section (ptr, section,file, callback, data)293 walk_wild_section (ptr, file, callback, data) 240 294 lang_wild_statement_type *ptr; 241 const char *section;242 295 lang_input_statement_type *file; 243 296 callback_t callback; 244 297 PTR data; 245 298 { 246 /* Don't process sections from files which were excluded. */ 247 if (ptr->exclude_filename_list != NULL) 248 { 249 struct name_list *list_tmp; 250 for (list_tmp = ptr->exclude_filename_list; 251 list_tmp; 252 list_tmp = list_tmp->next) 253 { 254 boolean match; 255 256 if (wildcardp (list_tmp->name)) 257 match = fnmatch (list_tmp->name, file->filename, 0) == 0; 258 else 259 match = strcmp (list_tmp->name, file->filename) == 0; 260 261 if (match) 262 return; 263 } 264 } 265 266 if (file->just_syms_flag == false) 267 { 268 register asection *s; 269 boolean wildcard = false; 270 271 if (section != NULL) 272 wildcard = wildcardp (section); 273 274 for (s = file->the_bfd->sections; s != NULL; s = s->next) 275 { 276 boolean match; 277 const char *sname = bfd_get_section_name (file->the_bfd, s); 278 279 if (section == NULL) 280 match = true; 281 else if (wildcard) 282 match = fnmatch (section, sname, 0) == 0; 283 else 284 match = strcmp (section, sname) == 0; 285 286 /* If this is a wild-card output section statement, exclude 287 sections that match UNIQUE_SECTION_LIST. */ 288 if (match && (data == NULL || !unique_section_p (sname))) 289 (*callback) (ptr, s, file, data); 299 asection *s; 300 301 if (file->just_syms_flag) 302 return; 303 304 for (s = file->the_bfd->sections; s != NULL; s = s->next) 305 { 306 struct wildcard_list *sec; 307 308 sec = ptr->section_list; 309 if (sec == NULL) 310 (*callback) (ptr, sec, s, file, data); 311 312 while (sec != NULL) 313 { 314 bfd_boolean skip = FALSE; 315 struct name_list *list_tmp; 316 317 /* Don't process sections from files which were 318 excluded. */ 319 for (list_tmp = sec->spec.exclude_name_list; 320 list_tmp; 321 list_tmp = list_tmp->next) 322 { 323 if (wildcardp (list_tmp->name)) 324 skip = fnmatch (list_tmp->name, file->filename, 0) == 0; 325 else 326 skip = strcmp (list_tmp->name, file->filename) == 0; 327 328 /* If this file is part of an archive, and the archive is 329 excluded, exclude this file. */ 330 if (! skip && file->the_bfd != NULL 331 && file->the_bfd->my_archive != NULL 332 && file->the_bfd->my_archive->filename != NULL) 333 { 334 if (wildcardp (list_tmp->name)) 335 skip = fnmatch (list_tmp->name, 336 file->the_bfd->my_archive->filename, 337 0) == 0; 338 else 339 skip = strcmp (list_tmp->name, 340 file->the_bfd->my_archive->filename) == 0; 341 } 342 343 if (skip) 344 break; 345 } 346 347 if (!skip && sec->spec.name != NULL) 348 { 349 const char *sname = bfd_get_section_name (file->the_bfd, s); 350 351 if (wildcardp (sec->spec.name)) 352 skip = fnmatch (sec->spec.name, sname, 0) != 0; 353 else 354 skip = strcmp (sec->spec.name, sname) != 0; 355 } 356 357 if (!skip) 358 (*callback) (ptr, sec, s, file, data); 359 360 sec = sec->next; 290 361 } 291 362 } … … 295 366 296 367 static void 297 walk_wild_file (s, section,f, callback, data)368 walk_wild_file (s, f, callback, data) 298 369 lang_wild_statement_type *s; 299 const char *section;300 370 lang_input_statement_type *f; 301 371 callback_t callback; … … 304 374 if (f->the_bfd == NULL 305 375 || ! bfd_check_format (f->the_bfd, bfd_archive)) 306 walk_wild_section (s, section,f, callback, data);376 walk_wild_section (s, f, callback, data); 307 377 else 308 378 { … … 321 391 if (member->usrdata != NULL) 322 392 { 323 walk_wild_section (s, section,393 walk_wild_section (s, 324 394 (lang_input_statement_type *) member->usrdata, 325 395 callback, data); … … 332 402 333 403 static void 334 walk_wild (s, section, file,callback, data)404 walk_wild (s, callback, data) 335 405 lang_wild_statement_type *s; 336 const char *section;337 const char *file;338 406 callback_t callback; 339 407 PTR data; 340 408 { 341 if (file == (char *) NULL) 409 const char *file_spec = s->filename; 410 411 if (file_spec == NULL) 342 412 { 343 413 /* Perform the iteration over all files in the list. */ 344 414 LANG_FOR_EACH_INPUT_STATEMENT (f) 345 415 { 346 walk_wild_file (s, section,f, callback, data);347 } 348 } 349 else if (wildcardp (file ))416 walk_wild_file (s, f, callback, data); 417 } 418 } 419 else if (wildcardp (file_spec)) 350 420 { 351 421 LANG_FOR_EACH_INPUT_STATEMENT (f) 352 422 { 353 if (fnmatch (file , f->filename, FNM_FILE_NAME) == 0)354 walk_wild_file (s, section,f, callback, data);423 if (fnmatch (file_spec, f->filename, FNM_FILE_NAME) == 0) 424 walk_wild_file (s, f, callback, data); 355 425 } 356 426 } … … 360 430 361 431 /* Perform the iteration over a single file. */ 362 f = lookup_name (file); 363 walk_wild_file (s, section, f, callback, data); 432 f = lookup_name (file_spec); 433 if (f) 434 walk_wild_file (s, f, callback, data); 364 435 } 365 436 } … … 373 444 lang_statement_union_type *s; 374 445 { 375 for (; s != (lang_statement_union_type *) NULL; s = s-> next)446 for (; s != (lang_statement_union_type *) NULL; s = s->header.next) 376 447 { 377 448 func (s); … … 454 525 455 526 We can be supplied with requests for input files more than once; 456 they may, for example be split over se rveral lines like foo.o(.text)527 they may, for example be split over several lines like foo.o(.text) 457 528 foo.o(.data) etc, so when asked for a file we check that we haven't 458 529 got it already so we don't duplicate the bfd. */ … … 463 534 lang_input_file_enum_type file_type; 464 535 const char *target; 465 b oolean add_to_list;536 bfd_boolean add_to_list; 466 537 { 467 538 lang_input_statement_type *p; … … 476 547 } 477 548 478 lang_has_input_file = true;549 lang_has_input_file = TRUE; 479 550 p->target = target; 551 p->sysrooted = FALSE; 480 552 switch (file_type) 481 553 { 482 554 case lang_input_file_is_symbols_only_enum: 483 555 p->filename = name; 484 p->is_archive = false;485 p->real = true;556 p->is_archive = FALSE; 557 p->real = TRUE; 486 558 p->local_sym_name = name; 487 p->just_syms_flag = true;488 p->search_dirs_flag = false;559 p->just_syms_flag = TRUE; 560 p->search_dirs_flag = FALSE; 489 561 break; 490 562 case lang_input_file_is_fake_enum: 491 563 p->filename = name; 492 p->is_archive = false;493 p->real = false;564 p->is_archive = FALSE; 565 p->real = FALSE; 494 566 p->local_sym_name = name; 495 p->just_syms_flag = false;496 p->search_dirs_flag = false;567 p->just_syms_flag = FALSE; 568 p->search_dirs_flag = FALSE; 497 569 break; 498 570 case lang_input_file_is_l_enum: 499 p->is_archive = true;571 p->is_archive = TRUE; 500 572 p->filename = name; 501 p->real = true;573 p->real = TRUE; 502 574 p->local_sym_name = concat ("-l", name, (const char *) NULL); 503 p->just_syms_flag = false;504 p->search_dirs_flag = true;575 p->just_syms_flag = FALSE; 576 p->search_dirs_flag = TRUE; 505 577 break; 506 578 case lang_input_file_is_marker_enum: 507 579 p->filename = name; 508 p->is_archive = false;509 p->real = false;580 p->is_archive = FALSE; 581 p->real = FALSE; 510 582 p->local_sym_name = name; 511 p->just_syms_flag = false;512 p->search_dirs_flag = true;583 p->just_syms_flag = FALSE; 584 p->search_dirs_flag = TRUE; 513 585 break; 514 586 case lang_input_file_is_search_file_enum: 587 p->sysrooted = ldlang_sysrooted_script; 515 588 p->filename = name; 516 p->is_archive = false;517 p->real = true;589 p->is_archive = FALSE; 590 p->real = TRUE; 518 591 p->local_sym_name = name; 519 p->just_syms_flag = false;520 p->search_dirs_flag = true;592 p->just_syms_flag = FALSE; 593 p->search_dirs_flag = TRUE; 521 594 break; 522 595 case lang_input_file_is_file_enum: 523 596 p->filename = name; 524 p->is_archive = false;525 p->real = true;597 p->is_archive = FALSE; 598 p->real = TRUE; 526 599 p->local_sym_name = name; 527 p->just_syms_flag = false;528 p->search_dirs_flag = false;600 p->just_syms_flag = FALSE; 601 p->search_dirs_flag = FALSE; 529 602 break; 530 603 default: … … 538 611 p->dynamic = config.dynamic_link; 539 612 p->whole_archive = whole_archive; 540 p->loaded = false;613 p->loaded = FALSE; 541 614 lang_statement_append (&input_file_chain, 542 615 (lang_statement_union_type *) p, … … 551 624 const char *target; 552 625 { 553 lang_has_input_file = true;554 return new_afile (name, file_type, target, true);626 lang_has_input_file = TRUE; 627 return new_afile (name, file_type, target, TRUE); 555 628 } 556 629 … … 598 671 lang_memory_region_type *p; 599 672 673 /* NAME is NULL for LMA memspecs if no region was specified. */ 674 if (name == NULL) 675 return NULL; 676 600 677 for (p = lang_memory_region_list; 601 678 p != (lang_memory_region_type *) NULL; … … 638 715 new->length = ~(bfd_size_type) 0; 639 716 new->current = 0; 640 new->had_full_message = false;717 new->had_full_message = FALSE; 641 718 642 719 return new; … … 703 780 lookup->region = (lang_memory_region_type *) NULL; 704 781 lookup->lma_region = (lang_memory_region_type *) NULL; 705 lookup->fill = 0;782 lookup->fill = (fill_type *) 0; 706 783 lookup->block_value = 1; 707 784 lookup->name = name; … … 709 786 lookup->next = (lang_statement_union_type *) NULL; 710 787 lookup->bfd_section = (asection *) NULL; 711 lookup->processed = false;788 lookup->processed = FALSE; 712 789 lookup->sectype = normal_section; 713 790 lookup->addr_tree = (etree_type *) NULL; … … 719 796 lookup->section_alignment = -1; 720 797 lookup->load_base = (union etree_union *) NULL; 798 lookup->update_dot_tree = NULL; 721 799 lookup->phdrs = NULL; 722 800 … … 814 892 815 893 if (strcmp (s->name, DISCARD_SECTION_NAME) == 0) 816 einfo (_("%P%F: Illegal use of `%s' section "), DISCARD_SECTION_NAME);894 einfo (_("%P%F: Illegal use of `%s' section\n"), DISCARD_SECTION_NAME); 817 895 818 896 new = ((section_userdata_type *) … … 838 916 if (s->addr_tree != NULL) 839 917 exp_init_os (s->addr_tree); 918 919 if (s->load_base != NULL) 920 exp_init_os (s->load_base); 840 921 } 841 922 … … 936 1017 if (entry->just_syms_flag) 937 1018 { 938 sec->output_section = bfd_abs_section_ptr; 939 sec->output_offset = sec->vma; 1019 bfd_link_just_syms (sec, &link_info); 940 1020 return; 941 1021 } … … 960 1040 961 1041 Also, not merging link once sections in a relocatable link 962 causes trouble for MIPS ELF, which relies in link once semantics1042 causes trouble for MIPS ELF, which relies on link once semantics 963 1043 to handle the .reginfo section correctly. */ 964 1044 … … 967 1047 already_linked_list = 968 1048 ((struct already_linked_hash_entry *) 969 bfd_hash_lookup (&already_linked_table, name, true, false));1049 bfd_hash_lookup (&already_linked_table, name, TRUE, FALSE)); 970 1050 971 1051 for (l = already_linked_list->entry; l != NULL; l = l->next) … … 1009 1089 } 1010 1090 1011 /* Set the output_section field so that wild_doit does not 1012 create a lang_input_section structure for this section. 1013 Since there might be a symbol in the section being 1014 discarded, we must retain a pointer to the section which 1015 we are really going to use. */ 1091 /* Set the output_section field so that lang_add_section 1092 does not create a lang_input_section structure for this 1093 section. */ 1016 1094 sec->output_section = bfd_abs_section_ptr; 1017 sec->kept_section = l->sec; 1095 1096 if (flags & SEC_GROUP) 1097 bfd_discard_group (abfd, sec); 1018 1098 1019 1099 return; … … 1071 1151 foo.o(.text, .data). */ 1072 1152 1073 /* Return trueif the PATTERN argument is a wildcard pattern.1153 /* Return TRUE if the PATTERN argument is a wildcard pattern. 1074 1154 Although backslashes are treated specially if a pattern contains 1075 1155 wildcards, we do not consider the mere presence of a backslash to 1076 be enough to cause the thepattern to be treated as a wildcard.1156 be enough to cause the pattern to be treated as a wildcard. 1077 1157 That lets us handle DOS filenames more naturally. */ 1078 1158 1079 static b oolean1159 static bfd_boolean 1080 1160 wildcardp (pattern) 1081 1161 const char *pattern; … … 1087 1167 || *s == '*' 1088 1168 || *s == '[') 1089 return true;1090 return false;1169 return TRUE; 1170 return FALSE; 1091 1171 } 1092 1172 … … 1096 1176 1097 1177 void 1098 wild_doit(ptr, section, output, file)1178 lang_add_section (ptr, section, output, file) 1099 1179 lang_statement_list_type *ptr; 1100 1180 asection *section; … … 1103 1183 { 1104 1184 flagword flags; 1105 b oolean discard;1185 bfd_boolean discard; 1106 1186 1107 1187 flags = bfd_get_section_flags (section->owner, section); 1108 1188 1109 discard = false; 1110 1111 /* If we are doing a final link, discard sections marked with 1112 SEC_EXCLUDE. */ 1113 if (! link_info.relocateable 1114 && (flags & SEC_EXCLUDE) != 0) 1115 discard = true; 1189 discard = FALSE; 1190 1191 /* Discard sections marked with SEC_EXCLUDE if we are doing a final 1192 link. Discard debugging sections marked with SEC_EXCLUDE on a 1193 relocatable link too. */ 1194 if ((flags & SEC_EXCLUDE) != 0 1195 && ((flags & SEC_DEBUGGING) != 0 || !link_info.relocateable)) 1196 discard = TRUE; 1116 1197 1117 1198 /* Discard input sections which are assigned to a section named 1118 1199 DISCARD_SECTION_NAME. */ 1119 1200 if (strcmp (output->name, DISCARD_SECTION_NAME) == 0) 1120 discard = true;1201 discard = TRUE; 1121 1202 1122 1203 /* Discard debugging sections if we are stripping debugging … … 1124 1205 if ((link_info.strip == strip_debugger || link_info.strip == strip_all) 1125 1206 && (flags & SEC_DEBUGGING) != 0) 1126 discard = true;1207 discard = TRUE; 1127 1208 1128 1209 if (discard) … … 1138 1219 if (section->output_section == NULL) 1139 1220 { 1140 b oolean first;1221 bfd_boolean first; 1141 1222 lang_input_section_type *new; 1142 1223 flagword flags; … … 1181 1262 flags &= ~ SEC_READONLY; 1182 1263 1264 /* Keep SEC_MERGE and SEC_STRINGS only if they are the same. */ 1265 if (! first 1266 && ((section->output_section->flags & (SEC_MERGE | SEC_STRINGS)) 1267 != (flags & (SEC_MERGE | SEC_STRINGS)) 1268 || ((flags & SEC_MERGE) 1269 && section->output_section->entsize != section->entsize))) 1270 { 1271 section->output_section->flags &= ~ (SEC_MERGE | SEC_STRINGS); 1272 flags &= ~ (SEC_MERGE | SEC_STRINGS); 1273 } 1274 1275 /* For now make .tbss normal section. */ 1276 if ((flags & SEC_THREAD_LOCAL) && ! link_info.relocateable) 1277 flags |= SEC_LOAD; 1278 1183 1279 section->output_section->flags |= flags; 1280 1281 if (flags & SEC_MERGE) 1282 section->output_section->entsize = section->entsize; 1184 1283 1185 1284 /* If SEC_READONLY is not set in the input section, then clear … … 1211 1310 output->bfd_section->alignment_power = section->alignment_power; 1212 1311 1213 /* If supplied an alig ment, then force it. */1312 /* If supplied an alignment, then force it. */ 1214 1313 if (output->section_alignment != -1) 1215 1314 output->bfd_section->alignment_power = output->section_alignment; … … 1230 1329 1231 1330 static lang_statement_union_type * 1232 wild_sort (wild, file, section)1331 wild_sort (wild, sec, file, section) 1233 1332 lang_wild_statement_type *wild; 1333 struct wildcard_list *sec; 1234 1334 lang_input_statement_type *file; 1235 1335 asection *section; … … 1238 1338 lang_statement_union_type *l; 1239 1339 1240 if (! wild->filenames_sorted && ! wild->sections_sorted)1340 if (!wild->filenames_sorted && (sec == NULL || !sec->spec.sorted)) 1241 1341 return NULL; 1242 1342 1243 1343 section_name = bfd_get_section_name (file->the_bfd, section); 1244 for (l = wild->children.head; l != NULL; l = l-> next)1344 for (l = wild->children.head; l != NULL; l = l->header.next) 1245 1345 { 1246 1346 lang_input_section_type *ls; … … 1256 1356 { 1257 1357 const char *fn, *ln; 1258 b oolean fa, la;1358 bfd_boolean fa, la; 1259 1359 int i; 1260 1360 … … 1268 1368 { 1269 1369 fn = bfd_get_filename (bfd_my_archive (file->the_bfd)); 1270 fa = true;1370 fa = TRUE; 1271 1371 } 1272 1372 else 1273 1373 { 1274 1374 fn = file->filename; 1275 fa = false;1375 fa = FALSE; 1276 1376 } 1277 1377 … … 1280 1380 { 1281 1381 ln = bfd_get_filename (bfd_my_archive (ls->ifile->the_bfd)); 1282 la = true;1382 la = TRUE; 1283 1383 } 1284 1384 else 1285 1385 { 1286 1386 ln = ls->ifile->filename; 1287 la = false;1387 la = FALSE; 1288 1388 } 1289 1389 … … 1312 1412 looking at the sections for this file. */ 1313 1413 1314 if ( wild->sections_sorted)1414 if (sec != NULL && sec->spec.sorted) 1315 1415 { 1316 1416 if (strcmp (section_name, … … 1329 1429 1330 1430 static void 1331 output_section_callback (ptr, sec tion, file, output)1431 output_section_callback (ptr, sec, section, file, output) 1332 1432 lang_wild_statement_type *ptr; 1433 struct wildcard_list *sec; 1333 1434 asection *section; 1334 1435 lang_input_statement_type *file; … … 1336 1437 { 1337 1438 lang_statement_union_type *before; 1439 1440 /* Exclude sections that match UNIQUE_SECTION_LIST. */ 1441 if (unique_section_p (bfd_get_section_name (file->the_bfd, section))) 1442 return; 1338 1443 1339 1444 /* If the wild pattern was marked KEEP, the member sections … … 1342 1447 section->flags |= SEC_KEEP; 1343 1448 1344 before = wild_sort (ptr, file, section);1449 before = wild_sort (ptr, sec, file, section); 1345 1450 1346 1451 /* Here BEFORE points to the lang_input_section which … … 1350 1455 1351 1456 if (before == NULL) 1352 wild_doit(&ptr->children, section,1353 1354 1457 lang_add_section (&ptr->children, section, 1458 (lang_output_section_statement_type *) output, 1459 file); 1355 1460 else 1356 1461 { … … 1359 1464 1360 1465 lang_list_init (&list); 1361 wild_doit(&list, section,1362 1363 1466 lang_add_section (&list, section, 1467 (lang_output_section_statement_type *) output, 1468 file); 1364 1469 1365 1470 /* If we are discarding the section, LIST.HEAD will … … 1367 1472 if (list.head != NULL) 1368 1473 { 1369 ASSERT (list.head-> next == NULL);1474 ASSERT (list.head->header.next == NULL); 1370 1475 1371 1476 for (pp = &ptr->children.head; 1372 1477 *pp != before; 1373 pp = &(*pp)-> next)1478 pp = &(*pp)->header.next) 1374 1479 ASSERT (*pp != NULL); 1375 1480 1376 list.head-> next = *pp;1481 list.head->header.next = *pp; 1377 1482 *pp = list.head; 1378 1483 } … … 1404 1509 if (search == (lang_input_statement_type *) NULL) 1405 1510 search = new_afile (name, lang_input_file_is_file_enum, default_target, 1406 false);1511 FALSE); 1407 1512 1408 1513 /* If we have already added this file, or this file is not real … … 1414 1519 return search; 1415 1520 1416 load_symbols (search, (lang_statement_list_type *) NULL); 1521 if (! load_symbols (search, (lang_statement_list_type *) NULL)) 1522 return NULL; 1417 1523 1418 1524 return search; … … 1421 1527 /* Get the symbols for an input file. */ 1422 1528 1423 static void1529 static bfd_boolean 1424 1530 load_symbols (entry, place) 1425 1531 lang_input_statement_type *entry; … … 1429 1535 1430 1536 if (entry->loaded) 1431 return ;1537 return TRUE; 1432 1538 1433 1539 ldfile_open_file (entry); … … 1438 1544 bfd_error_type err; 1439 1545 lang_statement_list_type *hold; 1546 bfd_boolean bad_load = TRUE; 1547 bfd_boolean save_ldlang_sysrooted_script; 1440 1548 1441 1549 err = bfd_get_error (); … … 1443 1551 /* See if the emulation has some special knowledge. */ 1444 1552 if (ldemul_unrecognized_file (entry)) 1445 return ;1553 return TRUE; 1446 1554 1447 1555 if (err == bfd_error_file_ambiguously_recognized) … … 1457 1565 else if (err != bfd_error_file_not_recognized 1458 1566 || place == NULL) 1459 einfo (_("%F%B: file not recognized: %E\n"), entry->the_bfd); 1567 einfo (_("%F%B: file not recognized: %E\n"), entry->the_bfd); 1568 else 1569 bad_load = FALSE; 1460 1570 1461 1571 bfd_close (entry->the_bfd); … … 1467 1577 hold = stat_ptr; 1468 1578 stat_ptr = place; 1469 1470 ldfile_assumed_script = true; 1579 save_ldlang_sysrooted_script = ldlang_sysrooted_script; 1580 ldlang_sysrooted_script = entry->sysrooted; 1581 1582 ldfile_assumed_script = TRUE; 1471 1583 parser_input = input_script; 1472 1584 yyparse (); 1473 ldfile_assumed_script = false; 1474 1585 ldfile_assumed_script = FALSE; 1586 1587 ldlang_sysrooted_script = save_ldlang_sysrooted_script; 1475 1588 stat_ptr = hold; 1476 1589 1477 return ;1590 return ! bad_load; 1478 1591 } 1479 1592 1480 1593 if (ldemul_recognized_file (entry)) 1481 return ;1594 return TRUE; 1482 1595 1483 1596 /* We don't call ldlang_add_file for an archive. Instead, the … … 1499 1612 if (entry->whole_archive) 1500 1613 { 1501 bfd *member = bfd_openr_next_archived_file (entry->the_bfd, 1502 (bfd *) NULL); 1503 while (member != NULL) 1614 bfd *member = NULL; 1615 bfd_boolean loaded = TRUE; 1616 1617 for (;;) 1504 1618 { 1619 member = bfd_openr_next_archived_file (entry->the_bfd, member); 1620 1621 if (member == NULL) 1622 break; 1623 1505 1624 if (! bfd_check_format (member, bfd_object)) 1506 einfo (_("%F%B: object %B in archive is not object\n"), 1507 entry->the_bfd, member); 1625 { 1626 einfo (_("%F%B: member %B in archive is not an object\n"), 1627 entry->the_bfd, member); 1628 loaded = FALSE; 1629 } 1630 1508 1631 if (! ((*link_info.callbacks->add_archive_element) 1509 1632 (&link_info, member, "--whole-archive"))) 1510 1633 abort (); 1634 1511 1635 if (! bfd_link_add_symbols (member, &link_info)) 1512 einfo (_("%F%B: could not read symbols: %E\n"), member); 1513 member = bfd_openr_next_archived_file (entry->the_bfd, 1514 member); 1636 { 1637 einfo (_("%F%B: could not read symbols: %E\n"), member); 1638 loaded = FALSE; 1639 } 1515 1640 } 1516 1641 1517 entry->loaded = true; 1518 1519 return; 1520 } 1521 } 1522 1523 if (! bfd_link_add_symbols (entry->the_bfd, &link_info)) 1642 entry->loaded = loaded; 1643 return loaded; 1644 } 1645 break; 1646 } 1647 1648 if (bfd_link_add_symbols (entry->the_bfd, &link_info)) 1649 entry->loaded = TRUE; 1650 else 1524 1651 einfo (_("%F%B: could not read symbols: %E\n"), entry->the_bfd); 1525 1652 1526 entry->loaded = true; 1527 } 1528 1529 /* Handle a wild statement. SECTION or FILE or both may be NULL, 1530 indicating that it is a wildcard. Separate lang_input_section 1531 statements are created for each part of the expansion; they are 1532 added after the wild statement S. OUTPUT is the output section. */ 1653 return entry->loaded; 1654 } 1655 1656 /* Handle a wild statement. S->FILENAME or S->SECTION_LIST or both 1657 may be NULL, indicating that it is a wildcard. Separate 1658 lang_input_section statements are created for each part of the 1659 expansion; they are added after the wild statement S. OUTPUT is 1660 the output section. */ 1533 1661 1534 1662 static void 1535 wild (s, section, file,target, output)1663 wild (s, target, output) 1536 1664 lang_wild_statement_type *s; 1537 const char *section;1538 const char *file;1539 1665 const char *target ATTRIBUTE_UNUSED; 1540 1666 lang_output_section_statement_type *output; 1541 1667 { 1542 walk_wild (s, section, file, output_section_callback, (PTR) output); 1543 1544 if (section != (char *) NULL 1545 && strcmp (section, "COMMON") == 0 1546 && default_common_section == NULL) 1547 { 1548 /* Remember the section that common is going to in case we later 1549 get something which doesn't know where to put it. */ 1550 default_common_section = output; 1551 } 1552 } 1553 1554 /* Return true iff target is the sought target. */ 1668 struct wildcard_list *sec; 1669 1670 walk_wild (s, output_section_callback, (PTR) output); 1671 1672 for (sec = s->section_list; sec != NULL; sec = sec->next) 1673 { 1674 if (default_common_section != NULL) 1675 break; 1676 if (sec->spec.name != NULL && strcmp (sec->spec.name, "COMMON") == 0) 1677 { 1678 /* Remember the section that common is going to in case we 1679 later get something which doesn't know where to put it. */ 1680 default_common_section = output; 1681 } 1682 } 1683 } 1684 1685 /* Return TRUE iff target is the sought target. */ 1555 1686 1556 1687 static int … … 1574 1705 1575 1706 while ((c = *src++) != 0) 1576 { 1577 if (isupper ((unsigned char) c)) 1578 c = tolower (c); 1579 1580 *dest++ = c; 1581 } 1707 *dest++ = TOLOWER (c); 1582 1708 1583 1709 *dest = 0; 1584 1710 } 1585 1711 1586 /* Remove the first occur ance of needle (if any) in haystack1712 /* Remove the first occurrence of needle (if any) in haystack 1587 1713 from haystack. */ 1588 1714 … … 1717 1843 } 1718 1844 1845 const char * 1846 lang_get_output_target () 1847 { 1848 const char *target; 1849 1850 /* Has the user told us which output format to use? */ 1851 if (output_target != (char *) NULL) 1852 return output_target; 1853 1854 /* No - has the current target been set to something other than 1855 the default? */ 1856 if (current_target != default_target) 1857 return current_target; 1858 1859 /* No - can we determine the format of the first input file? */ 1860 target = get_first_input_target (); 1861 if (target != NULL) 1862 return target; 1863 1864 /* Failed - use the default output target. */ 1865 return default_target; 1866 } 1867 1719 1868 /* Open the output file. */ 1720 1869 … … 1725 1874 bfd *output; 1726 1875 1727 /* Has the user told us which output format to use? */ 1728 if (output_target == (char *) NULL) 1729 { 1730 /* No - has the current target been set to something other than 1731 the default? */ 1732 if (current_target != default_target) 1733 output_target = current_target; 1734 1735 /* No - can we determine the format of the first input file? */ 1736 else 1737 { 1738 output_target = get_first_input_target (); 1739 1740 /* Failed - use the default output target. */ 1741 if (output_target == NULL) 1742 output_target = default_target; 1743 } 1744 } 1876 output_target = lang_get_output_target (); 1745 1877 1746 1878 /* Has the user requested a particular endianness on the command … … 1802 1934 } 1803 1935 1804 delete_output_file_on_failure = true;1936 delete_output_file_on_failure = TRUE; 1805 1937 1806 1938 #if 0 … … 1860 1992 open_input_bfds (s, force) 1861 1993 lang_statement_union_type *s; 1862 b oolean force;1863 { 1864 for (; s != (lang_statement_union_type *) NULL; s = s-> next)1994 bfd_boolean force; 1995 { 1996 for (; s != (lang_statement_union_type *) NULL; s = s->header.next) 1865 1997 { 1866 1998 switch (s->header.type) … … 1890 2022 { 1891 2023 undefs = link_info.hash->undefs_tail; 1892 open_input_bfds (s->group_statement.children.head, true);2024 open_input_bfds (s->group_statement.children.head, TRUE); 1893 2025 } 1894 2026 while (undefs != link_info.hash->undefs_tail); … … 1914 2046 && bfd_check_format (s->input_statement.the_bfd, 1915 2047 bfd_archive)) 1916 s->input_statement.loaded = false;2048 s->input_statement.loaded = FALSE; 1917 2049 1918 2050 lang_list_init (&add); 1919 2051 1920 load_symbols (&s->input_statement, &add); 2052 if (! load_symbols (&s->input_statement, &add)) 2053 config.make_executable = FALSE; 1921 2054 1922 2055 if (add.head != NULL) 1923 2056 { 1924 *add.tail = s-> next;1925 s-> next = add.head;2057 *add.tail = s->header.next; 2058 s->header.next = add.head; 1926 2059 } 1927 2060 } … … 1945 2078 default_common_section = lang_output_section_statement_lookup (".bss"); 1946 2079 1947 if ( placed_commons == false)2080 if (!placed_commons) 1948 2081 { 1949 2082 lang_wild_statement_type *new = … … 1959 2092 1960 2093 /* Add the supplied name to the symbol table as an undefined reference. 1961 Remove items from the chain as we open input bfds. */1962 typedef struct ldlang_undef_chain_list 1963 { 1964 struct ldlang_undef_chain_list *next;1965 char *name; 1966 }ldlang_undef_chain_list_type;1967 1968 static ldlang_undef_chain_list_type *ldlang_undef_chain_list_head; 2094 This is a two step process as the symbol table doesn't even exist at 2095 the time the ld command line is processed. First we put the name 2096 on a list, then, once the output file has been opened, transfer the 2097 name to the symbol table. */ 2098 2099 typedef struct bfd_sym_chain ldlang_undef_chain_list_type; 2100 2101 #define ldlang_undef_chain_list_head entry_symbol.next 1969 2102 1970 2103 void … … 1980 2113 1981 2114 new->name = xstrdup (name); 2115 2116 if (output_bfd != NULL) 2117 insert_undefined (new->name); 2118 } 2119 2120 /* Insert NAME as undefined in the symbol table. */ 2121 2122 static void 2123 insert_undefined (name) 2124 const char *name; 2125 { 2126 struct bfd_link_hash_entry *h; 2127 2128 h = bfd_link_hash_lookup (link_info.hash, name, TRUE, FALSE, TRUE); 2129 if (h == (struct bfd_link_hash_entry *) NULL) 2130 einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); 2131 if (h->type == bfd_link_hash_new) 2132 { 2133 h->type = bfd_link_hash_undefined; 2134 h->u.undef.abfd = NULL; 2135 bfd_link_add_undef (link_info.hash, h); 2136 } 1982 2137 } 1983 2138 … … 1995 2150 ptr = ptr->next) 1996 2151 { 1997 struct bfd_link_hash_entry *h; 1998 1999 h = bfd_link_hash_lookup (link_info.hash, ptr->name, true, false, true); 2000 if (h == (struct bfd_link_hash_entry *) NULL) 2001 einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); 2002 if (h->type == bfd_link_hash_new) 2003 { 2004 h->type = bfd_link_hash_undefined; 2005 h->u.undef.abfd = NULL; 2006 bfd_link_add_undef (link_info.hash, h); 2007 } 2008 } 2009 } 2010 2011 /* Open input files and attatch to output sections. */ 2152 insert_undefined (ptr->name); 2153 } 2154 } 2155 2156 /* Open input files and attach to output sections. */ 2012 2157 2013 2158 static void … … 2017 2162 lang_output_section_statement_type *output_section_statement; 2018 2163 { 2019 for (; s != (lang_statement_union_type *) NULL; s = s-> next)2164 for (; s != (lang_statement_union_type *) NULL; s = s->header.next) 2020 2165 { 2021 2166 switch (s->header.type) 2022 2167 { 2023 2024 2168 case lang_wild_statement_enum: 2025 wild (&s->wild_statement, s->wild_statement.section_name, 2026 s->wild_statement.filename, target, 2027 output_section_statement); 2028 2169 wild (&s->wild_statement, target, output_section_statement); 2029 2170 break; 2030 2171 case lang_constructors_statement_enum: … … 2083 2224 } 2084 2225 break; 2226 } 2227 } 2228 } 2229 2230 /* An output section might have been removed after its statement was 2231 added. For example, ldemul_before_allocation can remove dynamic 2232 sections if they turn out to be not needed. Clean them up here. */ 2233 2234 static void 2235 strip_excluded_output_sections () 2236 { 2237 lang_statement_union_type *u; 2238 2239 for (u = lang_output_section_statement.head; 2240 u != NULL; 2241 u = u->output_section_statement.next) 2242 { 2243 lang_output_section_statement_type *os; 2244 asection *s; 2245 2246 os = &u->output_section_statement; 2247 s = os->bfd_section; 2248 if (s != NULL && (s->flags & SEC_EXCLUDE) != 0) 2249 { 2250 asection **p; 2251 2252 os->bfd_section = NULL; 2253 2254 for (p = &output_bfd->sections; *p; p = &(*p)->next) 2255 if (*p == s) 2256 { 2257 bfd_section_list_remove (output_bfd, p); 2258 output_bfd->section_count--; 2259 break; 2260 } 2085 2261 } 2086 2262 } … … 2147 2323 lang_final_phase_enum, print_dot, &print_dot); 2148 2324 if (result.valid_p) 2149 minfo ("0x%V", result.value + result.section->bfd_section->vma); 2325 { 2326 const char *dst; 2327 bfd_vma value; 2328 2329 value = result.value + result.section->bfd_section->vma; 2330 dst = assignment->exp->assign.dst; 2331 2332 minfo ("0x%V", value); 2333 if (dst[0] == '.' && dst[1] == 0) 2334 print_dot = value; 2335 } 2150 2336 else 2151 2337 { … … 2176 2362 via bfd_link_hash_traverse. */ 2177 2363 2178 static b oolean2364 static bfd_boolean 2179 2365 print_one_symbol (hash_entry, ptr) 2180 2366 struct bfd_link_hash_entry *hash_entry; … … 2199 2385 } 2200 2386 2201 return true;2387 return TRUE; 2202 2388 } 2203 2389 … … 2266 2452 lang_fill_statement_type *fill; 2267 2453 { 2268 fprintf (config.map_file, " FILL mask 0x%x\n", fill->fill); 2454 size_t size; 2455 unsigned char *p; 2456 fputs (" FILL mask 0x", config.map_file); 2457 for (p = fill->fill->data, size = fill->fill->size; size != 0; p++, size--) 2458 fprintf (config.map_file, "%02x", *p); 2459 fputs ("\n", config.map_file); 2269 2460 } 2270 2461 … … 2395 2586 if (s->output_section != NULL) 2396 2587 addr += s->output_section->vma; 2397 minfo ("0x%V %W", addr, s->size); 2398 2399 if (s->fill != 0) 2400 minfo (" %u", s->fill); 2588 minfo ("0x%V %W ", addr, s->size); 2589 2590 if (s->fill->size != 0) 2591 { 2592 size_t size; 2593 unsigned char *p; 2594 for (p = s->fill->data, size = s->fill->size; size != 0; p++, size--) 2595 fprintf (config.map_file, "%02x", *p); 2596 } 2401 2597 2402 2598 print_nl (); … … 2410 2606 lang_output_section_statement_type *os; 2411 2607 { 2608 struct wildcard_list *sec; 2609 2412 2610 print_space (); 2413 2611 2414 2612 if (w->filenames_sorted) 2415 2613 minfo ("SORT("); 2416 if (w->exclude_filename_list != NULL)2417 {2418 name_list *tmp;2419 minfo ("EXCLUDE_FILE ( %s", w->exclude_filename_list->name);2420 for (tmp = w->exclude_filename_list->next; tmp; tmp = tmp->next)2421 minfo (", %s", tmp->name);2422 minfo (")");2423 }2424 2614 if (w->filename != NULL) 2425 2615 minfo ("%s", w->filename); … … 2430 2620 2431 2621 minfo ("("); 2432 if (w->sections_sorted) 2433 minfo ("SORT("); 2434 if (w->section_name != NULL) 2435 minfo ("%s", w->section_name); 2436 else 2437 minfo ("*"); 2438 if (w->sections_sorted) 2439 minfo (")"); 2622 for (sec = w->section_list; sec; sec = sec->next) 2623 { 2624 if (sec->spec.sorted) 2625 minfo ("SORT("); 2626 if (sec->spec.exclude_name_list != NULL) 2627 { 2628 name_list *tmp; 2629 minfo ("EXCLUDE_FILE(%s", sec->spec.exclude_name_list->name); 2630 for (tmp = sec->spec.exclude_name_list->next; tmp; tmp = tmp->next) 2631 minfo (" %s", tmp->name); 2632 minfo (") "); 2633 } 2634 if (sec->spec.name != NULL) 2635 minfo ("%s", sec->spec.name); 2636 else 2637 minfo ("*"); 2638 if (sec->spec.sorted) 2639 minfo (")"); 2640 if (sec->next) 2641 minfo (" "); 2642 } 2440 2643 minfo (")"); 2441 2644 … … 2468 2671 { 2469 2672 print_statement (s, os); 2470 s = s-> next;2673 s = s->header.next; 2471 2674 } 2472 2675 } … … 2574 2777 { 2575 2778 print_statement (s, abs_output_section); 2576 s = s-> next;2779 s = s->header.next; 2577 2780 } 2578 2781 } … … 2581 2784 } 2582 2785 2786 static void 2787 insert_pad (ptr, fill, alignment_needed, output_section, dot) 2788 lang_statement_union_type **ptr; 2789 fill_type *fill; 2790 unsigned int alignment_needed; 2791 asection *output_section; 2792 bfd_vma dot; 2793 { 2794 static fill_type zero_fill = { 1, { 0 } }; 2795 lang_statement_union_type *pad; 2796 2797 pad = ((lang_statement_union_type *) 2798 ((char *) ptr - offsetof (lang_statement_union_type, header.next))); 2799 if (ptr != &statement_list.head 2800 && pad->header.type == lang_padding_statement_enum 2801 && pad->padding_statement.output_section == output_section) 2802 { 2803 /* Use the existing pad statement. The above test on output 2804 section is probably redundant, but it doesn't hurt to check. */ 2805 } 2806 else 2807 { 2808 /* Make a new padding statement, linked into existing chain. */ 2809 pad = ((lang_statement_union_type *) 2810 stat_alloc (sizeof (lang_padding_statement_type))); 2811 pad->header.next = *ptr; 2812 *ptr = pad; 2813 pad->header.type = lang_padding_statement_enum; 2814 pad->padding_statement.output_section = output_section; 2815 if (fill == (fill_type *) 0) 2816 fill = &zero_fill; 2817 pad->padding_statement.fill = fill; 2818 } 2819 pad->padding_statement.output_offset = dot - output_section->vma; 2820 pad->padding_statement.size = alignment_needed; 2821 output_section->_raw_size += alignment_needed; 2822 } 2823 2824 /* Work out how much this section will move the dot point. */ 2825 2583 2826 static bfd_vma 2584 insert_pad (this_ptr, fill, power, output_section_statement, dot) 2585 lang_statement_union_type **this_ptr; 2586 fill_type fill; 2587 unsigned int power; 2588 asection *output_section_statement; 2589 bfd_vma dot; 2590 { 2591 /* Align this section first to the 2592 input sections requirement, then 2593 to the output section's requirement. 2594 If this alignment is > than any seen before, 2595 then record it too. Perform the alignment by 2596 inserting a magic 'padding' statement. */ 2597 2598 unsigned opb = bfd_arch_mach_octets_per_byte (ldfile_output_architecture, 2599 ldfile_output_machine); 2600 unsigned int alignment_needed = align_power (dot, power) - dot; 2601 2602 if (alignment_needed != 0) 2603 { 2604 lang_statement_union_type *new = 2605 ((lang_statement_union_type *) 2606 stat_alloc (sizeof (lang_padding_statement_type))); 2607 2608 /* Link into existing chain. */ 2609 new->header.next = *this_ptr; 2610 *this_ptr = new; 2611 new->header.type = lang_padding_statement_enum; 2612 new->padding_statement.output_section = output_section_statement; 2613 new->padding_statement.output_offset = 2614 dot - output_section_statement->vma; 2615 new->padding_statement.fill = fill; 2616 new->padding_statement.size = alignment_needed * opb; 2617 } 2618 2619 /* Remember the most restrictive alignment. */ 2620 if (power > output_section_statement->alignment_power) 2621 { 2622 output_section_statement->alignment_power = power; 2623 } 2624 output_section_statement->_raw_size += alignment_needed * opb; 2625 2626 return dot + alignment_needed; 2627 } 2628 2629 /* Work out how much this section will move the dot point. */ 2630 2631 static bfd_vma 2632 size_input_section (this_ptr, output_section_statement, fill, dot, relax) 2827 size_input_section (this_ptr, output_section_statement, fill, dot) 2633 2828 lang_statement_union_type **this_ptr; 2634 2829 lang_output_section_statement_type *output_section_statement; 2635 fill_type fill;2830 fill_type *fill; 2636 2831 bfd_vma dot; 2637 boolean relax ATTRIBUTE_UNUSED;2638 2832 { 2639 2833 lang_input_section_type *is = &((*this_ptr)->input_section); 2640 2834 asection *i = is->section; 2641 unsigned opb = bfd_arch_mach_octets_per_byte (ldfile_output_architecture, 2642 ldfile_output_machine); 2643 2644 if (is->ifile->just_syms_flag == false) 2645 { 2835 2836 if (!is->ifile->just_syms_flag) 2837 { 2838 unsigned opb = bfd_arch_mach_octets_per_byte (ldfile_output_architecture, 2839 ldfile_output_machine); 2840 unsigned int alignment_needed; 2841 asection *o; 2842 2843 /* Align this section first to the input sections requirement, 2844 then to the output section's requirement. If this alignment 2845 is greater than any seen before, then record it too. Perform 2846 the alignment by inserting a magic 'padding' statement. */ 2847 2646 2848 if (output_section_statement->subsection_alignment != -1) 2647 i->alignment_power = 2648 output_section_statement->subsection_alignment; 2649 2650 dot = insert_pad (this_ptr, fill, i->alignment_power, 2651 output_section_statement->bfd_section, dot); 2849 i->alignment_power = output_section_statement->subsection_alignment; 2850 2851 o = output_section_statement->bfd_section; 2852 if (o->alignment_power < i->alignment_power) 2853 o->alignment_power = i->alignment_power; 2854 2855 alignment_needed = align_power (dot, i->alignment_power) - dot; 2856 2857 if (alignment_needed != 0) 2858 { 2859 insert_pad (this_ptr, fill, alignment_needed * opb, o, dot); 2860 dot += alignment_needed; 2861 } 2652 2862 2653 2863 /* Remember where in the output section this input section goes. */ 2654 2864 2655 i->output_offset = dot - o utput_section_statement->bfd_section->vma;2865 i->output_offset = dot - o->vma; 2656 2866 2657 2867 /* Mark how big the output section must be to contain this now. */ … … 2660 2870 else 2661 2871 dot += i->_raw_size / opb; 2662 output_section_statement->bfd_section->_raw_size = 2663 (dot - output_section_statement->bfd_section->vma) * opb; 2872 o->_raw_size = (dot - o->vma) * opb; 2664 2873 } 2665 2874 else … … 2732 2941 } 2733 2942 2734 /* This variable indicates whether bfd_relax_section should be called2735 again. */2736 2737 static boolean relax_again;2738 2739 2943 /* Make sure the new address is within the region. We explicitly permit the 2740 2944 current address to be at the exact end of the region when the address is … … 2752 2956 || (region->current - region->origin > region->length)) 2753 2957 && ((region->current != region->origin + region->length) 2754 2958 || base == 0)) 2755 2959 { 2756 2960 if (tree != (etree_type *) NULL) 2757 2758 2759 2760 2761 2762 2763 2961 { 2962 einfo (_("%X%P: address 0x%v of %B section %s is not within region %s\n"), 2963 region->current, 2964 os->bfd_section->owner, 2965 os->bfd_section->name, 2966 region->name); 2967 } 2764 2968 else 2765 2766 2767 2768 2769 2770 2969 { 2970 einfo (_("%X%P: region %s is full (%B section %s)\n"), 2971 region->name, 2972 os->bfd_section->owner, 2973 os->bfd_section->name); 2974 } 2771 2975 /* Reset the region pointer. */ 2772 2976 region->current = region->origin; … … 2776 2980 /* Set the sizes for all the output sections. */ 2777 2981 2778 bfd_vma 2779 lang_size_sections (s, output_section_statement, prev, fill, dot, relax) 2982 static bfd_vma 2983 lang_size_sections_1 (s, output_section_statement, prev, fill, dot, relax, 2984 check_regions) 2780 2985 lang_statement_union_type *s; 2781 2986 lang_output_section_statement_type *output_section_statement; 2782 2987 lang_statement_union_type **prev; 2783 fill_type fill;2988 fill_type *fill; 2784 2989 bfd_vma dot; 2785 boolean relax; 2990 bfd_boolean *relax; 2991 bfd_boolean check_regions; 2786 2992 { 2787 2993 unsigned opb = bfd_arch_mach_octets_per_byte (ldfile_output_architecture, … … 2789 2995 2790 2996 /* Size up the sections from their constituent parts. */ 2791 for (; s != (lang_statement_union_type *) NULL; s = s-> next)2997 for (; s != (lang_statement_union_type *) NULL; s = s->header.next) 2792 2998 { 2793 2999 switch (s->header.type) … … 2812 3018 2813 3019 if (os->children.head == NULL 2814 || os->children.head-> next != NULL3020 || os->children.head->header.next != NULL 2815 3021 || os->children.head->header.type != lang_input_section_enum) 2816 3022 einfo (_("%P%X: Internal error on COFF shared library section %s\n"), … … 2850 3056 if ((bfd_get_section_flags (output_bfd, os->bfd_section) 2851 3057 & (SEC_ALLOC | SEC_LOAD)) != 0 3058 && (bfd_get_section_flags (output_bfd, os->bfd_section) 3059 & SEC_NEVER_LOAD) == 0 2852 3060 && ! link_info.relocateable 3061 && check_regions 2853 3062 && strcmp (os->region->name, "*default*") == 0 2854 3063 && lang_memory_region_list != NULL … … 2883 3092 lang_allocating_phase_enum, 2884 3093 dot, &dot); 2885 if (r.valid_p == false) 2886 { 2887 einfo (_("%F%S: non constant address expression for section %s\n"), 2888 os->name); 2889 } 3094 if (!r.valid_p) 3095 einfo (_("%F%S: non constant address expression for section %s\n"), 3096 os->name); 3097 2890 3098 dot = r.value + r.section->bfd_section->vma; 2891 3099 } … … 2902 3110 } 2903 3111 2904 (void) lang_size_sections (os->children.head, os, 2905 &os->children.head, 2906 os->fill, dot, relax); 3112 lang_size_sections_1 (os->children.head, os, &os->children.head, 3113 os->fill, dot, relax, check_regions); 2907 3114 2908 3115 /* Put the section within the requested block size, or 2909 3116 align at the block boundary. */ 2910 after = ALIGN_N(os->bfd_section->vma3117 after = align_n (os->bfd_section->vma 2911 3118 + os->bfd_section->_raw_size / opb, 2912 /* The coercion here is important, see ld.h. */2913 3119 (bfd_vma) os->block_value); 2914 3120 2915 3121 if (bfd_is_abs_section (os->bfd_section)) 2916 3122 ASSERT (after == os->bfd_section->vma); 3123 else if ((os->bfd_section->flags & SEC_HAS_CONTENTS) == 0 3124 && (os->bfd_section->flags & SEC_THREAD_LOCAL) 3125 && ! link_info.relocateable) 3126 os->bfd_section->_raw_size = 0; 2917 3127 else 2918 3128 os->bfd_section->_raw_size = 2919 3129 (after - os->bfd_section->vma) * opb; 3130 2920 3131 dot = os->bfd_section->vma + os->bfd_section->_raw_size / opb; 2921 os->processed = true; 3132 os->processed = TRUE; 3133 3134 if (os->update_dot_tree != 0) 3135 exp_fold_tree (os->update_dot_tree, abs_output_section, 3136 lang_allocating_phase_enum, dot, &dot); 2922 3137 2923 3138 /* Update dot in the region ? … … 2937 3152 os->region->current = dot; 2938 3153 2939 /* Make sure the new address is within the region. */ 2940 os_region_check (os, os->region, os->addr_tree, 2941 os->bfd_section->vma); 3154 if (check_regions) 3155 /* Make sure the new address is within the region. */ 3156 os_region_check (os, os->region, os->addr_tree, 3157 os->bfd_section->vma); 2942 3158 2943 3159 /* If there's no load address specified, use the run … … 2946 3162 os->lma_region = os->region; 2947 3163 2948 if (os->lma_region != NULL )3164 if (os->lma_region != NULL && os->lma_region != os->region) 2949 3165 { 2950 if (os->load_base != NULL) 2951 { 2952 einfo (_("%X%P: use an absolute load address or a load memory region, not both\n")); 2953 } 2954 else 2955 { 2956 /* Don't allocate twice. */ 2957 if (os->lma_region != os->region) 2958 { 2959 /* Set load_base, which will be handled later. */ 2960 os->load_base = 2961 exp_intop (os->lma_region->current); 2962 os->lma_region->current += 2963 os->bfd_section->_raw_size / opb; 2964 os_region_check (os, os->lma_region, NULL, 2965 os->bfd_section->lma); 2966 } 2967 } 3166 /* Set load_base, which will be handled later. */ 3167 os->load_base = exp_intop (os->lma_region->current); 3168 os->lma_region->current += 3169 os->bfd_section->_raw_size / opb; 3170 if (check_regions) 3171 os_region_check (os, os->lma_region, NULL, 3172 os->bfd_section->lma); 2968 3173 } 2969 3174 } … … 2972 3177 2973 3178 case lang_constructors_statement_enum: 2974 dot = lang_size_sections (constructor_list.head, 2975 output_section_statement, 2976 &s->wild_statement.children.head, 2977 fill, 2978 dot, relax); 3179 dot = lang_size_sections_1 (constructor_list.head, 3180 output_section_statement, 3181 &s->wild_statement.children.head, 3182 fill, dot, relax, check_regions); 2979 3183 break; 2980 3184 … … 3037 3241 case lang_wild_statement_enum: 3038 3242 3039 dot = lang_size_sections (s->wild_statement.children.head,3040 output_section_statement,3041 &s->wild_statement.children.head,3042 fill, dot, relax);3243 dot = lang_size_sections_1 (s->wild_statement.children.head, 3244 output_section_statement, 3245 &s->wild_statement.children.head, 3246 fill, dot, relax, check_regions); 3043 3247 3044 3248 break; … … 3063 3267 else 3064 3268 { 3065 b oolean again;3269 bfd_boolean again; 3066 3270 3067 3271 if (! bfd_relax_section (i->owner, i, &link_info, &again)) 3068 3272 einfo (_("%P%F: can't relax section: %E\n")); 3069 3273 if (again) 3070 relax_again = true;3274 *relax = TRUE; 3071 3275 } 3072 dot = size_input_section (prev, 3073 output_section_statement, 3074 output_section_statement->fill, 3075 dot, relax); 3276 dot = size_input_section (prev, output_section_statement, 3277 output_section_statement->fill, dot); 3076 3278 } 3077 3279 break; … … 3096 3298 if (newdot != dot) 3097 3299 { 3098 /* The assignment changed dot. Insert a pad. */3099 3300 if (output_section_statement == abs_output_section) 3100 3301 { … … 3103 3304 lang_memory_region_lookup ("*default*")->current = newdot; 3104 3305 } 3105 else if (!relax)3306 else 3106 3307 { 3107 lang_statement_union_type *new = 3108 ((lang_statement_union_type *) 3109 stat_alloc (sizeof (lang_padding_statement_type))); 3110 3111 /* Link into existing chain. */ 3112 new->header.next = *prev; 3113 *prev = new; 3114 new->header.type = lang_padding_statement_enum; 3115 new->padding_statement.output_section = 3116 output_section_statement->bfd_section; 3117 new->padding_statement.output_offset = 3118 dot - output_section_statement->bfd_section->vma; 3119 new->padding_statement.fill = fill; 3120 new->padding_statement.size = (newdot - dot) * opb; 3121 output_section_statement->bfd_section->_raw_size += 3122 new->padding_statement.size; 3308 /* Insert a pad after this statement. We can't 3309 put the pad before when relaxing, in case the 3310 assignment references dot. */ 3311 insert_pad (&s->header.next, fill, (newdot - dot) * opb, 3312 output_section_statement->bfd_section, dot); 3313 3314 /* Don't neuter the pad below when relaxing. */ 3315 s = s->header.next; 3123 3316 } 3124 3317 … … 3129 3322 3130 3323 case lang_padding_statement_enum: 3131 /* If we are relaxing, and this is not the first pass, some 3132 padding statements may have been inserted during previous 3133 passes. We may have to move the padding statement to a new 3134 location if dot has a different value at this point in this 3135 pass than it did at this point in the previous pass. */ 3136 s->padding_statement.output_offset = 3137 dot - output_section_statement->bfd_section->vma; 3138 dot += s->padding_statement.size / opb; 3139 output_section_statement->bfd_section->_raw_size += 3140 s->padding_statement.size; 3324 /* If this is the first time lang_size_sections is called, 3325 we won't have any padding statements. If this is the 3326 second or later passes when relaxing, we should allow 3327 padding to shrink. If padding is needed on this pass, it 3328 will be added back in. */ 3329 s->padding_statement.size = 0; 3330 3331 /* Make sure output_offset is valid. If relaxation shrinks 3332 the section and this pad isn't needed, it's possible to 3333 have output_offset larger than the final size of the 3334 section. bfd_set_section_contents will complain even for 3335 a pad size of zero. */ 3336 s->padding_statement.output_offset 3337 = dot - output_section_statement->bfd_section->vma; 3141 3338 break; 3142 3339 3143 3340 case lang_group_statement_enum: 3144 dot = lang_size_sections (s->group_statement.children.head,3145 output_section_statement,3146 &s->group_statement.children.head,3147 fill, dot, relax);3341 dot = lang_size_sections_1 (s->group_statement.children.head, 3342 output_section_statement, 3343 &s->group_statement.children.head, 3344 fill, dot, relax, check_regions); 3148 3345 break; 3149 3346 … … 3152 3349 break; 3153 3350 3154 /* This can only get here when relaxing is turned on. */ 3155 3351 /* We can only get here when relaxing is turned on. */ 3156 3352 case lang_address_statement_enum: 3157 3353 break; … … 3160 3356 } 3161 3357 return dot; 3358 } 3359 3360 bfd_vma 3361 lang_size_sections (s, output_section_statement, prev, fill, dot, relax, 3362 check_regions) 3363 lang_statement_union_type *s; 3364 lang_output_section_statement_type *output_section_statement; 3365 lang_statement_union_type **prev; 3366 fill_type *fill; 3367 bfd_vma dot; 3368 bfd_boolean *relax; 3369 bfd_boolean check_regions; 3370 { 3371 bfd_vma result; 3372 3373 exp_data_seg.phase = exp_dataseg_none; 3374 result = lang_size_sections_1 (s, output_section_statement, prev, fill, 3375 dot, relax, check_regions); 3376 if (exp_data_seg.phase == exp_dataseg_end_seen) 3377 { 3378 /* If DATA_SEGMENT_ALIGN DATA_SEGMENT_END pair was seen, check whether 3379 a page could be saved in the data segment. */ 3380 bfd_vma first, last; 3381 3382 first = -exp_data_seg.base & (exp_data_seg.pagesize - 1); 3383 last = exp_data_seg.end & (exp_data_seg.pagesize - 1); 3384 if (first && last 3385 && ((exp_data_seg.base & ~(exp_data_seg.pagesize - 1)) 3386 != (exp_data_seg.end & ~(exp_data_seg.pagesize - 1))) 3387 && first + last <= exp_data_seg.pagesize) 3388 { 3389 exp_data_seg.phase = exp_dataseg_adjust; 3390 result = lang_size_sections_1 (s, output_section_statement, prev, 3391 fill, dot, relax, check_regions); 3392 } 3393 } 3394 3395 return result; 3162 3396 } 3163 3397 … … 3166 3400 lang_statement_union_type *s; 3167 3401 lang_output_section_statement_type *output_section_statement; 3168 fill_type fill;3402 fill_type *fill; 3169 3403 bfd_vma dot; 3170 3404 { … … 3172 3406 ldfile_output_machine); 3173 3407 3174 for (; s != (lang_statement_union_type *) NULL; s = s-> next)3408 for (; s != (lang_statement_union_type *) NULL; s = s->header.next) 3175 3409 { 3176 3410 switch (s->header.type) … … 3232 3466 lang_final_phase_enum, dot, &dot); 3233 3467 s->data_statement.value = value.value; 3234 if ( value.valid_p == false)3468 if (!value.valid_p) 3235 3469 einfo (_("%F%P: invalid data statement\n")); 3236 3470 } 3237 3238 3471 { 3472 unsigned int size; 3239 3473 switch (s->data_statement.type) 3240 3474 { … … 3269 3503 lang_final_phase_enum, dot, &dot); 3270 3504 s->reloc_statement.addend_value = value.value; 3271 if ( value.valid_p == false)3505 if (!value.valid_p) 3272 3506 einfo (_("%F%P: invalid reloc statement\n")); 3273 3507 } … … 3348 3582 3349 3583 sprintf (buf, ".startof.%s", secname); 3350 h = bfd_link_hash_lookup (link_info.hash, buf, false, false, true);3584 h = bfd_link_hash_lookup (link_info.hash, buf, FALSE, FALSE, TRUE); 3351 3585 if (h != NULL && h->type == bfd_link_hash_undefined) 3352 3586 { … … 3357 3591 3358 3592 sprintf (buf, ".sizeof.%s", secname); 3359 h = bfd_link_hash_lookup (link_info.hash, buf, false, false, true);3593 h = bfd_link_hash_lookup (link_info.hash, buf, FALSE, FALSE, TRUE); 3360 3594 if (h != NULL && h->type == bfd_link_hash_undefined) 3361 3595 { 3362 3363 3364 3596 unsigned opb; 3597 3598 opb = bfd_arch_mach_octets_per_byte (ldfile_output_architecture, 3365 3599 ldfile_output_machine); 3366 3600 h->type = bfd_link_hash_defined; … … 3380 3614 { 3381 3615 struct bfd_link_hash_entry *h; 3382 b oolean warn;3616 bfd_boolean warn; 3383 3617 3384 3618 if (link_info.relocateable || link_info.shared) 3385 warn = false;3619 warn = FALSE; 3386 3620 else 3387 warn = true;3388 3389 if (entry_symbol == (char *) NULL)3621 warn = TRUE; 3622 3623 if (entry_symbol.name == (const char *) NULL) 3390 3624 { 3391 3625 /* No entry has been specified. Look for start, but don't warn 3392 3626 if we don't find it. */ 3393 entry_symbol = "start"; 3394 warn = false; 3395 } 3396 3397 h = bfd_link_hash_lookup (link_info.hash, entry_symbol, false, false, true); 3627 entry_symbol.name = "start"; 3628 warn = FALSE; 3629 } 3630 3631 h = bfd_link_hash_lookup (link_info.hash, entry_symbol.name, 3632 FALSE, FALSE, TRUE); 3398 3633 if (h != (struct bfd_link_hash_entry *) NULL 3399 3634 && (h->type == bfd_link_hash_defined … … 3408 3643 + h->u.def.section->output_offset); 3409 3644 if (! bfd_set_start_address (output_bfd, val)) 3410 einfo (_("%P%F:%s: can't set start address\n"), entry_symbol );3645 einfo (_("%P%F:%s: can't set start address\n"), entry_symbol.name); 3411 3646 } 3412 3647 else … … 3417 3652 /* We couldn't find the entry symbol. Try parsing it as a 3418 3653 number. */ 3419 val = bfd_scan_vma (entry_symbol , &send, 0);3654 val = bfd_scan_vma (entry_symbol.name, &send, 0); 3420 3655 if (*send == '\0') 3421 3656 { … … 3429 3664 /* Can't find the entry symbol, and it's not a number. Use 3430 3665 the first address in the text section. */ 3431 ts = bfd_get_section_by_name (output_bfd, ".text");3666 ts = bfd_get_section_by_name (output_bfd, entry_section); 3432 3667 if (ts != (asection *) NULL) 3433 3668 { 3434 3669 if (warn) 3435 3670 einfo (_("%P: warning: cannot find entry symbol %s; defaulting to %V\n"), 3436 entry_symbol, bfd_get_section_vma (output_bfd, ts)); 3671 entry_symbol.name, 3672 bfd_get_section_vma (output_bfd, ts)); 3437 3673 if (! bfd_set_start_address (output_bfd, 3438 3674 bfd_get_section_vma (output_bfd, … … 3444 3680 if (warn) 3445 3681 einfo (_("%P: warning: cannot find entry symbol %s; not setting start address\n"), 3446 entry_symbol );3682 entry_symbol.name); 3447 3683 } 3448 3684 } … … 3480 3716 { 3481 3717 input_bfd = file->input_statement.the_bfd; 3482 compatible = bfd_arch_get_compatible (input_bfd, 3483 output_bfd); 3718 compatible = bfd_arch_get_compatible (input_bfd, output_bfd, 3719 command_line.accept_unknown_input_arch); 3720 3721 /* In general it is not possible to perform a relocatable 3722 link between differing object formats when the input 3723 file has relocations, because the relocations in the 3724 input format may not have equivalent representations in 3725 the output format (and besides BFD does not translate 3726 relocs for other link purposes than a final link). */ 3727 if ((link_info.relocateable || link_info.emitrelocations) 3728 && (compatible == NULL 3729 || bfd_get_flavour (input_bfd) != bfd_get_flavour (output_bfd)) 3730 && (bfd_get_file_flags (input_bfd) & HAS_RELOC) != 0) 3731 { 3732 einfo (_("%P%F: Relocatable linking with relocations from format %s (%B) to format %s (%B) is not supported\n"), 3733 bfd_get_target (input_bfd), input_bfd, 3734 bfd_get_target (output_bfd), output_bfd); 3735 /* einfo with %F exits. */ 3736 } 3737 3484 3738 if (compatible == NULL) 3485 3739 { … … 3492 3746 { 3493 3747 /* If the input bfd has no contents, it shouldn't set the 3494 private data of the output bfd. */3748 private data of the output bfd. */ 3495 3749 3496 3750 bfd_error_handler_type pfn = NULL; … … 3522 3776 lang_common () 3523 3777 { 3778 if (command_line.inhibit_common_definition) 3779 return; 3524 3780 if (link_info.relocateable 3525 3781 && ! command_line.force_common_definition) … … 3540 3796 /* Place one common symbol in the correct section. */ 3541 3797 3542 static b oolean3798 static bfd_boolean 3543 3799 lang_one_common (h, info) 3544 3800 struct bfd_link_hash_entry *h; … … 3552 3808 3553 3809 if (h->type != bfd_link_hash_common) 3554 return true;3810 return TRUE; 3555 3811 3556 3812 size = h->u.c.size; … … 3559 3815 if (config.sort_common 3560 3816 && power_of_two < (unsigned int) *(int *) info) 3561 return true;3817 return TRUE; 3562 3818 3563 3819 section = h->u.c.p->section; 3564 3820 3565 3821 /* Increase the size of the section. */ 3566 section->_cooked_size = ALIGN_N((section->_cooked_size + opb - 1) / opb,3567 (bfd_ size_type) (1 << power_of_two)) * opb;3822 section->_cooked_size = align_n ((section->_cooked_size + opb - 1) / opb, 3823 (bfd_vma) 1 << power_of_two) * opb; 3568 3824 3569 3825 /* Adjust the alignment if necessary. */ … … 3586 3842 if (config.map_file != NULL) 3587 3843 { 3588 static b oolean header_printed;3844 static bfd_boolean header_printed; 3589 3845 int len; 3590 3846 char *name; … … 3595 3851 minfo (_("\nAllocating common symbols\n")); 3596 3852 minfo (_("Common symbol size file\n\n")); 3597 header_printed = true;3853 header_printed = TRUE; 3598 3854 } 3599 3855 … … 3631 3887 } 3632 3888 3633 return true;3889 return TRUE; 3634 3890 } 3635 3891 … … 3651 3907 if (s->output_section == (asection *) NULL) 3652 3908 { 3653 /* This section of the file is not atta tched, root3909 /* This section of the file is not attached, root 3654 3910 around for a sensible place for it to go. */ 3655 3911 3656 3912 if (file->just_syms_flag) 3657 3913 { 3658 /* We are only retrieving symbol values from this 3659 file. We want the symbols to act as though the 3660 values in the file are absolute. */ 3661 s->output_section = bfd_abs_section_ptr; 3662 s->output_offset = s->vma; 3914 abort (); 3663 3915 } 3664 3916 else if (strcmp (s->name, "COMMON") == 0) … … 3682 3934 3683 3935 } 3684 wild_doit(&default_common_section->children, s,3685 3936 lang_add_section (&default_common_section->children, s, 3937 default_common_section, file); 3686 3938 } 3687 3939 } … … 3690 3942 else 3691 3943 { 3692 lang_output_section_statement_type *os =3693 lang_output_section_statement_lookup (s->name); 3694 3695 wild_doit(&os->children, s, os, file);3944 lang_output_section_statement_type *os; 3945 3946 os = lang_output_section_statement_lookup (s->name); 3947 lang_add_section (&os->children, s, os, file); 3696 3948 } 3697 3949 } … … 3835 4087 { 3836 4088 /* Make -o on command line override OUTPUT in script. */ 3837 if ( had_output_filename == false || !from_script)4089 if (!had_output_filename || !from_script) 3838 4090 { 3839 4091 output_filename = name; 3840 had_output_filename = true;4092 had_output_filename = TRUE; 3841 4093 } 3842 4094 } … … 3921 4173 /* Reset the current counters in the regions. */ 3922 4174 3923 staticvoid3924 reset_memory_regions ()4175 void 4176 lang_reset_memory_regions () 3925 4177 { 3926 4178 lang_memory_region_type *p = lang_memory_region_list; 4179 asection *o; 3927 4180 3928 4181 for (p = lang_memory_region_list; … … 3933 4186 p->current = p->origin; 3934 4187 } 3935 } 3936 3937 /* Expand a wild statement for a particular FILE, marking its sections KEEP 3938 as needed. SECTION may be NULL, in which case it is a wild card. */ 4188 4189 for (o = output_bfd->sections; o != NULL; o = o->next) 4190 o->_raw_size = 0; 4191 } 4192 4193 /* If the wild pattern was marked KEEP, the member sections 4194 should be as well. */ 3939 4195 3940 4196 static void 3941 gc_section_callback (ptr, sec tion, file, data)4197 gc_section_callback (ptr, sec, section, file, data) 3942 4198 lang_wild_statement_type *ptr; 4199 struct wildcard_list *sec ATTRIBUTE_UNUSED; 3943 4200 asection *section; 3944 4201 lang_input_statement_type *file ATTRIBUTE_UNUSED; 3945 4202 PTR data ATTRIBUTE_UNUSED; 3946 4203 { 3947 /* If the wild pattern was marked KEEP, the member sections3948 should be as well. */3949 4204 if (ptr->keep_sections) 3950 4205 section->flags |= SEC_KEEP; 3951 4206 } 3952 4207 3953 /* Handle a wild statement, marking it against GC. SECTION or FILE or both 3954 may be NULL, indicating that it is a wildcard. */ 4208 /* Handle a wild statement, marking it against GC. */ 3955 4209 3956 4210 static void 3957 lang_gc_wild (s , section, file)4211 lang_gc_wild (s) 3958 4212 lang_wild_statement_type *s; 3959 const char *section; 3960 const char *file; 3961 { 3962 walk_wild (s, section, file, gc_section_callback, NULL); 4213 { 4214 walk_wild (s, gc_section_callback, NULL); 3963 4215 } 3964 4216 … … 3969 4221 lang_statement_union_type *s; 3970 4222 { 3971 for (; s != (lang_statement_union_type *) NULL; s = s-> next)4223 for (; s != (lang_statement_union_type *) NULL; s = s->header.next) 3972 4224 { 3973 4225 switch (s->header.type) 3974 4226 { 3975 4227 case lang_wild_statement_enum: 3976 lang_gc_wild (&s->wild_statement, 3977 s->wild_statement.section_name, 3978 s->wild_statement.filename); 4228 lang_gc_wild (&s->wild_statement); 3979 4229 break; 3980 4230 case lang_constructors_statement_enum: … … 3997 4247 { 3998 4248 struct bfd_link_hash_entry *h; 3999 ldlang_undef_chain_list_type *ulist , fake_list_start;4249 ldlang_undef_chain_list_type *ulist; 4000 4250 4001 4251 /* Keep all sections so marked in the link script. */ … … 4003 4253 lang_gc_sections_1 (statement_list.head); 4004 4254 4005 /* Keep all sections containing symbols undefined on the command-line. 4006 Handle the entry symbol at the same time. */ 4007 4008 if (entry_symbol != NULL) 4009 { 4010 fake_list_start.next = ldlang_undef_chain_list_head; 4011 fake_list_start.name = (char *) entry_symbol; 4012 ulist = &fake_list_start; 4013 } 4014 else 4015 ulist = ldlang_undef_chain_list_head; 4016 4017 for (; ulist; ulist = ulist->next) 4255 /* Keep all sections containing symbols undefined on the command-line, 4256 and the section containing the entry symbol. */ 4257 4258 for (ulist = link_info.gc_sym_list; ulist; ulist = ulist->next) 4018 4259 { 4019 4260 h = bfd_link_hash_lookup (link_info.hash, ulist->name, 4020 false, false, false);4261 FALSE, FALSE, FALSE); 4021 4262 4022 4263 if (h != (struct bfd_link_hash_entry *) NULL … … 4050 4291 /* Create a bfd for each input file. */ 4051 4292 current_target = default_target; 4052 open_input_bfds (statement_list.head, false); 4293 open_input_bfds (statement_list.head, FALSE); 4294 4295 link_info.gc_sym_list = &entry_symbol; 4296 if (entry_symbol.name == NULL) 4297 link_info.gc_sym_list = ldlang_undef_chain_list_head; 4053 4298 4054 4299 ldemul_after_open (); … … 4075 4320 lang_gc_sections (); 4076 4321 4322 /* If there were any SEC_MERGE sections, finish their merging, so that 4323 section sizes can be computed. This has to be done after GC of sections, 4324 so that GCed sections are not merged, but before assigning output 4325 sections, since removing whole input sections is hard then. */ 4326 bfd_merge_sections (output_bfd, &link_info); 4327 4077 4328 /* Size up the common data. */ 4078 4329 lang_common (); … … 4086 4337 lang_place_orphans (); 4087 4338 4339 if (! link_info.relocateable) 4340 { 4341 /* Look for a text section and set the readonly attribute in it. */ 4342 asection *found = bfd_get_section_by_name (output_bfd, ".text"); 4343 4344 if (found != (asection *) NULL) 4345 { 4346 if (config.text_read_only) 4347 found->flags |= SEC_READONLY; 4348 else 4349 found->flags &= ~SEC_READONLY; 4350 } 4351 } 4352 4353 /* Do anything special before sizing sections. This is where ELF 4354 and other back-ends size dynamic sections. */ 4088 4355 ldemul_before_allocation (); 4356 4357 if (!link_info.relocateable) 4358 strip_excluded_output_sections (); 4089 4359 4090 4360 /* We must record the program headers before we try to fix the … … 4092 4362 lang_record_phdrs (); 4093 4363 4364 /* Size up the sections. */ 4365 lang_size_sections (statement_list.head, 4366 abs_output_section, 4367 &statement_list.head, 0, (bfd_vma) 0, NULL, 4368 command_line.relax ? FALSE : TRUE); 4369 4094 4370 /* Now run around and relax if we can. */ 4095 4371 if (command_line.relax) 4096 4372 { 4097 /* First time round is a trial run to get the 'worst case'4098 addresses of the objects if there was no relaxing. */4099 lang_size_sections (statement_list.head,4100 abs_output_section,4101 &(statement_list.head), 0, (bfd_vma) 0, false);4102 4103 4373 /* Keep relaxing until bfd_relax_section gives up. */ 4374 bfd_boolean relax_again; 4375 4104 4376 do 4105 4377 { 4106 reset_memory_regions ();4107 4108 relax_again = false;4378 lang_reset_memory_regions (); 4379 4380 relax_again = FALSE; 4109 4381 4110 4382 /* Note: pe-dll.c does something like this also. If you find … … 4116 4388 lang_do_assignments (statement_list.head, 4117 4389 abs_output_section, 4118 (fill_type ) 0, (bfd_vma) 0);4390 (fill_type *) 0, (bfd_vma) 0); 4119 4391 4120 4392 /* Perform another relax pass - this time we know where the 4121 globals are, so can make better guess. */4393 globals are, so can make a better guess. */ 4122 4394 lang_size_sections (statement_list.head, 4123 4395 abs_output_section, 4124 &(statement_list.head), 0, (bfd_vma) 0, true); 4396 &statement_list.head, 0, (bfd_vma) 0, 4397 &relax_again, FALSE); 4398 4399 /* If the normal relax is done and the relax finalize pass 4400 is not performed yet, we perform another relax pass. */ 4401 if (!relax_again && !link_info.relax_finalizing) 4402 { 4403 link_info.relax_finalizing = TRUE; 4404 relax_again = TRUE; 4405 } 4125 4406 } 4126 4407 while (relax_again); 4127 } 4128 else 4129 { 4130 /* Size up the sections. */ 4408 4409 /* Final extra sizing to report errors. */ 4410 lang_reset_memory_regions (); 4411 lang_do_assignments (statement_list.head, 4412 abs_output_section, 4413 (fill_type *) 0, (bfd_vma) 0); 4131 4414 lang_size_sections (statement_list.head, 4132 4415 abs_output_section, 4133 &(statement_list.head), 0, (bfd_vma) 0, false); 4416 & statement_list.head, 0, (bfd_vma) 0, 4417 NULL, TRUE); 4134 4418 } 4135 4419 … … 4146 4430 lang_do_assignments (statement_list.head, 4147 4431 abs_output_section, 4148 (fill_type ) 0, (bfd_vma) 0);4432 (fill_type *) 0, (bfd_vma) 0); 4149 4433 4150 4434 /* Make sure that the section addresses make sense. */ … … 4162 4446 4163 4447 void 4164 lang_add_wild (section_name, sections_sorted, filename, filenames_sorted, 4165 keep_sections, exclude_filename_list) 4166 const char *const section_name; 4167 boolean sections_sorted; 4168 const char *const filename; 4169 boolean filenames_sorted; 4170 boolean keep_sections; 4171 struct name_list *exclude_filename_list; 4172 { 4173 lang_wild_statement_type *new = new_stat (lang_wild_statement, 4174 stat_ptr); 4175 4176 if (section_name != (char *) NULL && strcmp (section_name, "COMMON") == 0) 4177 { 4178 placed_commons = true; 4179 } 4180 if (filename != NULL && ! wildcardp (filename)) 4181 { 4182 lang_has_input_file = true; 4183 } 4184 new->section_name = section_name; 4185 new->sections_sorted = sections_sorted; 4186 new->filename = filename; 4187 new->filenames_sorted = filenames_sorted; 4448 lang_add_wild (filespec, section_list, keep_sections) 4449 struct wildcard_spec *filespec; 4450 struct wildcard_list *section_list; 4451 bfd_boolean keep_sections; 4452 { 4453 struct wildcard_list *curr, *next; 4454 lang_wild_statement_type *new; 4455 4456 /* Reverse the list as the parser puts it back to front. */ 4457 for (curr = section_list, section_list = NULL; 4458 curr != NULL; 4459 section_list = curr, curr = next) 4460 { 4461 if (curr->spec.name != NULL && strcmp (curr->spec.name, "COMMON") == 0) 4462 placed_commons = TRUE; 4463 4464 next = curr->next; 4465 curr->next = section_list; 4466 } 4467 4468 if (filespec != NULL && filespec->name != NULL) 4469 { 4470 if (strcmp (filespec->name, "*") == 0) 4471 filespec->name = NULL; 4472 else if (! wildcardp (filespec->name)) 4473 lang_has_input_file = TRUE; 4474 } 4475 4476 new = new_stat (lang_wild_statement, stat_ptr); 4477 new->filename = NULL; 4478 new->filenames_sorted = FALSE; 4479 if (filespec != NULL) 4480 { 4481 new->filename = filespec->name; 4482 new->filenames_sorted = filespec->sorted; 4483 } 4484 new->section_list = section_list; 4188 4485 new->keep_sections = keep_sections; 4189 new->exclude_filename_list = exclude_filename_list;4190 4486 lang_list_init (&new->children); 4191 4487 } … … 4211 4507 lang_add_entry (name, cmdline) 4212 4508 const char *name; 4213 b oolean cmdline;4214 { 4215 if (entry_symbol == NULL4509 bfd_boolean cmdline; 4510 { 4511 if (entry_symbol.name == NULL 4216 4512 || cmdline 4217 4513 || ! entry_from_cmdline) 4218 4514 { 4219 entry_symbol = name;4515 entry_symbol.name = name; 4220 4516 entry_from_cmdline = cmdline; 4221 4517 } … … 4242 4538 { 4243 4539 case 'F': 4244 map_option_f = true;4540 map_option_f = TRUE; 4245 4541 break; 4246 4542 } … … 4250 4546 4251 4547 void 4252 lang_add_fill ( exp)4253 int exp;4548 lang_add_fill (fill) 4549 fill_type *fill; 4254 4550 { 4255 4551 lang_fill_statement_type *new = new_stat (lang_fill_statement, 4256 4552 stat_ptr); 4257 4553 4258 new->fill = exp;4554 new->fill = fill; 4259 4555 } 4260 4556 … … 4329 4625 first_file->filename = name; 4330 4626 first_file->local_sym_name = name; 4331 first_file->real = true;4627 first_file->real = TRUE; 4332 4628 4333 4629 startup_file = name; … … 4336 4632 void 4337 4633 lang_float (maybe) 4338 b oolean maybe;4634 bfd_boolean maybe; 4339 4635 { 4340 4636 lang_float_flag = maybe; 4637 } 4638 4639 4640 /* Work out the load- and run-time regions from a script statement, and 4641 store them in *LMA_REGION and *REGION respectively. 4642 4643 MEMSPEC is the name of the run-time region, or "*default*" if the 4644 statement didn't specify one. LMA_MEMSPEC is the name of the 4645 load-time region, or null if the statement didn't specify one. 4646 HAVE_LMA_P is TRUE if the statement had an explicit load address. 4647 4648 It is an error to specify both a load region and a load address. */ 4649 4650 static void 4651 lang_get_regions (region, lma_region, memspec, lma_memspec, have_lma_p) 4652 struct memory_region_struct **region, **lma_region; 4653 const char *memspec, *lma_memspec; 4654 int have_lma_p; 4655 { 4656 *lma_region = lang_memory_region_lookup (lma_memspec); 4657 4658 /* If no runtime region has been given, but the load region has 4659 been, use the load region. */ 4660 if (lma_memspec != 0 && strcmp (memspec, "*default*") == 0) 4661 *region = *lma_region; 4662 else 4663 *region = lang_memory_region_lookup (memspec); 4664 4665 if (have_lma_p && lma_memspec != 0) 4666 einfo (_("%X%P:%S: section has both a load address and a load region\n")); 4341 4667 } 4342 4668 4343 4669 void 4344 4670 lang_leave_output_section_statement (fill, memspec, phdrs, lma_memspec) 4345 bfd_vmafill;4671 fill_type *fill; 4346 4672 const char *memspec; 4347 4673 struct lang_output_section_phdr_list *phdrs; 4348 4674 const char *lma_memspec; 4349 4675 { 4676 lang_get_regions (¤t_section->region, 4677 ¤t_section->lma_region, 4678 memspec, lma_memspec, 4679 current_section->load_base != 0); 4350 4680 current_section->fill = fill; 4351 current_section->region = lang_memory_region_lookup (memspec);4352 if (strcmp (lma_memspec, "*default*") != 0)4353 {4354 current_section->lma_region = lang_memory_region_lookup (lma_memspec);4355 /* If no runtime region has been given, but the load region has4356 been, use the load region. */4357 if (strcmp (memspec, "*default*") == 0)4358 current_section->region = lang_memory_region_lookup (lma_memspec);4359 }4360 4681 current_section->phdrs = phdrs; 4361 4682 stat_ptr = &statement_list; … … 4374 4695 struct bfd_link_hash_entry *h; 4375 4696 4376 h = bfd_link_hash_lookup (link_info.hash, name, true, true, true);4697 h = bfd_link_hash_lookup (link_info.hash, name, TRUE, TRUE, TRUE); 4377 4698 if (h == (struct bfd_link_hash_entry *) NULL) 4378 4699 einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); … … 4407 4728 struct bfd_link_hash_entry *h; 4408 4729 4409 h = bfd_link_hash_lookup (link_info.hash, name, true, true, true);4730 h = bfd_link_hash_lookup (link_info.hash, name, TRUE, TRUE, TRUE); 4410 4731 if (h == (struct bfd_link_hash_entry *) NULL) 4411 4732 einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); … … 4493 4814 const char *name; 4494 4815 etree_type *type; 4495 b oolean filehdr;4496 b oolean phdrs;4816 bfd_boolean filehdr; 4817 bfd_boolean phdrs; 4497 4818 etree_type *at; 4498 4819 etree_type *flags; … … 4573 4894 secs[c] = os->bfd_section; 4574 4895 ++c; 4575 pl->used = true;4896 pl->used = TRUE; 4576 4897 } 4577 4898 } … … 4631 4952 4632 4953 /* Set notice_all so that we get informed about all symbols. */ 4633 link_info.notice_all = true;4954 link_info.notice_all = TRUE; 4634 4955 } 4635 4956 … … 4639 4960 /* The overlay virtual address. */ 4640 4961 static etree_type *overlay_vma; 4641 4642 /* The overlay load address. */4643 static etree_type *overlay_lma;4644 4645 /* Whether nocrossrefs is set for this overlay. */4646 static int overlay_nocrossrefs;4647 4962 4648 4963 /* An expression for the maximum section size seen so far. */ … … 4661 4976 4662 4977 void 4663 lang_enter_overlay (vma_expr , lma_expr, nocrossrefs)4978 lang_enter_overlay (vma_expr) 4664 4979 etree_type *vma_expr; 4665 etree_type *lma_expr;4666 int nocrossrefs;4667 4980 { 4668 4981 /* The grammar should prevent nested overlays from occurring. */ 4669 ASSERT (overlay_vma == NULL 4670 && overlay_lma == NULL 4671 && overlay_list == NULL 4672 && overlay_max == NULL); 4982 ASSERT (overlay_vma == NULL && overlay_max == NULL); 4673 4983 4674 4984 overlay_vma = vma_expr; 4675 overlay_lma = lma_expr;4676 overlay_nocrossrefs = nocrossrefs;4677 4985 } 4678 4986 4679 4987 /* Start a section in an overlay. We handle this by calling 4680 lang_enter_output_section_statement with the correct VMA and LMA. */ 4988 lang_enter_output_section_statement with the correct VMA. 4989 lang_leave_overlay sets up the LMA and memory regions. */ 4681 4990 4682 4991 void … … 4688 4997 4689 4998 lang_enter_output_section_statement (name, overlay_vma, normal_section, 4690 0, 0, 0, overlay_lma);4691 4692 /* If this is the first section, then base the VMA and LMAof future4999 0, 0, 0, 0); 5000 5001 /* If this is the first section, then base the VMA of future 4693 5002 sections on this one. This will work correctly even if `.' is 4694 5003 used in the addresses. */ 4695 5004 if (overlay_list == NULL) 4696 { 4697 overlay_vma = exp_nameop (ADDR, name); 4698 overlay_lma = exp_nameop (LOADADDR, name); 4699 } 5005 overlay_vma = exp_nameop (ADDR, name); 4700 5006 4701 5007 /* Remember the section. */ … … 4707 5013 size = exp_nameop (SIZEOF, name); 4708 5014 4709 /* Adjust the LMA for the next section. */4710 overlay_lma = exp_binop ('+', overlay_lma, size);4711 4712 5015 /* Arrange to work out the maximum section end address. */ 4713 5016 if (overlay_max == NULL) … … 4722 5025 void 4723 5026 lang_leave_overlay_section (fill, phdrs) 4724 bfd_vmafill;5027 fill_type *fill; 4725 5028 struct lang_output_section_phdr_list *phdrs; 4726 5029 { … … 4732 5035 name = current_section->name; 4733 5036 4734 lang_leave_output_section_statement (fill, "*default*", 4735 phdrs, "*default*"); 5037 /* For now, assume that "*default*" is the run-time memory region and 5038 that no load-time region has been specified. It doesn't really 5039 matter what we say here, since lang_leave_overlay will override it. */ 5040 lang_leave_output_section_statement (fill, "*default*", phdrs, 0); 4736 5041 4737 5042 /* Define the magic symbols. */ … … 4740 5045 s2 = clean; 4741 5046 for (s1 = name; *s1 != '\0'; s1++) 4742 if ( isalnum ((unsigned char)*s1) || *s1 == '_')5047 if (ISALNUM (*s1) || *s1 == '_') 4743 5048 *s2++ = *s1; 4744 5049 *s2 = '\0'; … … 4763 5068 4764 5069 void 4765 lang_leave_overlay (fill, memspec, phdrs, lma_memspec) 4766 bfd_vma fill; 5070 lang_leave_overlay (lma_expr, nocrossrefs, fill, memspec, phdrs, lma_memspec) 5071 etree_type *lma_expr; 5072 int nocrossrefs; 5073 fill_type *fill; 4767 5074 const char *memspec; 4768 5075 struct lang_output_section_phdr_list *phdrs; … … 4774 5081 struct lang_nocrossref *nocrossref; 4775 5082 4776 if (memspec == NULL) 4777 region = NULL; 4778 else 4779 region = lang_memory_region_lookup (memspec); 4780 4781 if (lma_memspec == NULL) 4782 lma_region = NULL; 4783 else 4784 lma_region = lang_memory_region_lookup (lma_memspec); 5083 lang_get_regions (®ion, &lma_region, 5084 memspec, lma_memspec, 5085 lma_expr != 0); 4785 5086 4786 5087 nocrossref = NULL; 5088 5089 /* After setting the size of the last section, set '.' to end of the 5090 overlay region. */ 5091 if (overlay_list != NULL) 5092 overlay_list->os->update_dot_tree 5093 = exp_assop ('=', ".", exp_binop ('+', overlay_vma, overlay_max)); 4787 5094 4788 5095 l = overlay_list; … … 4791 5098 struct overlay_list *next; 4792 5099 4793 if (fill != 0 && l->os->fill ==0)5100 if (fill != (fill_type *) 0 && l->os->fill == (fill_type *) 0) 4794 5101 l->os->fill = fill; 4795 if (region != NULL && l->os->region == NULL) 4796 l->os->region = region; 4797 /* We only set lma_region for the first overlay section, as 4798 subsequent overlay sections will have load_base set relative 4799 to the first section. Also, don't set lma_region if 4800 load_base is specified. FIXME: There should really be a test 4801 that `AT ( LDADDR )' doesn't conflict with `AT >LMA_REGION' 4802 rather than letting LDADDR simply override LMA_REGION. */ 4803 if (lma_region != NULL && l->os->lma_region == NULL 4804 && l->next == NULL && l->os->load_base == NULL) 4805 l->os->lma_region = lma_region; 5102 5103 l->os->region = region; 5104 l->os->lma_region = lma_region; 5105 5106 /* The first section has the load address specified in the 5107 OVERLAY statement. The rest are worked out from that. 5108 The base address is not needed (and should be null) if 5109 an LMA region was specified. */ 5110 if (l->next == 0) 5111 l->os->load_base = lma_expr; 5112 else if (lma_region == 0) 5113 l->os->load_base = exp_binop ('+', 5114 exp_nameop (LOADADDR, l->next->os->name), 5115 exp_nameop (SIZEOF, l->next->os->name)); 5116 4806 5117 if (phdrs != NULL && l->os->phdrs == NULL) 4807 5118 l->os->phdrs = phdrs; 4808 5119 4809 if ( overlay_nocrossrefs)5120 if (nocrossrefs) 4810 5121 { 4811 5122 struct lang_nocrossref *nc; … … 4825 5136 lang_add_nocrossref (nocrossref); 4826 5137 4827 /* Update . for the end of the overlay. */4828 lang_add_assignment (exp_assop ('=', ".",4829 exp_binop ('+', overlay_vma, overlay_max)));4830 4831 5138 overlay_vma = NULL; 4832 overlay_lma = NULL;4833 overlay_nocrossrefs = 0;4834 5139 overlay_list = NULL; 4835 5140 overlay_max = NULL; … … 4868 5173 { 4869 5174 /* cplus_demangle (also) returns NULL when it is not a C++ symbol. 4870 Should we early out falsein this case? */5175 Should we early out FALSE in this case? */ 4871 5176 result = fnmatch (expr->pattern, sym, 0) == 0; 4872 5177 } … … 4895 5200 { 4896 5201 /* cplus_demangle (also) returns NULL when it is not a Java symbol. 4897 Should we early out falsein this case? */5202 Should we early out FALSE in this case? */ 4898 5203 result = fnmatch (expr->pattern, sym, 0) == 0; 4899 5204 } … … 4910 5215 4911 5216 struct bfd_elf_version_expr * 4912 lang_new_vers_ regex(orig, new, lang)5217 lang_new_vers_pattern (orig, new, lang) 4913 5218 struct bfd_elf_version_expr *orig; 4914 5219 const char *new; … … 4920 5225 ret->next = orig; 4921 5226 ret->pattern = new; 5227 ret->symver = 0; 5228 ret->script = 0; 4922 5229 4923 5230 if (lang == NULL || strcasecmp (lang, "C") == 0) … … 4934 5241 } 4935 5242 4936 return ret;5243 return ldemul_new_vers_pattern (ret); 4937 5244 } 4938 5245 … … 4975 5282 struct bfd_elf_version_expr *e1; 4976 5283 5284 if (name == NULL) 5285 name = ""; 5286 5287 if ((name[0] == '\0' && lang_elf_version_info != NULL) 5288 || (lang_elf_version_info && lang_elf_version_info->name[0] == '\0')) 5289 { 5290 einfo (_("%X%P: anonymous version tag cannot be combined with other version tags\n")); 5291 free (version); 5292 return; 5293 } 5294 4977 5295 /* Make sure this node has a unique name. */ 4978 5296 for (t = lang_elf_version_info; t != NULL; t = t->next) … … 5011 5329 version->deps = deps; 5012 5330 version->name = name; 5013 ++version_index; 5014 version->vernum = version_index; 5331 if (name[0] != '\0') 5332 { 5333 ++version_index; 5334 version->vernum = version_index; 5335 } 5336 else 5337 version->vernum = 0; 5015 5338 5016 5339 for (pp = &lang_elf_version_info; *pp != NULL; pp = &(*pp)->next) … … 5058 5381 5059 5382 if (sec == NULL) 5060 5383 continue; 5061 5384 5062 5385 len = bfd_section_size (is->the_bfd, sec); 5063 5386 contents = xmalloc (len); 5064 5387 if (!bfd_get_section_contents (is->the_bfd, sec, contents, 0, len)) 5065 einfo (_("%X%P: unable to read .exports section contents "), sec);5388 einfo (_("%X%P: unable to read .exports section contents\n"), sec); 5066 5389 5067 5390 p = contents; 5068 5391 while (p < contents + len) 5069 5392 { 5070 greg = lang_new_vers_ regex(greg, p, NULL);5393 greg = lang_new_vers_pattern (greg, p, NULL); 5071 5394 p = strchr (p, '\0') + 1; 5072 5395 } … … 5079 5402 } 5080 5403 5081 lreg = lang_new_vers_ regex(NULL, "*", NULL);5404 lreg = lang_new_vers_pattern (NULL, "*", NULL); 5082 5405 lang_register_vers_node (command_line.version_exports_section, 5083 5406 lang_new_vers_node (greg, lreg), NULL); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.