/* ldlang.h - linker command language support
Copyright (C) 1991-2024 Free Software Foundation, Inc.
This file is part of the GNU Binutils.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
typedef struct lang_output_section_statement_struct
{
lang_statement_header_type header;
lang_statement_list_type children;
struct lang_output_section_statement_struct *next;
struct lang_output_section_statement_struct *prev;
const char *name;
asection *bfd_section;
lang_memory_region_type *region;
lang_memory_region_type *lma_region;
fill_type *fill;
union etree_union *addr_tree;
union etree_union *load_base;
union etree_union *section_alignment;
union etree_union *subsection_alignment;
/* If non-null, an expression to evaluate after setting the section's
size. The expression is evaluated inside REGION (above) with '.'
set to the end of the section. Used in the last overlay section
to move '.' past all the overlaid sections. */
union etree_union *update_dot_tree;
lang_output_section_phdr_list *phdrs;
/* Used by ELF SHF_LINK_ORDER sorting. */
void *data;
unsigned int block_value;
int constraint;
flagword flags;
enum section_type sectype;
etree_type *sectype_value;
unsigned int processed_vma : 1;
unsigned int processed_lma : 1;
unsigned int all_input_readonly : 1;
/* If this section should be ignored. */
unsigned int ignored : 1;
/* If this section should update "dot". Prevents section being ignored. */
unsigned int update_dot : 1;
/* If this section is after assignment to _end. */
unsigned int after_end : 1;
/* If this section uses the alignment of its input sections. */
unsigned int align_lma_with_input : 1;
/* If script has duplicate output section statements of the same name
create duplicate output sections. */
unsigned int dup_output : 1;
} lang_output_section_statement_type;
/* Section to generate reloc against.
Exactly one of section and name must be NULL. */
asection *section;
/* Name of symbol to generate reloc against.
Exactly one of section and name must be NULL. */
const char *name;
/* Expression for addend. */
union etree_union *addend_exp;
/* Resolved addend. */
bfd_vma addend_value;
/* Output section where reloc should be performed. */
asection *output_section;
/* Offset within output section. */
bfd_vma output_offset;
} lang_reloc_statement_type;
struct lang_input_statement_flags
{
/* 1 means this file was specified in a -l option. */
unsigned int maybe_archive : 1;
/* 1 means this file was specified in a -l:namespec option. */
unsigned int full_name_provided : 1;
/* 1 means search a set of directories for this file. */
unsigned int search_dirs : 1;
/* 1 means this was found when processing a script in the sysroot. */
unsigned int sysrooted : 1;
/* 1 means this is base file of incremental load.
Do not load this file's text or data.
Also default text_start to after this file's bss. */
unsigned int just_syms : 1;
/* Whether to search for this entry as a dynamic archive. */
unsigned int dynamic : 1;
/* Set if a DT_NEEDED tag should be added not just for the dynamic library
explicitly given by this entry but also for any dynamic libraries in
this entry's needed list. */
unsigned int add_DT_NEEDED_for_dynamic : 1;
/* Set if this entry should cause a DT_NEEDED tag only when some
regular file references its symbols (ie. --as-needed is in effect). */
unsigned int add_DT_NEEDED_for_regular : 1;
/* Whether to include the entire contents of an archive. */
unsigned int whole_archive : 1;
/* Set when bfd opening is successful. */
unsigned int loaded : 1;
unsigned int real : 1;
/* Set if the file does not exist. */
unsigned int missing_file : 1;
/* Set if reloading an archive or --as-needed lib. */
unsigned int reload : 1;
#if BFD_SUPPORTS_PLUGINS
/* Set if the file was claimed by a plugin. */
unsigned int claimed : 1;
/* Set if the file was claimed from an archive. */
unsigned int claim_archive : 1;
/* Set if added by the lto plugin add_input_file callback. */
unsigned int lto_output : 1;
#endif /* BFD_SUPPORTS_PLUGINS */
/* Head of list of pushed flags. */
struct lang_input_statement_flags *pushed;
};
typedef struct lang_input_statement_struct
{
lang_statement_header_type header;
/* Name of this file. */
const char *filename;
/* Name to use for the symbol giving address of text start.
Usually the same as filename, but for a file spec'd with
-l this is the -l switch itself rather than the filename. */
const char *local_sym_name;
/* Name to use when sorting. */
const char *sort_key;
/* Extra search path. Used to find a file relative to the
directory of the current linker script. */
const char *extra_search_path;
bfd *the_bfd;
ctf_archive_t *the_ctf;
struct flag_info *section_flag_list;
/* Next pointer for file_chain statement list. */
struct lang_input_statement_struct *next;
/* Next pointer for input_file_chain statement list. */
struct lang_input_statement_struct *next_real_file;
/* For input sections, when writing a map file: head / tail of a linked
list of hash table entries for symbols defined in this section. */
typedef struct input_section_userdata_struct
{
struct map_symbol_def *map_symbol_def_head;
struct map_symbol_def **map_symbol_def_tail;
unsigned long map_symbol_def_count;
} input_section_userdata_type;
/* A group statement collects a set of libraries together. The
libraries are searched multiple times, until no new undefined
symbols are found. The effect is to search a group of libraries as
though they were a single library. */