00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef LDLANG_H
00028 #define LDLANG_H
00029
00030 #define DEFAULT_MEMORY_REGION "*default*"
00031
00032 typedef enum
00033 {
00034 lang_input_file_is_l_enum,
00035 lang_input_file_is_symbols_only_enum,
00036 lang_input_file_is_marker_enum,
00037 lang_input_file_is_fake_enum,
00038 lang_input_file_is_search_file_enum,
00039 lang_input_file_is_file_enum
00040 } lang_input_file_enum_type;
00041
00042 struct _fill_type
00043 {
00044 size_t size;
00045 unsigned char data[1];
00046 };
00047
00048 typedef struct statement_list
00049 {
00050 union lang_statement_union *head;
00051 union lang_statement_union **tail;
00052 } lang_statement_list_type;
00053
00054 typedef struct memory_region_struct
00055 {
00056 char *name;
00057 struct memory_region_struct *next;
00058 bfd_vma origin;
00059 bfd_size_type length;
00060 bfd_vma current;
00061 bfd_size_type old_length;
00062 flagword flags;
00063 flagword not_flags;
00064 bfd_boolean had_full_message;
00065 } lang_memory_region_type;
00066
00067 typedef struct lang_statement_header_struct
00068 {
00069 union lang_statement_union *next;
00070 enum statement_enum
00071 {
00072 lang_output_section_statement_enum,
00073 lang_assignment_statement_enum,
00074 lang_input_statement_enum,
00075 lang_address_statement_enum,
00076 lang_wild_statement_enum,
00077 lang_input_section_enum,
00078 lang_object_symbols_statement_enum,
00079 lang_fill_statement_enum,
00080 lang_data_statement_enum,
00081 lang_reloc_statement_enum,
00082 lang_target_statement_enum,
00083 lang_output_statement_enum,
00084 lang_padding_statement_enum,
00085 lang_group_statement_enum,
00086
00087 lang_afile_asection_pair_statement_enum,
00088 lang_constructors_statement_enum
00089 } type;
00090 } lang_statement_header_type;
00091
00092 typedef struct
00093 {
00094 lang_statement_header_type header;
00095 union etree_union *exp;
00096 } lang_assignment_statement_type;
00097
00098 typedef struct lang_target_statement_struct
00099 {
00100 lang_statement_header_type header;
00101 const char *target;
00102 } lang_target_statement_type;
00103
00104 typedef struct lang_output_statement_struct
00105 {
00106 lang_statement_header_type header;
00107 const char *name;
00108 } lang_output_statement_type;
00109
00110
00111
00112 enum section_type
00113 {
00114 normal_section,
00115 dsect_section,
00116 copy_section,
00117 noload_section,
00118 info_section,
00119 overlay_section
00120 };
00121
00122
00123
00124
00125 typedef struct lang_output_section_phdr_list
00126 {
00127 struct lang_output_section_phdr_list *next;
00128 const char *name;
00129 bfd_boolean used;
00130 } lang_output_section_phdr_list;
00131
00132 typedef struct lang_output_section_statement_struct
00133 {
00134 lang_statement_header_type header;
00135 union etree_union *addr_tree;
00136 lang_statement_list_type children;
00137 const char *memspec;
00138 struct lang_output_section_statement_struct *next;
00139 const char *name;
00140
00141 int processed;
00142
00143 asection *bfd_section;
00144 flagword flags;
00145 enum section_type sectype;
00146 lang_memory_region_type *region;
00147 lang_memory_region_type *lma_region;
00148 size_t block_value;
00149 fill_type *fill;
00150
00151 int subsection_alignment;
00152 int section_alignment;
00153 int constraint;
00154 bfd_boolean all_input_readonly;
00155
00156 union etree_union *load_base;
00157
00158
00159
00160
00161
00162 union etree_union *update_dot_tree;
00163
00164 lang_output_section_phdr_list *phdrs;
00165 } lang_output_section_statement_type;
00166
00167 typedef struct
00168 {
00169 lang_statement_header_type header;
00170 } lang_common_statement_type;
00171
00172 typedef struct
00173 {
00174 lang_statement_header_type header;
00175 } lang_object_symbols_statement_type;
00176
00177 typedef struct
00178 {
00179 lang_statement_header_type header;
00180 fill_type *fill;
00181 int size;
00182 asection *output_section;
00183 } lang_fill_statement_type;
00184
00185 typedef struct
00186 {
00187 lang_statement_header_type header;
00188 unsigned int type;
00189 union etree_union *exp;
00190 bfd_vma value;
00191 asection *output_section;
00192 bfd_vma output_vma;
00193 } lang_data_statement_type;
00194
00195
00196
00197 typedef struct
00198 {
00199 lang_statement_header_type header;
00200
00201
00202 bfd_reloc_code_real_type reloc;
00203
00204
00205 reloc_howto_type *howto;
00206
00207
00208
00209 asection *section;
00210
00211
00212
00213 const char *name;
00214
00215
00216 union etree_union *addend_exp;
00217
00218
00219 bfd_vma addend_value;
00220
00221
00222 asection *output_section;
00223
00224
00225 bfd_vma output_vma;
00226 } lang_reloc_statement_type;
00227
00228 typedef struct lang_input_statement_struct
00229 {
00230 lang_statement_header_type header;
00231
00232 const char *filename;
00233
00234
00235
00236 const char *local_sym_name;
00237
00238 bfd *the_bfd;
00239
00240 bfd_boolean closed;
00241 file_ptr passive_position;
00242
00243
00244 asymbol **asymbols;
00245 unsigned int symbol_count;
00246
00247
00248
00249 union lang_statement_union *next;
00250
00251
00252 union lang_statement_union *next_real_file;
00253
00254 bfd_boolean is_archive;
00255
00256
00257 bfd_boolean search_dirs_flag;
00258
00259
00260
00261
00262
00263 bfd_boolean sysrooted;
00264
00265
00266
00267
00268 bfd_boolean just_syms_flag;
00269
00270
00271 bfd_boolean dynamic;
00272
00273
00274
00275 bfd_boolean add_needed;
00276
00277
00278
00279 bfd_boolean as_needed;
00280
00281
00282 bfd_boolean whole_archive;
00283
00284 bfd_boolean loaded;
00285
00286 const char *target;
00287 bfd_boolean real;
00288 } lang_input_statement_type;
00289
00290 typedef struct
00291 {
00292 lang_statement_header_type header;
00293 asection *section;
00294 lang_input_statement_type *ifile;
00295
00296 } lang_input_section_type;
00297
00298 typedef struct
00299 {
00300 lang_statement_header_type header;
00301 asection *section;
00302 union lang_statement_union *file;
00303 } lang_afile_asection_pair_statement_type;
00304
00305 typedef struct lang_wild_statement_struct
00306 {
00307 lang_statement_header_type header;
00308 const char *filename;
00309 bfd_boolean filenames_sorted;
00310 struct wildcard_list *section_list;
00311 bfd_boolean keep_sections;
00312 lang_statement_list_type children;
00313 } lang_wild_statement_type;
00314
00315 typedef struct lang_address_statement_struct
00316 {
00317 lang_statement_header_type header;
00318 const char *section_name;
00319 union etree_union *address;
00320 const segment_type *segment;
00321 } lang_address_statement_type;
00322
00323 typedef struct
00324 {
00325 lang_statement_header_type header;
00326 bfd_vma output_offset;
00327 size_t size;
00328 asection *output_section;
00329 fill_type *fill;
00330 } lang_padding_statement_type;
00331
00332
00333
00334
00335
00336
00337 typedef struct
00338 {
00339 lang_statement_header_type header;
00340 lang_statement_list_type children;
00341 } lang_group_statement_type;
00342
00343 typedef union lang_statement_union
00344 {
00345 lang_statement_header_type header;
00346 lang_wild_statement_type wild_statement;
00347 lang_data_statement_type data_statement;
00348 lang_reloc_statement_type reloc_statement;
00349 lang_address_statement_type address_statement;
00350 lang_output_section_statement_type output_section_statement;
00351 lang_afile_asection_pair_statement_type afile_asection_pair_statement;
00352 lang_assignment_statement_type assignment_statement;
00353 lang_input_statement_type input_statement;
00354 lang_target_statement_type target_statement;
00355 lang_output_statement_type output_statement;
00356 lang_input_section_type input_section;
00357 lang_common_statement_type common_statement;
00358 lang_object_symbols_statement_type object_symbols_statement;
00359 lang_fill_statement_type fill_statement;
00360 lang_padding_statement_type padding_statement;
00361 lang_group_statement_type group_statement;
00362 } lang_statement_union_type;
00363
00364
00365
00366
00367 struct lang_phdr
00368 {
00369 struct lang_phdr *next;
00370 const char *name;
00371 unsigned long type;
00372 bfd_boolean filehdr;
00373 bfd_boolean phdrs;
00374 etree_type *at;
00375 etree_type *flags;
00376 };
00377
00378
00379
00380
00381 typedef struct lang_nocrossref
00382 {
00383 struct lang_nocrossref *next;
00384 const char *name;
00385 } lang_nocrossref_type;
00386
00387
00388
00389 struct lang_nocrossrefs
00390 {
00391 struct lang_nocrossrefs *next;
00392 lang_nocrossref_type *list;
00393 };
00394
00395 extern struct lang_nocrossrefs *nocrossref_list;
00396
00397
00398
00399
00400 struct unique_sections
00401 {
00402 struct unique_sections *next;
00403 const char *name;
00404 };
00405
00406
00407
00408
00409 struct lang_definedness_hash_entry
00410 {
00411 struct bfd_hash_entry root;
00412 int iteration;
00413 };
00414
00415
00416
00417 struct orphan_save {
00418 const char *name;
00419 flagword flags;
00420 lang_output_section_statement_type *os;
00421 asection **section;
00422 lang_statement_union_type **stmt;
00423 lang_output_section_statement_type **os_tail;
00424 };
00425
00426 extern struct unique_sections *unique_section_list;
00427
00428 extern lang_output_section_statement_type *abs_output_section;
00429 extern lang_statement_list_type lang_output_section_statement;
00430 extern bfd_boolean lang_has_input_file;
00431 extern etree_type *base;
00432 extern lang_statement_list_type *stat_ptr;
00433 extern bfd_boolean delete_output_file_on_failure;
00434
00435 extern struct bfd_sym_chain entry_symbol;
00436 extern const char *entry_section;
00437 extern bfd_boolean entry_from_cmdline;
00438 extern lang_statement_list_type file_chain;
00439
00440 extern int lang_statement_iteration;
00441
00442 extern void lang_init
00443 (void);
00444 extern lang_memory_region_type *lang_memory_region_lookup
00445 (const char *const, bfd_boolean);
00446 extern lang_memory_region_type *lang_memory_region_default
00447 (asection *);
00448 extern void lang_map
00449 (void);
00450 extern void lang_set_flags
00451 (lang_memory_region_type *, const char *, int);
00452 extern void lang_add_output
00453 (const char *, int from_script);
00454 extern lang_output_section_statement_type *lang_enter_output_section_statement
00455 (const char *output_section_statement_name,
00456 etree_type *address_exp,
00457 enum section_type sectype,
00458 etree_type *align,
00459 etree_type *subalign,
00460 etree_type *, int);
00461 extern void lang_final
00462 (void);
00463 extern void lang_process
00464 (void);
00465 extern void lang_section_start
00466 (const char *, union etree_union *, const segment_type *);
00467 extern void lang_add_entry
00468 (const char *, bfd_boolean);
00469 extern void lang_add_target
00470 (const char *);
00471 extern void lang_add_wild
00472 (struct wildcard_spec *, struct wildcard_list *, bfd_boolean);
00473 extern void lang_add_map
00474 (const char *);
00475 extern void lang_add_fill
00476 (fill_type *);
00477 extern lang_assignment_statement_type *lang_add_assignment
00478 (union etree_union *);
00479 extern void lang_add_attribute
00480 (enum statement_enum);
00481 extern void lang_startup
00482 (const char *);
00483 extern void lang_float
00484 (bfd_boolean);
00485 extern void lang_leave_output_section_statement
00486 (fill_type *, const char *, lang_output_section_phdr_list *,
00487 const char *);
00488 extern void lang_abs_symbol_at_end_of
00489 (const char *, const char *);
00490 extern void lang_abs_symbol_at_beginning_of
00491 (const char *, const char *);
00492 extern void lang_statement_append
00493 (lang_statement_list_type *, lang_statement_union_type *,
00494 lang_statement_union_type **);
00495 extern void lang_for_each_input_file
00496 (void (*dothis) (lang_input_statement_type *));
00497 extern void lang_for_each_file
00498 (void (*dothis) (lang_input_statement_type *));
00499 extern void lang_reset_memory_regions
00500 (void);
00501 extern void lang_do_assignments
00502 (lang_statement_union_type *, lang_output_section_statement_type *,
00503 fill_type *, bfd_vma);
00504
00505 #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
00506 lang_input_statement_type *statement; \
00507 for (statement = (lang_input_statement_type *) file_chain.head; \
00508 statement != (lang_input_statement_type *) NULL; \
00509 statement = (lang_input_statement_type *) statement->next) \
00510
00511 extern void lang_process
00512 (void);
00513 extern void ldlang_add_file
00514 (lang_input_statement_type *);
00515 extern lang_output_section_statement_type *lang_output_section_find
00516 (const char * const);
00517 extern lang_output_section_statement_type *lang_output_section_find_by_flags
00518 (const asection *, lang_output_section_statement_type **exact);
00519 extern lang_output_section_statement_type *lang_insert_orphan
00520 (lang_input_statement_type *, asection *, const char *,
00521 lang_output_section_statement_type *, struct orphan_save *,
00522 etree_type *, lang_statement_list_type *);
00523 extern lang_input_statement_type *lang_add_input_file
00524 (const char *, lang_input_file_enum_type, const char *);
00525 extern void lang_add_keepsyms_file
00526 (const char *);
00527 extern lang_output_section_statement_type *
00528 lang_output_section_statement_lookup
00529 (const char *const);
00530 extern void ldlang_add_undef
00531 (const char *const);
00532 extern void lang_add_output_format
00533 (const char *, const char *, const char *, int);
00534 extern void lang_list_init
00535 (lang_statement_list_type *);
00536 extern void lang_add_data
00537 (int type, union etree_union *);
00538 extern void lang_add_reloc
00539 (bfd_reloc_code_real_type, reloc_howto_type *, asection *, const char *,
00540 union etree_union *);
00541 extern void lang_for_each_statement
00542 (void (*) (lang_statement_union_type *));
00543 extern void *stat_alloc
00544 (size_t);
00545 extern void dprint_statement
00546 (lang_statement_union_type *, int);
00547 extern bfd_vma lang_size_sections
00548 (lang_statement_union_type *, lang_output_section_statement_type *,
00549 lang_statement_union_type **, fill_type *, bfd_vma, bfd_boolean *,
00550 bfd_boolean);
00551 extern void lang_enter_group
00552 (void);
00553 extern void lang_leave_group
00554 (void);
00555 extern void lang_add_section
00556 (lang_statement_list_type *, asection *,
00557 lang_output_section_statement_type *, lang_input_statement_type *);
00558 extern void lang_new_phdr
00559 (const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *,
00560 etree_type *);
00561 extern void lang_add_nocrossref
00562 (lang_nocrossref_type *);
00563 extern void lang_enter_overlay
00564 (etree_type *, etree_type *);
00565 extern void lang_enter_overlay_section
00566 (const char *);
00567 extern void lang_leave_overlay_section
00568 (fill_type *, lang_output_section_phdr_list *);
00569 extern void lang_leave_overlay
00570 (etree_type *, int, fill_type *, const char *,
00571 lang_output_section_phdr_list *, const char *);
00572
00573 extern struct bfd_elf_version_tree *lang_elf_version_info;
00574
00575 extern struct bfd_elf_version_expr *lang_new_vers_pattern
00576 (struct bfd_elf_version_expr *, const char *, const char *);
00577 extern struct bfd_elf_version_tree *lang_new_vers_node
00578 (struct bfd_elf_version_expr *, struct bfd_elf_version_expr *);
00579 extern struct bfd_elf_version_deps *lang_add_vers_depend
00580 (struct bfd_elf_version_deps *, const char *);
00581 extern void lang_register_vers_node
00582 (const char *, struct bfd_elf_version_tree *, struct bfd_elf_version_deps *);
00583 bfd_boolean unique_section_p
00584 (const asection *);
00585 extern void lang_add_unique
00586 (const char *);
00587 extern const char *lang_get_output_target
00588 (void);
00589 extern void lang_track_definedness (const char *);
00590 extern int lang_symbol_definition_iteration (const char *);
00591 extern void lang_update_definedness
00592 (const char *, struct bfd_link_hash_entry *);
00593
00594 extern void add_excluded_libs (const char *);
00595
00596 #endif