1*a9fa9459Szrj /* ldlang.h - linker command language support 2*a9fa9459Szrj Copyright (C) 1991-2016 Free Software Foundation, Inc. 3*a9fa9459Szrj 4*a9fa9459Szrj This file is part of the GNU Binutils. 5*a9fa9459Szrj 6*a9fa9459Szrj This program is free software; you can redistribute it and/or modify 7*a9fa9459Szrj it under the terms of the GNU General Public License as published by 8*a9fa9459Szrj the Free Software Foundation; either version 3 of the License, or 9*a9fa9459Szrj (at your option) any later version. 10*a9fa9459Szrj 11*a9fa9459Szrj This program is distributed in the hope that it will be useful, 12*a9fa9459Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of 13*a9fa9459Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*a9fa9459Szrj GNU General Public License for more details. 15*a9fa9459Szrj 16*a9fa9459Szrj You should have received a copy of the GNU General Public License 17*a9fa9459Szrj along with this program; if not, write to the Free Software 18*a9fa9459Szrj Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 19*a9fa9459Szrj MA 02110-1301, USA. */ 20*a9fa9459Szrj 21*a9fa9459Szrj #ifndef LDLANG_H 22*a9fa9459Szrj #define LDLANG_H 23*a9fa9459Szrj 24*a9fa9459Szrj #define DEFAULT_MEMORY_REGION "*default*" 25*a9fa9459Szrj 26*a9fa9459Szrj typedef enum 27*a9fa9459Szrj { 28*a9fa9459Szrj lang_input_file_is_l_enum, 29*a9fa9459Szrj lang_input_file_is_symbols_only_enum, 30*a9fa9459Szrj lang_input_file_is_marker_enum, 31*a9fa9459Szrj lang_input_file_is_fake_enum, 32*a9fa9459Szrj lang_input_file_is_search_file_enum, 33*a9fa9459Szrj lang_input_file_is_file_enum 34*a9fa9459Szrj } lang_input_file_enum_type; 35*a9fa9459Szrj 36*a9fa9459Szrj struct _fill_type 37*a9fa9459Szrj { 38*a9fa9459Szrj size_t size; 39*a9fa9459Szrj unsigned char data[1]; 40*a9fa9459Szrj }; 41*a9fa9459Szrj 42*a9fa9459Szrj typedef struct statement_list 43*a9fa9459Szrj { 44*a9fa9459Szrj union lang_statement_union * head; 45*a9fa9459Szrj union lang_statement_union ** tail; 46*a9fa9459Szrj } lang_statement_list_type; 47*a9fa9459Szrj 48*a9fa9459Szrj typedef struct memory_region_name_struct 49*a9fa9459Szrj { 50*a9fa9459Szrj const char * name; 51*a9fa9459Szrj struct memory_region_name_struct * next; 52*a9fa9459Szrj } lang_memory_region_name; 53*a9fa9459Szrj 54*a9fa9459Szrj typedef struct memory_region_struct 55*a9fa9459Szrj { 56*a9fa9459Szrj lang_memory_region_name name_list; 57*a9fa9459Szrj struct memory_region_struct *next; 58*a9fa9459Szrj union etree_union *origin_exp; 59*a9fa9459Szrj bfd_vma origin; 60*a9fa9459Szrj bfd_size_type length; 61*a9fa9459Szrj union etree_union *length_exp; 62*a9fa9459Szrj bfd_vma current; 63*a9fa9459Szrj union lang_statement_union *last_os; 64*a9fa9459Szrj flagword flags; 65*a9fa9459Szrj flagword not_flags; 66*a9fa9459Szrj bfd_boolean had_full_message; 67*a9fa9459Szrj } lang_memory_region_type; 68*a9fa9459Szrj 69*a9fa9459Szrj enum statement_enum 70*a9fa9459Szrj { 71*a9fa9459Szrj lang_output_section_statement_enum, 72*a9fa9459Szrj lang_assignment_statement_enum, 73*a9fa9459Szrj lang_input_statement_enum, 74*a9fa9459Szrj lang_address_statement_enum, 75*a9fa9459Szrj lang_wild_statement_enum, 76*a9fa9459Szrj lang_input_section_enum, 77*a9fa9459Szrj lang_object_symbols_statement_enum, 78*a9fa9459Szrj lang_fill_statement_enum, 79*a9fa9459Szrj lang_data_statement_enum, 80*a9fa9459Szrj lang_reloc_statement_enum, 81*a9fa9459Szrj lang_target_statement_enum, 82*a9fa9459Szrj lang_output_statement_enum, 83*a9fa9459Szrj lang_padding_statement_enum, 84*a9fa9459Szrj lang_group_statement_enum, 85*a9fa9459Szrj lang_insert_statement_enum, 86*a9fa9459Szrj lang_constructors_statement_enum 87*a9fa9459Szrj }; 88*a9fa9459Szrj 89*a9fa9459Szrj typedef struct lang_statement_header_struct 90*a9fa9459Szrj { 91*a9fa9459Szrj union lang_statement_union *next; 92*a9fa9459Szrj enum statement_enum type; 93*a9fa9459Szrj } lang_statement_header_type; 94*a9fa9459Szrj 95*a9fa9459Szrj typedef struct 96*a9fa9459Szrj { 97*a9fa9459Szrj lang_statement_header_type header; 98*a9fa9459Szrj union etree_union *exp; 99*a9fa9459Szrj } lang_assignment_statement_type; 100*a9fa9459Szrj 101*a9fa9459Szrj typedef struct lang_target_statement_struct 102*a9fa9459Szrj { 103*a9fa9459Szrj lang_statement_header_type header; 104*a9fa9459Szrj const char *target; 105*a9fa9459Szrj } lang_target_statement_type; 106*a9fa9459Szrj 107*a9fa9459Szrj typedef struct lang_output_statement_struct 108*a9fa9459Szrj { 109*a9fa9459Szrj lang_statement_header_type header; 110*a9fa9459Szrj const char *name; 111*a9fa9459Szrj } lang_output_statement_type; 112*a9fa9459Szrj 113*a9fa9459Szrj /* Section types specified in a linker script. */ 114*a9fa9459Szrj 115*a9fa9459Szrj enum section_type 116*a9fa9459Szrj { 117*a9fa9459Szrj normal_section, 118*a9fa9459Szrj overlay_section, 119*a9fa9459Szrj noload_section, 120*a9fa9459Szrj noalloc_section 121*a9fa9459Szrj }; 122*a9fa9459Szrj 123*a9fa9459Szrj /* This structure holds a list of program headers describing 124*a9fa9459Szrj segments in which this section should be placed. */ 125*a9fa9459Szrj 126*a9fa9459Szrj typedef struct lang_output_section_phdr_list 127*a9fa9459Szrj { 128*a9fa9459Szrj struct lang_output_section_phdr_list *next; 129*a9fa9459Szrj const char *name; 130*a9fa9459Szrj bfd_boolean used; 131*a9fa9459Szrj } lang_output_section_phdr_list; 132*a9fa9459Szrj 133*a9fa9459Szrj typedef struct lang_output_section_statement_struct 134*a9fa9459Szrj { 135*a9fa9459Szrj lang_statement_header_type header; 136*a9fa9459Szrj lang_statement_list_type children; 137*a9fa9459Szrj struct lang_output_section_statement_struct *next; 138*a9fa9459Szrj struct lang_output_section_statement_struct *prev; 139*a9fa9459Szrj const char *name; 140*a9fa9459Szrj asection *bfd_section; 141*a9fa9459Szrj lang_memory_region_type *region; 142*a9fa9459Szrj lang_memory_region_type *lma_region; 143*a9fa9459Szrj fill_type *fill; 144*a9fa9459Szrj union etree_union *addr_tree; 145*a9fa9459Szrj union etree_union *load_base; 146*a9fa9459Szrj 147*a9fa9459Szrj /* If non-null, an expression to evaluate after setting the section's 148*a9fa9459Szrj size. The expression is evaluated inside REGION (above) with '.' 149*a9fa9459Szrj set to the end of the section. Used in the last overlay section 150*a9fa9459Szrj to move '.' past all the overlaid sections. */ 151*a9fa9459Szrj union etree_union *update_dot_tree; 152*a9fa9459Szrj 153*a9fa9459Szrj lang_output_section_phdr_list *phdrs; 154*a9fa9459Szrj 155*a9fa9459Szrj unsigned int block_value; 156*a9fa9459Szrj int subsection_alignment; /* Alignment of components. */ 157*a9fa9459Szrj int section_alignment; /* Alignment of start of section. */ 158*a9fa9459Szrj int constraint; 159*a9fa9459Szrj flagword flags; 160*a9fa9459Szrj enum section_type sectype; 161*a9fa9459Szrj unsigned int processed_vma : 1; 162*a9fa9459Szrj unsigned int processed_lma : 1; 163*a9fa9459Szrj unsigned int all_input_readonly : 1; 164*a9fa9459Szrj /* If this section should be ignored. */ 165*a9fa9459Szrj unsigned int ignored : 1; 166*a9fa9459Szrj /* If this section should update "dot". Prevents section being ignored. */ 167*a9fa9459Szrj unsigned int update_dot : 1; 168*a9fa9459Szrj /* If this section is after assignment to _end. */ 169*a9fa9459Szrj unsigned int after_end : 1; 170*a9fa9459Szrj /* If this section uses the alignment of its input sections. */ 171*a9fa9459Szrj unsigned int align_lma_with_input : 1; 172*a9fa9459Szrj } lang_output_section_statement_type; 173*a9fa9459Szrj 174*a9fa9459Szrj typedef struct 175*a9fa9459Szrj { 176*a9fa9459Szrj lang_statement_header_type header; 177*a9fa9459Szrj } lang_common_statement_type; 178*a9fa9459Szrj 179*a9fa9459Szrj typedef struct 180*a9fa9459Szrj { 181*a9fa9459Szrj lang_statement_header_type header; 182*a9fa9459Szrj } lang_object_symbols_statement_type; 183*a9fa9459Szrj 184*a9fa9459Szrj typedef struct 185*a9fa9459Szrj { 186*a9fa9459Szrj lang_statement_header_type header; 187*a9fa9459Szrj fill_type *fill; 188*a9fa9459Szrj int size; 189*a9fa9459Szrj asection *output_section; 190*a9fa9459Szrj } lang_fill_statement_type; 191*a9fa9459Szrj 192*a9fa9459Szrj typedef struct 193*a9fa9459Szrj { 194*a9fa9459Szrj lang_statement_header_type header; 195*a9fa9459Szrj unsigned int type; 196*a9fa9459Szrj union etree_union *exp; 197*a9fa9459Szrj bfd_vma value; 198*a9fa9459Szrj asection *output_section; 199*a9fa9459Szrj bfd_vma output_offset; 200*a9fa9459Szrj } lang_data_statement_type; 201*a9fa9459Szrj 202*a9fa9459Szrj /* Generate a reloc in the output file. */ 203*a9fa9459Szrj 204*a9fa9459Szrj typedef struct 205*a9fa9459Szrj { 206*a9fa9459Szrj lang_statement_header_type header; 207*a9fa9459Szrj 208*a9fa9459Szrj /* Reloc to generate. */ 209*a9fa9459Szrj bfd_reloc_code_real_type reloc; 210*a9fa9459Szrj 211*a9fa9459Szrj /* Reloc howto structure. */ 212*a9fa9459Szrj reloc_howto_type *howto; 213*a9fa9459Szrj 214*a9fa9459Szrj /* Section to generate reloc against. 215*a9fa9459Szrj Exactly one of section and name must be NULL. */ 216*a9fa9459Szrj asection *section; 217*a9fa9459Szrj 218*a9fa9459Szrj /* Name of symbol to generate reloc against. 219*a9fa9459Szrj Exactly one of section and name must be NULL. */ 220*a9fa9459Szrj const char *name; 221*a9fa9459Szrj 222*a9fa9459Szrj /* Expression for addend. */ 223*a9fa9459Szrj union etree_union *addend_exp; 224*a9fa9459Szrj 225*a9fa9459Szrj /* Resolved addend. */ 226*a9fa9459Szrj bfd_vma addend_value; 227*a9fa9459Szrj 228*a9fa9459Szrj /* Output section where reloc should be performed. */ 229*a9fa9459Szrj asection *output_section; 230*a9fa9459Szrj 231*a9fa9459Szrj /* Offset within output section. */ 232*a9fa9459Szrj bfd_vma output_offset; 233*a9fa9459Szrj } lang_reloc_statement_type; 234*a9fa9459Szrj 235*a9fa9459Szrj struct lang_input_statement_flags 236*a9fa9459Szrj { 237*a9fa9459Szrj /* 1 means this file was specified in a -l option. */ 238*a9fa9459Szrj unsigned int maybe_archive : 1; 239*a9fa9459Szrj 240*a9fa9459Szrj /* 1 means this file was specified in a -l:namespec option. */ 241*a9fa9459Szrj unsigned int full_name_provided : 1; 242*a9fa9459Szrj 243*a9fa9459Szrj /* 1 means search a set of directories for this file. */ 244*a9fa9459Szrj unsigned int search_dirs : 1; 245*a9fa9459Szrj 246*a9fa9459Szrj /* 1 means this was found when processing a script in the sysroot. */ 247*a9fa9459Szrj unsigned int sysrooted : 1; 248*a9fa9459Szrj 249*a9fa9459Szrj /* 1 means this is base file of incremental load. 250*a9fa9459Szrj Do not load this file's text or data. 251*a9fa9459Szrj Also default text_start to after this file's bss. */ 252*a9fa9459Szrj unsigned int just_syms : 1; 253*a9fa9459Szrj 254*a9fa9459Szrj /* Whether to search for this entry as a dynamic archive. */ 255*a9fa9459Szrj unsigned int dynamic : 1; 256*a9fa9459Szrj 257*a9fa9459Szrj /* Set if a DT_NEEDED tag should be added not just for the dynamic library 258*a9fa9459Szrj explicitly given by this entry but also for any dynamic libraries in 259*a9fa9459Szrj this entry's needed list. */ 260*a9fa9459Szrj unsigned int add_DT_NEEDED_for_dynamic : 1; 261*a9fa9459Szrj 262*a9fa9459Szrj /* Set if this entry should cause a DT_NEEDED tag only when some 263*a9fa9459Szrj regular file references its symbols (ie. --as-needed is in effect). */ 264*a9fa9459Szrj unsigned int add_DT_NEEDED_for_regular : 1; 265*a9fa9459Szrj 266*a9fa9459Szrj /* Whether to include the entire contents of an archive. */ 267*a9fa9459Szrj unsigned int whole_archive : 1; 268*a9fa9459Szrj 269*a9fa9459Szrj /* Set when bfd opening is successful. */ 270*a9fa9459Szrj unsigned int loaded : 1; 271*a9fa9459Szrj 272*a9fa9459Szrj unsigned int real : 1; 273*a9fa9459Szrj 274*a9fa9459Szrj /* Set if the file does not exist. */ 275*a9fa9459Szrj unsigned int missing_file : 1; 276*a9fa9459Szrj 277*a9fa9459Szrj /* Set if reloading an archive or --as-needed lib. */ 278*a9fa9459Szrj unsigned int reload : 1; 279*a9fa9459Szrj 280*a9fa9459Szrj #ifdef ENABLE_PLUGINS 281*a9fa9459Szrj /* Set if the file was claimed by a plugin. */ 282*a9fa9459Szrj unsigned int claimed : 1; 283*a9fa9459Szrj 284*a9fa9459Szrj /* Set if the file was claimed from an archive. */ 285*a9fa9459Szrj unsigned int claim_archive : 1; 286*a9fa9459Szrj 287*a9fa9459Szrj /* Set if added by the lto plugin add_input_file callback. */ 288*a9fa9459Szrj unsigned int lto_output : 1; 289*a9fa9459Szrj #endif /* ENABLE_PLUGINS */ 290*a9fa9459Szrj 291*a9fa9459Szrj /* Head of list of pushed flags. */ 292*a9fa9459Szrj struct lang_input_statement_flags *pushed; 293*a9fa9459Szrj }; 294*a9fa9459Szrj 295*a9fa9459Szrj typedef struct lang_input_statement_struct 296*a9fa9459Szrj { 297*a9fa9459Szrj lang_statement_header_type header; 298*a9fa9459Szrj /* Name of this file. */ 299*a9fa9459Szrj const char *filename; 300*a9fa9459Szrj /* Name to use for the symbol giving address of text start. 301*a9fa9459Szrj Usually the same as filename, but for a file spec'd with 302*a9fa9459Szrj -l this is the -l switch itself rather than the filename. */ 303*a9fa9459Szrj const char *local_sym_name; 304*a9fa9459Szrj 305*a9fa9459Szrj bfd *the_bfd; 306*a9fa9459Szrj 307*a9fa9459Szrj struct flag_info *section_flag_list; 308*a9fa9459Szrj 309*a9fa9459Szrj /* Point to the next file - whatever it is, wanders up and down 310*a9fa9459Szrj archives */ 311*a9fa9459Szrj union lang_statement_union *next; 312*a9fa9459Szrj 313*a9fa9459Szrj /* Point to the next file, but skips archive contents. */ 314*a9fa9459Szrj union lang_statement_union *next_real_file; 315*a9fa9459Szrj 316*a9fa9459Szrj const char *target; 317*a9fa9459Szrj 318*a9fa9459Szrj struct lang_input_statement_flags flags; 319*a9fa9459Szrj } lang_input_statement_type; 320*a9fa9459Szrj 321*a9fa9459Szrj typedef struct 322*a9fa9459Szrj { 323*a9fa9459Szrj lang_statement_header_type header; 324*a9fa9459Szrj asection *section; 325*a9fa9459Szrj } lang_input_section_type; 326*a9fa9459Szrj 327*a9fa9459Szrj struct map_symbol_def { 328*a9fa9459Szrj struct bfd_link_hash_entry *entry; 329*a9fa9459Szrj struct map_symbol_def *next; 330*a9fa9459Szrj }; 331*a9fa9459Szrj 332*a9fa9459Szrj /* For input sections, when writing a map file: head / tail of a linked 333*a9fa9459Szrj list of hash table entries for symbols defined in this section. */ 334*a9fa9459Szrj typedef struct input_section_userdata_struct 335*a9fa9459Szrj { 336*a9fa9459Szrj struct map_symbol_def *map_symbol_def_head; 337*a9fa9459Szrj struct map_symbol_def **map_symbol_def_tail; 338*a9fa9459Szrj unsigned long map_symbol_def_count; 339*a9fa9459Szrj } input_section_userdata_type; 340*a9fa9459Szrj 341*a9fa9459Szrj #define get_userdata(x) ((x)->userdata) 342*a9fa9459Szrj 343*a9fa9459Szrj 344*a9fa9459Szrj typedef struct lang_wild_statement_struct lang_wild_statement_type; 345*a9fa9459Szrj 346*a9fa9459Szrj typedef void (*callback_t) (lang_wild_statement_type *, struct wildcard_list *, 347*a9fa9459Szrj asection *, struct flag_info *, 348*a9fa9459Szrj lang_input_statement_type *, void *); 349*a9fa9459Szrj 350*a9fa9459Szrj typedef void (*walk_wild_section_handler_t) (lang_wild_statement_type *, 351*a9fa9459Szrj lang_input_statement_type *, 352*a9fa9459Szrj callback_t callback, 353*a9fa9459Szrj void *data); 354*a9fa9459Szrj 355*a9fa9459Szrj typedef bfd_boolean (*lang_match_sec_type_func) (bfd *, const asection *, 356*a9fa9459Szrj bfd *, const asection *); 357*a9fa9459Szrj 358*a9fa9459Szrj /* Binary search tree structure to efficiently sort sections by 359*a9fa9459Szrj name. */ 360*a9fa9459Szrj typedef struct lang_section_bst 361*a9fa9459Szrj { 362*a9fa9459Szrj asection *section; 363*a9fa9459Szrj struct lang_section_bst *left; 364*a9fa9459Szrj struct lang_section_bst *right; 365*a9fa9459Szrj } lang_section_bst_type; 366*a9fa9459Szrj 367*a9fa9459Szrj struct lang_wild_statement_struct 368*a9fa9459Szrj { 369*a9fa9459Szrj lang_statement_header_type header; 370*a9fa9459Szrj const char *filename; 371*a9fa9459Szrj bfd_boolean filenames_sorted; 372*a9fa9459Szrj struct wildcard_list *section_list; 373*a9fa9459Szrj bfd_boolean keep_sections; 374*a9fa9459Szrj lang_statement_list_type children; 375*a9fa9459Szrj 376*a9fa9459Szrj walk_wild_section_handler_t walk_wild_section_handler; 377*a9fa9459Szrj struct wildcard_list *handler_data[4]; 378*a9fa9459Szrj lang_section_bst_type *tree; 379*a9fa9459Szrj struct flag_info *section_flag_list; 380*a9fa9459Szrj }; 381*a9fa9459Szrj 382*a9fa9459Szrj typedef struct lang_address_statement_struct 383*a9fa9459Szrj { 384*a9fa9459Szrj lang_statement_header_type header; 385*a9fa9459Szrj const char *section_name; 386*a9fa9459Szrj union etree_union *address; 387*a9fa9459Szrj const segment_type *segment; 388*a9fa9459Szrj } lang_address_statement_type; 389*a9fa9459Szrj 390*a9fa9459Szrj typedef struct 391*a9fa9459Szrj { 392*a9fa9459Szrj lang_statement_header_type header; 393*a9fa9459Szrj bfd_vma output_offset; 394*a9fa9459Szrj bfd_size_type size; 395*a9fa9459Szrj asection *output_section; 396*a9fa9459Szrj fill_type *fill; 397*a9fa9459Szrj } lang_padding_statement_type; 398*a9fa9459Szrj 399*a9fa9459Szrj /* A group statement collects a set of libraries together. The 400*a9fa9459Szrj libraries are searched multiple times, until no new undefined 401*a9fa9459Szrj symbols are found. The effect is to search a group of libraries as 402*a9fa9459Szrj though they were a single library. */ 403*a9fa9459Szrj 404*a9fa9459Szrj typedef struct 405*a9fa9459Szrj { 406*a9fa9459Szrj lang_statement_header_type header; 407*a9fa9459Szrj lang_statement_list_type children; 408*a9fa9459Szrj } lang_group_statement_type; 409*a9fa9459Szrj 410*a9fa9459Szrj typedef struct 411*a9fa9459Szrj { 412*a9fa9459Szrj lang_statement_header_type header; 413*a9fa9459Szrj const char *where; 414*a9fa9459Szrj bfd_boolean is_before; 415*a9fa9459Szrj } lang_insert_statement_type; 416*a9fa9459Szrj 417*a9fa9459Szrj typedef union lang_statement_union 418*a9fa9459Szrj { 419*a9fa9459Szrj lang_statement_header_type header; 420*a9fa9459Szrj lang_wild_statement_type wild_statement; 421*a9fa9459Szrj lang_data_statement_type data_statement; 422*a9fa9459Szrj lang_reloc_statement_type reloc_statement; 423*a9fa9459Szrj lang_address_statement_type address_statement; 424*a9fa9459Szrj lang_output_section_statement_type output_section_statement; 425*a9fa9459Szrj lang_assignment_statement_type assignment_statement; 426*a9fa9459Szrj lang_input_statement_type input_statement; 427*a9fa9459Szrj lang_target_statement_type target_statement; 428*a9fa9459Szrj lang_output_statement_type output_statement; 429*a9fa9459Szrj lang_input_section_type input_section; 430*a9fa9459Szrj lang_common_statement_type common_statement; 431*a9fa9459Szrj lang_object_symbols_statement_type object_symbols_statement; 432*a9fa9459Szrj lang_fill_statement_type fill_statement; 433*a9fa9459Szrj lang_padding_statement_type padding_statement; 434*a9fa9459Szrj lang_group_statement_type group_statement; 435*a9fa9459Szrj lang_insert_statement_type insert_statement; 436*a9fa9459Szrj } lang_statement_union_type; 437*a9fa9459Szrj 438*a9fa9459Szrj /* This structure holds information about a program header, from the 439*a9fa9459Szrj PHDRS command in the linker script. */ 440*a9fa9459Szrj 441*a9fa9459Szrj struct lang_phdr 442*a9fa9459Szrj { 443*a9fa9459Szrj struct lang_phdr *next; 444*a9fa9459Szrj const char *name; 445*a9fa9459Szrj unsigned long type; 446*a9fa9459Szrj bfd_boolean filehdr; 447*a9fa9459Szrj bfd_boolean phdrs; 448*a9fa9459Szrj etree_type *at; 449*a9fa9459Szrj etree_type *flags; 450*a9fa9459Szrj }; 451*a9fa9459Szrj 452*a9fa9459Szrj /* This structure is used to hold a list of sections which may not 453*a9fa9459Szrj cross reference each other. */ 454*a9fa9459Szrj 455*a9fa9459Szrj typedef struct lang_nocrossref 456*a9fa9459Szrj { 457*a9fa9459Szrj struct lang_nocrossref *next; 458*a9fa9459Szrj const char *name; 459*a9fa9459Szrj } lang_nocrossref_type; 460*a9fa9459Szrj 461*a9fa9459Szrj /* The list of nocrossref lists. */ 462*a9fa9459Szrj 463*a9fa9459Szrj struct lang_nocrossrefs 464*a9fa9459Szrj { 465*a9fa9459Szrj struct lang_nocrossrefs *next; 466*a9fa9459Szrj lang_nocrossref_type *list; 467*a9fa9459Szrj bfd_boolean onlyfirst; 468*a9fa9459Szrj }; 469*a9fa9459Szrj 470*a9fa9459Szrj /* This structure is used to hold a list of input section names which 471*a9fa9459Szrj will not match an output section in the linker script. */ 472*a9fa9459Szrj 473*a9fa9459Szrj struct unique_sections 474*a9fa9459Szrj { 475*a9fa9459Szrj struct unique_sections *next; 476*a9fa9459Szrj const char *name; 477*a9fa9459Szrj }; 478*a9fa9459Szrj 479*a9fa9459Szrj /* Used by place_orphan to keep track of orphan sections and statements. */ 480*a9fa9459Szrj 481*a9fa9459Szrj struct orphan_save 482*a9fa9459Szrj { 483*a9fa9459Szrj const char *name; 484*a9fa9459Szrj flagword flags; 485*a9fa9459Szrj lang_output_section_statement_type *os; 486*a9fa9459Szrj asection **section; 487*a9fa9459Szrj lang_statement_union_type **stmt; 488*a9fa9459Szrj lang_output_section_statement_type **os_tail; 489*a9fa9459Szrj }; 490*a9fa9459Szrj 491*a9fa9459Szrj struct asneeded_minfo 492*a9fa9459Szrj { 493*a9fa9459Szrj struct asneeded_minfo *next; 494*a9fa9459Szrj const char *soname; 495*a9fa9459Szrj bfd *ref; 496*a9fa9459Szrj const char *name; 497*a9fa9459Szrj }; 498*a9fa9459Szrj 499*a9fa9459Szrj extern struct lang_phdr *lang_phdr_list; 500*a9fa9459Szrj extern struct lang_nocrossrefs *nocrossref_list; 501*a9fa9459Szrj extern const char *output_target; 502*a9fa9459Szrj extern lang_output_section_statement_type *abs_output_section; 503*a9fa9459Szrj extern lang_statement_list_type lang_output_section_statement; 504*a9fa9459Szrj extern struct lang_input_statement_flags input_flags; 505*a9fa9459Szrj extern bfd_boolean lang_has_input_file; 506*a9fa9459Szrj extern lang_statement_list_type *stat_ptr; 507*a9fa9459Szrj extern bfd_boolean delete_output_file_on_failure; 508*a9fa9459Szrj 509*a9fa9459Szrj extern struct bfd_sym_chain entry_symbol; 510*a9fa9459Szrj extern const char *entry_section; 511*a9fa9459Szrj extern bfd_boolean entry_from_cmdline; 512*a9fa9459Szrj extern lang_statement_list_type file_chain; 513*a9fa9459Szrj extern lang_statement_list_type input_file_chain; 514*a9fa9459Szrj 515*a9fa9459Szrj extern int lang_statement_iteration; 516*a9fa9459Szrj extern struct asneeded_minfo **asneeded_list_tail; 517*a9fa9459Szrj 518*a9fa9459Szrj extern void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *); 519*a9fa9459Szrj 520*a9fa9459Szrj extern void lang_init 521*a9fa9459Szrj (void); 522*a9fa9459Szrj extern void lang_finish 523*a9fa9459Szrj (void); 524*a9fa9459Szrj extern lang_memory_region_type * lang_memory_region_lookup 525*a9fa9459Szrj (const char * const, bfd_boolean); 526*a9fa9459Szrj extern void lang_memory_region_alias 527*a9fa9459Szrj (const char *, const char *); 528*a9fa9459Szrj extern void lang_map 529*a9fa9459Szrj (void); 530*a9fa9459Szrj extern void lang_set_flags 531*a9fa9459Szrj (lang_memory_region_type *, const char *, int); 532*a9fa9459Szrj extern void lang_add_output 533*a9fa9459Szrj (const char *, int from_script); 534*a9fa9459Szrj extern lang_output_section_statement_type *lang_enter_output_section_statement 535*a9fa9459Szrj (const char *, etree_type *, enum section_type, etree_type *, etree_type *, 536*a9fa9459Szrj etree_type *, int, int); 537*a9fa9459Szrj extern void lang_final 538*a9fa9459Szrj (void); 539*a9fa9459Szrj extern void lang_relax_sections 540*a9fa9459Szrj (bfd_boolean); 541*a9fa9459Szrj extern void lang_process 542*a9fa9459Szrj (void); 543*a9fa9459Szrj extern void lang_section_start 544*a9fa9459Szrj (const char *, union etree_union *, const segment_type *); 545*a9fa9459Szrj extern void lang_add_entry 546*a9fa9459Szrj (const char *, bfd_boolean); 547*a9fa9459Szrj extern void lang_default_entry 548*a9fa9459Szrj (const char *); 549*a9fa9459Szrj extern void lang_add_target 550*a9fa9459Szrj (const char *); 551*a9fa9459Szrj extern void lang_add_wild 552*a9fa9459Szrj (struct wildcard_spec *, struct wildcard_list *, bfd_boolean); 553*a9fa9459Szrj extern void lang_add_map 554*a9fa9459Szrj (const char *); 555*a9fa9459Szrj extern void lang_add_fill 556*a9fa9459Szrj (fill_type *); 557*a9fa9459Szrj extern lang_assignment_statement_type *lang_add_assignment 558*a9fa9459Szrj (union etree_union *); 559*a9fa9459Szrj extern void lang_add_attribute 560*a9fa9459Szrj (enum statement_enum); 561*a9fa9459Szrj extern void lang_startup 562*a9fa9459Szrj (const char *); 563*a9fa9459Szrj extern void lang_float 564*a9fa9459Szrj (bfd_boolean); 565*a9fa9459Szrj extern void lang_leave_output_section_statement 566*a9fa9459Szrj (fill_type *, const char *, lang_output_section_phdr_list *, 567*a9fa9459Szrj const char *); 568*a9fa9459Szrj extern void lang_statement_append 569*a9fa9459Szrj (lang_statement_list_type *, lang_statement_union_type *, 570*a9fa9459Szrj lang_statement_union_type **); 571*a9fa9459Szrj extern void lang_for_each_input_file 572*a9fa9459Szrj (void (*dothis) (lang_input_statement_type *)); 573*a9fa9459Szrj extern void lang_for_each_file 574*a9fa9459Szrj (void (*dothis) (lang_input_statement_type *)); 575*a9fa9459Szrj extern void lang_reset_memory_regions 576*a9fa9459Szrj (void); 577*a9fa9459Szrj extern void lang_do_assignments 578*a9fa9459Szrj (lang_phase_type); 579*a9fa9459Szrj extern asection *section_for_dot 580*a9fa9459Szrj (void); 581*a9fa9459Szrj 582*a9fa9459Szrj #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ 583*a9fa9459Szrj lang_input_statement_type *statement; \ 584*a9fa9459Szrj for (statement = (lang_input_statement_type *) file_chain.head; \ 585*a9fa9459Szrj statement != (lang_input_statement_type *) NULL; \ 586*a9fa9459Szrj statement = (lang_input_statement_type *) statement->next) \ 587*a9fa9459Szrj 588*a9fa9459Szrj #define lang_output_section_find(NAME) \ 589*a9fa9459Szrj lang_output_section_statement_lookup (NAME, 0, FALSE) 590*a9fa9459Szrj 591*a9fa9459Szrj extern void lang_process 592*a9fa9459Szrj (void); 593*a9fa9459Szrj extern void ldlang_add_file 594*a9fa9459Szrj (lang_input_statement_type *); 595*a9fa9459Szrj extern lang_output_section_statement_type *lang_output_section_find_by_flags 596*a9fa9459Szrj (const asection *, flagword, lang_output_section_statement_type **, 597*a9fa9459Szrj lang_match_sec_type_func); 598*a9fa9459Szrj extern lang_output_section_statement_type *lang_insert_orphan 599*a9fa9459Szrj (asection *, const char *, int, lang_output_section_statement_type *, 600*a9fa9459Szrj struct orphan_save *, etree_type *, lang_statement_list_type *); 601*a9fa9459Szrj extern lang_input_statement_type *lang_add_input_file 602*a9fa9459Szrj (const char *, lang_input_file_enum_type, const char *); 603*a9fa9459Szrj extern void lang_add_keepsyms_file 604*a9fa9459Szrj (const char *); 605*a9fa9459Szrj extern lang_output_section_statement_type *lang_output_section_get 606*a9fa9459Szrj (const asection *); 607*a9fa9459Szrj extern lang_output_section_statement_type *lang_output_section_statement_lookup 608*a9fa9459Szrj (const char *, int, bfd_boolean); 609*a9fa9459Szrj extern lang_output_section_statement_type *next_matching_output_section_statement 610*a9fa9459Szrj (lang_output_section_statement_type *, int); 611*a9fa9459Szrj extern void ldlang_add_undef 612*a9fa9459Szrj (const char *const, bfd_boolean); 613*a9fa9459Szrj extern void ldlang_add_require_defined 614*a9fa9459Szrj (const char *const); 615*a9fa9459Szrj extern void lang_add_output_format 616*a9fa9459Szrj (const char *, const char *, const char *, int); 617*a9fa9459Szrj extern void lang_list_init 618*a9fa9459Szrj (lang_statement_list_type *); 619*a9fa9459Szrj extern void push_stat_ptr 620*a9fa9459Szrj (lang_statement_list_type *); 621*a9fa9459Szrj extern void pop_stat_ptr 622*a9fa9459Szrj (void); 623*a9fa9459Szrj extern void lang_add_data 624*a9fa9459Szrj (int type, union etree_union *); 625*a9fa9459Szrj extern void lang_add_reloc 626*a9fa9459Szrj (bfd_reloc_code_real_type, reloc_howto_type *, asection *, const char *, 627*a9fa9459Szrj union etree_union *); 628*a9fa9459Szrj extern void lang_for_each_statement 629*a9fa9459Szrj (void (*) (lang_statement_union_type *)); 630*a9fa9459Szrj extern void lang_for_each_statement_worker 631*a9fa9459Szrj (void (*) (lang_statement_union_type *), lang_statement_union_type *); 632*a9fa9459Szrj extern void *stat_alloc 633*a9fa9459Szrj (size_t); 634*a9fa9459Szrj extern void strip_excluded_output_sections 635*a9fa9459Szrj (void); 636*a9fa9459Szrj extern void lang_clear_os_map 637*a9fa9459Szrj (void); 638*a9fa9459Szrj extern void dprint_statement 639*a9fa9459Szrj (lang_statement_union_type *, int); 640*a9fa9459Szrj extern void lang_size_sections 641*a9fa9459Szrj (bfd_boolean *, bfd_boolean); 642*a9fa9459Szrj extern void one_lang_size_sections_pass 643*a9fa9459Szrj (bfd_boolean *, bfd_boolean); 644*a9fa9459Szrj extern void lang_add_insert 645*a9fa9459Szrj (const char *, int); 646*a9fa9459Szrj extern void lang_enter_group 647*a9fa9459Szrj (void); 648*a9fa9459Szrj extern void lang_leave_group 649*a9fa9459Szrj (void); 650*a9fa9459Szrj extern void lang_add_section 651*a9fa9459Szrj (lang_statement_list_type *, asection *, 652*a9fa9459Szrj struct flag_info *, lang_output_section_statement_type *); 653*a9fa9459Szrj extern void lang_new_phdr 654*a9fa9459Szrj (const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *, 655*a9fa9459Szrj etree_type *); 656*a9fa9459Szrj extern void lang_add_nocrossref 657*a9fa9459Szrj (lang_nocrossref_type *); 658*a9fa9459Szrj extern void lang_add_nocrossref_to 659*a9fa9459Szrj (lang_nocrossref_type *); 660*a9fa9459Szrj extern void lang_enter_overlay 661*a9fa9459Szrj (etree_type *, etree_type *); 662*a9fa9459Szrj extern void lang_enter_overlay_section 663*a9fa9459Szrj (const char *); 664*a9fa9459Szrj extern void lang_leave_overlay_section 665*a9fa9459Szrj (fill_type *, lang_output_section_phdr_list *); 666*a9fa9459Szrj extern void lang_leave_overlay 667*a9fa9459Szrj (etree_type *, int, fill_type *, const char *, 668*a9fa9459Szrj lang_output_section_phdr_list *, const char *); 669*a9fa9459Szrj 670*a9fa9459Szrj extern struct bfd_elf_version_expr *lang_new_vers_pattern 671*a9fa9459Szrj (struct bfd_elf_version_expr *, const char *, const char *, bfd_boolean); 672*a9fa9459Szrj extern struct bfd_elf_version_tree *lang_new_vers_node 673*a9fa9459Szrj (struct bfd_elf_version_expr *, struct bfd_elf_version_expr *); 674*a9fa9459Szrj extern struct bfd_elf_version_deps *lang_add_vers_depend 675*a9fa9459Szrj (struct bfd_elf_version_deps *, const char *); 676*a9fa9459Szrj extern void lang_register_vers_node 677*a9fa9459Szrj (const char *, struct bfd_elf_version_tree *, struct bfd_elf_version_deps *); 678*a9fa9459Szrj extern void lang_append_dynamic_list (struct bfd_elf_version_expr *); 679*a9fa9459Szrj extern void lang_append_dynamic_list_cpp_typeinfo (void); 680*a9fa9459Szrj extern void lang_append_dynamic_list_cpp_new (void); 681*a9fa9459Szrj extern void lang_add_unique 682*a9fa9459Szrj (const char *); 683*a9fa9459Szrj extern const char *lang_get_output_target 684*a9fa9459Szrj (void); 685*a9fa9459Szrj extern void add_excluded_libs (const char *); 686*a9fa9459Szrj extern bfd_boolean load_symbols 687*a9fa9459Szrj (lang_input_statement_type *, lang_statement_list_type *); 688*a9fa9459Szrj 689*a9fa9459Szrj extern bfd_boolean 690*a9fa9459Szrj ldlang_override_segment_assignment 691*a9fa9459Szrj (struct bfd_link_info *, bfd *, asection *, asection *, bfd_boolean); 692*a9fa9459Szrj 693*a9fa9459Szrj extern void 694*a9fa9459Szrj lang_ld_feature (char *); 695*a9fa9459Szrj 696*a9fa9459Szrj extern void 697*a9fa9459Szrj lang_print_memory_usage (void); 698*a9fa9459Szrj 699*a9fa9459Szrj extern void 700*a9fa9459Szrj lang_add_gc_name (const char *); 701*a9fa9459Szrj 702*a9fa9459Szrj #endif 703