1*fae548d3Szrj /* ld.h -- general linker header file 2*fae548d3Szrj Copyright (C) 1991-2020 Free Software Foundation, Inc. 3*fae548d3Szrj 4*fae548d3Szrj This file is part of the GNU Binutils. 5*fae548d3Szrj 6*fae548d3Szrj This program is free software; you can redistribute it and/or modify 7*fae548d3Szrj it under the terms of the GNU General Public License as published by 8*fae548d3Szrj the Free Software Foundation; either version 3 of the License, or 9*fae548d3Szrj (at your option) any later version. 10*fae548d3Szrj 11*fae548d3Szrj This program is distributed in the hope that it will be useful, 12*fae548d3Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of 13*fae548d3Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*fae548d3Szrj GNU General Public License for more details. 15*fae548d3Szrj 16*fae548d3Szrj You should have received a copy of the GNU General Public License 17*fae548d3Szrj along with this program; if not, write to the Free Software 18*fae548d3Szrj Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 19*fae548d3Szrj MA 02110-1301, USA. */ 20*fae548d3Szrj 21*fae548d3Szrj #ifndef LD_H 22*fae548d3Szrj #define LD_H 23*fae548d3Szrj 24*fae548d3Szrj #ifdef HAVE_LOCALE_H 25*fae548d3Szrj #endif 26*fae548d3Szrj #ifndef SEEK_CUR 27*fae548d3Szrj #define SEEK_CUR 1 28*fae548d3Szrj #endif 29*fae548d3Szrj #ifndef SEEK_END 30*fae548d3Szrj #define SEEK_END 2 31*fae548d3Szrj #endif 32*fae548d3Szrj 33*fae548d3Szrj #ifdef HAVE_LOCALE_H 34*fae548d3Szrj # ifndef ENABLE_NLS 35*fae548d3Szrj /* The Solaris version of locale.h always includes libintl.h. If we have 36*fae548d3Szrj been configured with --disable-nls then ENABLE_NLS will not be defined 37*fae548d3Szrj and the dummy definitions of bindtextdomain (et al) below will conflict 38*fae548d3Szrj with the defintions in libintl.h. So we define these values to prevent 39*fae548d3Szrj the bogus inclusion of libintl.h. */ 40*fae548d3Szrj # define _LIBINTL_H 41*fae548d3Szrj # define _LIBGETTEXT_H 42*fae548d3Szrj # endif 43*fae548d3Szrj # include <locale.h> 44*fae548d3Szrj #endif 45*fae548d3Szrj 46*fae548d3Szrj #ifdef ENABLE_NLS 47*fae548d3Szrj # include <libintl.h> 48*fae548d3Szrj # define _(String) gettext (String) 49*fae548d3Szrj # ifdef gettext_noop 50*fae548d3Szrj # define N_(String) gettext_noop (String) 51*fae548d3Szrj # else 52*fae548d3Szrj # define N_(String) (String) 53*fae548d3Szrj # endif 54*fae548d3Szrj #else 55*fae548d3Szrj # define gettext(Msgid) (Msgid) 56*fae548d3Szrj # define dgettext(Domainname, Msgid) (Msgid) 57*fae548d3Szrj # define dcgettext(Domainname, Msgid, Category) (Msgid) 58*fae548d3Szrj # define ngettext(Msgid1, Msgid2, n) \ 59*fae548d3Szrj (n == 1 ? Msgid1 : Msgid2) 60*fae548d3Szrj # define dngettext(Domainname, Msgid1, Msgid2, n) \ 61*fae548d3Szrj (n == 1 ? Msgid1 : Msgid2) 62*fae548d3Szrj # define dcngettext(Domainname, Msgid1, Msgid2, n, Category) \ 63*fae548d3Szrj (n == 1 ? Msgid1 : Msgid2) 64*fae548d3Szrj # define textdomain(Domainname) do {} while (0) 65*fae548d3Szrj # define bindtextdomain(Domainname, Dirname) do {} while (0) 66*fae548d3Szrj # define _(String) (String) 67*fae548d3Szrj # define N_(String) (String) 68*fae548d3Szrj #endif 69*fae548d3Szrj 70*fae548d3Szrj /* Look in this environment name for the linker to pretend to be */ 71*fae548d3Szrj #define EMULATION_ENVIRON "LDEMULATION" 72*fae548d3Szrj /* If in there look for the strings: */ 73*fae548d3Szrj 74*fae548d3Szrj /* Look in this variable for a target format */ 75*fae548d3Szrj #define TARGET_ENVIRON "GNUTARGET" 76*fae548d3Szrj 77*fae548d3Szrj /* Input sections which are put in a section of this name are actually 78*fae548d3Szrj discarded. */ 79*fae548d3Szrj #define DISCARD_SECTION_NAME "/DISCARD/" 80*fae548d3Szrj 81*fae548d3Szrj /* A file name list. */ 82*fae548d3Szrj typedef struct name_list 83*fae548d3Szrj { 84*fae548d3Szrj const char *name; 85*fae548d3Szrj struct name_list *next; 86*fae548d3Szrj } 87*fae548d3Szrj name_list; 88*fae548d3Szrj 89*fae548d3Szrj typedef enum {sort_none, sort_ascending, sort_descending} sort_order; 90*fae548d3Szrj 91*fae548d3Szrj /* A wildcard specification. */ 92*fae548d3Szrj 93*fae548d3Szrj typedef enum 94*fae548d3Szrj { 95*fae548d3Szrj none, by_name, by_alignment, by_name_alignment, by_alignment_name, 96*fae548d3Szrj by_none, by_init_priority 97*fae548d3Szrj } sort_type; 98*fae548d3Szrj 99*fae548d3Szrj extern sort_type sort_section; 100*fae548d3Szrj 101*fae548d3Szrj struct wildcard_spec 102*fae548d3Szrj { 103*fae548d3Szrj const char *name; 104*fae548d3Szrj struct name_list *exclude_name_list; 105*fae548d3Szrj sort_type sorted; 106*fae548d3Szrj struct flag_info *section_flag_list; 107*fae548d3Szrj }; 108*fae548d3Szrj 109*fae548d3Szrj struct wildcard_list 110*fae548d3Szrj { 111*fae548d3Szrj struct wildcard_list *next; 112*fae548d3Szrj struct wildcard_spec spec; 113*fae548d3Szrj }; 114*fae548d3Szrj 115*fae548d3Szrj #define BYTE_SIZE (1) 116*fae548d3Szrj #define SHORT_SIZE (2) 117*fae548d3Szrj #define LONG_SIZE (4) 118*fae548d3Szrj #define QUAD_SIZE (8) 119*fae548d3Szrj 120*fae548d3Szrj enum endian_enum { ENDIAN_UNSET = 0, ENDIAN_BIG, ENDIAN_LITTLE }; 121*fae548d3Szrj 122*fae548d3Szrj typedef struct 123*fae548d3Szrj { 124*fae548d3Szrj /* 1 => assign space to common symbols even if `relocatable_output'. */ 125*fae548d3Szrj bfd_boolean force_common_definition; 126*fae548d3Szrj 127*fae548d3Szrj /* If TRUE, build MIPS embedded PIC relocation tables in the output 128*fae548d3Szrj file. */ 129*fae548d3Szrj bfd_boolean embedded_relocs; 130*fae548d3Szrj 131*fae548d3Szrj /* If TRUE, force generation of a file with a .exe file. */ 132*fae548d3Szrj bfd_boolean force_exe_suffix; 133*fae548d3Szrj 134*fae548d3Szrj /* If TRUE, generate a cross reference report. */ 135*fae548d3Szrj bfd_boolean cref; 136*fae548d3Szrj 137*fae548d3Szrj /* If TRUE (which is the default), warn about mismatched input 138*fae548d3Szrj files. */ 139*fae548d3Szrj bfd_boolean warn_mismatch; 140*fae548d3Szrj 141*fae548d3Szrj /* Warn on attempting to open an incompatible library during a library 142*fae548d3Szrj search. */ 143*fae548d3Szrj bfd_boolean warn_search_mismatch; 144*fae548d3Szrj 145*fae548d3Szrj /* If non-zero check section addresses, once computed, 146*fae548d3Szrj for overlaps. Relocatable links only check when this is > 0. */ 147*fae548d3Szrj signed char check_section_addresses; 148*fae548d3Szrj 149*fae548d3Szrj /* If TRUE allow the linking of input files in an unknown architecture 150*fae548d3Szrj assuming that the user knows what they are doing. This was the old 151*fae548d3Szrj behaviour of the linker. The new default behaviour is to reject such 152*fae548d3Szrj input files. */ 153*fae548d3Szrj bfd_boolean accept_unknown_input_arch; 154*fae548d3Szrj 155*fae548d3Szrj /* Name of the import library to generate. */ 156*fae548d3Szrj char *out_implib_filename; 157*fae548d3Szrj 158*fae548d3Szrj /* If TRUE we'll just print the default output on stdout. */ 159*fae548d3Szrj bfd_boolean print_output_format; 160*fae548d3Szrj 161*fae548d3Szrj /* If set, display the target memory usage (per memory region). */ 162*fae548d3Szrj bfd_boolean print_memory_usage; 163*fae548d3Szrj 164*fae548d3Szrj /* Should we force section groups to be resolved? Controlled with 165*fae548d3Szrj --force-group-allocation on the command line or FORCE_GROUP_ALLOCATION 166*fae548d3Szrj in the linker script. */ 167*fae548d3Szrj bfd_boolean force_group_allocation; 168*fae548d3Szrj 169*fae548d3Szrj /* Big or little endian as set on command line. */ 170*fae548d3Szrj enum endian_enum endian; 171*fae548d3Szrj 172*fae548d3Szrj /* Name of runtime interpreter to invoke. */ 173*fae548d3Szrj char *interpreter; 174*fae548d3Szrj 175*fae548d3Szrj /* Name to give runtime library from the -soname argument. */ 176*fae548d3Szrj char *soname; 177*fae548d3Szrj 178*fae548d3Szrj /* Runtime library search path from the -rpath argument. */ 179*fae548d3Szrj char *rpath; 180*fae548d3Szrj 181*fae548d3Szrj /* Link time runtime library search path from the -rpath-link 182*fae548d3Szrj argument. */ 183*fae548d3Szrj char *rpath_link; 184*fae548d3Szrj 185*fae548d3Szrj /* Name of shared object whose symbol table should be filtered with 186*fae548d3Szrj this shared object. From the --filter option. */ 187*fae548d3Szrj char *filter_shlib; 188*fae548d3Szrj 189*fae548d3Szrj /* Name of shared object for whose symbol table this shared object 190*fae548d3Szrj is an auxiliary filter. From the --auxiliary option. */ 191*fae548d3Szrj char **auxiliary_filters; 192*fae548d3Szrj 193*fae548d3Szrj /* A version symbol to be applied to the symbol names found in the 194*fae548d3Szrj .exports sections. */ 195*fae548d3Szrj char *version_exports_section; 196*fae548d3Szrj 197*fae548d3Szrj /* Default linker script. */ 198*fae548d3Szrj char *default_script; 199*fae548d3Szrj } args_type; 200*fae548d3Szrj 201*fae548d3Szrj extern args_type command_line; 202*fae548d3Szrj 203*fae548d3Szrj typedef int token_code_type; 204*fae548d3Szrj 205*fae548d3Szrj /* Different ways we can handle orphan sections. */ 206*fae548d3Szrj 207*fae548d3Szrj enum orphan_handling_enum 208*fae548d3Szrj { 209*fae548d3Szrj /* The classic strategy, find a suitable section to place the orphan 210*fae548d3Szrj into. */ 211*fae548d3Szrj orphan_handling_place = 0, 212*fae548d3Szrj 213*fae548d3Szrj /* Discard any orphan sections as though they were assign to the section 214*fae548d3Szrj /DISCARD/. */ 215*fae548d3Szrj orphan_handling_discard, 216*fae548d3Szrj 217*fae548d3Szrj /* Find somewhere to place the orphan section, as with 218*fae548d3Szrj ORPHAN_HANDLING_PLACE, but also issue a warning. */ 219*fae548d3Szrj orphan_handling_warn, 220*fae548d3Szrj 221*fae548d3Szrj /* Issue a fatal error if any orphan sections are found. */ 222*fae548d3Szrj orphan_handling_error, 223*fae548d3Szrj }; 224*fae548d3Szrj 225*fae548d3Szrj typedef struct 226*fae548d3Szrj { 227*fae548d3Szrj bfd_boolean magic_demand_paged; 228*fae548d3Szrj bfd_boolean make_executable; 229*fae548d3Szrj 230*fae548d3Szrj /* If TRUE, -shared is supported. */ 231*fae548d3Szrj /* ??? A better way to do this is perhaps to define this in the 232*fae548d3Szrj ld_emulation_xfer_struct since this is really a target dependent 233*fae548d3Szrj parameter. */ 234*fae548d3Szrj bfd_boolean has_shared; 235*fae548d3Szrj 236*fae548d3Szrj /* If TRUE, build constructors. */ 237*fae548d3Szrj bfd_boolean build_constructors; 238*fae548d3Szrj 239*fae548d3Szrj /* If TRUE, warn about any constructors. */ 240*fae548d3Szrj bfd_boolean warn_constructors; 241*fae548d3Szrj 242*fae548d3Szrj /* If TRUE, warn about merging common symbols with others. */ 243*fae548d3Szrj bfd_boolean warn_common; 244*fae548d3Szrj 245*fae548d3Szrj /* If TRUE, only warn once about a particular undefined symbol. */ 246*fae548d3Szrj bfd_boolean warn_once; 247*fae548d3Szrj 248*fae548d3Szrj /* How should we deal with orphan sections. */ 249*fae548d3Szrj enum orphan_handling_enum orphan_handling; 250*fae548d3Szrj 251*fae548d3Szrj /* If TRUE, warn if multiple global-pointers are needed (Alpha 252*fae548d3Szrj only). */ 253*fae548d3Szrj bfd_boolean warn_multiple_gp; 254*fae548d3Szrj 255*fae548d3Szrj /* If TRUE, warn if the starting address of an output section 256*fae548d3Szrj changes due to the alignment of an input section. */ 257*fae548d3Szrj bfd_boolean warn_section_align; 258*fae548d3Szrj 259*fae548d3Szrj /* If TRUE, warning messages are fatal */ 260*fae548d3Szrj bfd_boolean fatal_warnings; 261*fae548d3Szrj 262*fae548d3Szrj sort_order sort_common; 263*fae548d3Szrj 264*fae548d3Szrj bfd_boolean text_read_only; 265*fae548d3Szrj 266*fae548d3Szrj bfd_boolean stats; 267*fae548d3Szrj 268*fae548d3Szrj /* If set, orphan input sections will be mapped to separate output 269*fae548d3Szrj sections. */ 270*fae548d3Szrj bfd_boolean unique_orphan_sections; 271*fae548d3Szrj 272*fae548d3Szrj /* If set, only search library directories explicitly selected 273*fae548d3Szrj on the command line. */ 274*fae548d3Szrj bfd_boolean only_cmd_line_lib_dirs; 275*fae548d3Szrj 276*fae548d3Szrj /* If set, numbers and absolute symbols are simply treated as 277*fae548d3Szrj numbers everywhere. */ 278*fae548d3Szrj bfd_boolean sane_expr; 279*fae548d3Szrj 280*fae548d3Szrj /* If set, code and non-code sections should never be in one segment. */ 281*fae548d3Szrj bfd_boolean separate_code; 282*fae548d3Szrj 283*fae548d3Szrj /* The rpath separation character. Usually ':'. */ 284*fae548d3Szrj char rpath_separator; 285*fae548d3Szrj 286*fae548d3Szrj char *map_filename; 287*fae548d3Szrj FILE *map_file; 288*fae548d3Szrj 289*fae548d3Szrj unsigned int split_by_reloc; 290*fae548d3Szrj bfd_size_type split_by_file; 291*fae548d3Szrj 292*fae548d3Szrj /* The size of the hash table to use. */ 293*fae548d3Szrj unsigned long hash_table_size; 294*fae548d3Szrj 295*fae548d3Szrj /* The maximum page size for ELF. */ 296*fae548d3Szrj bfd_vma maxpagesize; 297*fae548d3Szrj 298*fae548d3Szrj /* The common page size for ELF. */ 299*fae548d3Szrj bfd_vma commonpagesize; 300*fae548d3Szrj 301*fae548d3Szrj /* If set, print discarded sections in map file output. */ 302*fae548d3Szrj bfd_boolean print_map_discarded; 303*fae548d3Szrj } ld_config_type; 304*fae548d3Szrj 305*fae548d3Szrj extern ld_config_type config; 306*fae548d3Szrj 307*fae548d3Szrj extern FILE * saved_script_handle; 308*fae548d3Szrj extern bfd_boolean force_make_executable; 309*fae548d3Szrj 310*fae548d3Szrj extern int yyparse (void); 311*fae548d3Szrj extern void add_cref (const char *, bfd *, asection *, bfd_vma); 312*fae548d3Szrj extern bfd_boolean handle_asneeded_cref (bfd *, enum notice_asneeded_action); 313*fae548d3Szrj extern void output_cref (FILE *); 314*fae548d3Szrj extern void check_nocrossrefs (void); 315*fae548d3Szrj extern void ld_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; 316*fae548d3Szrj 317*fae548d3Szrj /* If gcc >= 2.6, we can give a function name, too. */ 318*fae548d3Szrj #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) 319*fae548d3Szrj #define __PRETTY_FUNCTION__ NULL 320*fae548d3Szrj #endif 321*fae548d3Szrj 322*fae548d3Szrj #undef abort 323*fae548d3Szrj #define abort() ld_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__) 324*fae548d3Szrj 325*fae548d3Szrj #endif 326