133965Sjdp/* ld.h -- general linker header file 2218822Sdim Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 3218822Sdim 2001, 2002, 2003, 2004, 2005, 2006, 2007 460484Sobrien Free Software Foundation, Inc. 533965Sjdp 633965Sjdp This file is part of GLD, the Gnu Linker. 733965Sjdp 833965Sjdp GLD is free software; you can redistribute it and/or modify 933965Sjdp it under the terms of the GNU General Public License as published by 1033965Sjdp the Free Software Foundation; either version 2, or (at your option) 1133965Sjdp any later version. 1233965Sjdp 1333965Sjdp GLD is distributed in the hope that it will be useful, 1433965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1533965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1633965Sjdp GNU General Public License for more details. 1733965Sjdp 1833965Sjdp You should have received a copy of the GNU General Public License 1933965Sjdp along with GLD; see the file COPYING. If not, write to the Free 20218822Sdim Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 21218822Sdim 02110-1301, USA. */ 2233965Sjdp 2333965Sjdp#ifndef LD_H 2433965Sjdp#define LD_H 2533965Sjdp 2660484Sobrien#ifdef HAVE_LOCALE_H 27218822Sdim#endif 28218822Sdim#ifndef SEEK_CUR 29218822Sdim#define SEEK_CUR 1 30218822Sdim#endif 31218822Sdim#ifndef SEEK_END 32218822Sdim#define SEEK_END 2 33218822Sdim#endif 34218822Sdim 35218822Sdim#if defined(__GNUC__) && !defined(C_ALLOCA) 36218822Sdim# undef alloca 37218822Sdim# define alloca __builtin_alloca 38218822Sdim#else 39218822Sdim# if defined(HAVE_ALLOCA_H) && !defined(C_ALLOCA) 40218822Sdim# include <alloca.h> 41218822Sdim# else 42218822Sdim# ifndef alloca /* predefined by HP cc +Olibcalls */ 43218822Sdim# if !defined (__STDC__) && !defined (__hpux) 44218822Sdimchar *alloca (); 45218822Sdim# else 46218822Sdimvoid *alloca (); 47218822Sdim# endif /* __STDC__, __hpux */ 48218822Sdim# endif /* alloca */ 49218822Sdim# endif /* HAVE_ALLOCA_H */ 50218822Sdim#endif 51218822Sdim 52218822Sdim 53218822Sdim#ifdef HAVE_LOCALE_H 54218822Sdim# ifndef ENABLE_NLS 55218822Sdim /* The Solaris version of locale.h always includes libintl.h. If we have 56218822Sdim been configured with --disable-nls then ENABLE_NLS will not be defined 57218822Sdim and the dummy definitions of bindtextdomain (et al) below will conflict 58218822Sdim with the defintions in libintl.h. So we define these values to prevent 59218822Sdim the bogus inclusion of libintl.h. */ 60218822Sdim# define _LIBINTL_H 61218822Sdim# define _LIBGETTEXT_H 62218822Sdim# endif 6360484Sobrien# include <locale.h> 6460484Sobrien#endif 6560484Sobrien 6660484Sobrien#ifdef ENABLE_NLS 6760484Sobrien# include <libintl.h> 6860484Sobrien# define _(String) gettext (String) 6960484Sobrien# ifdef gettext_noop 7060484Sobrien# define N_(String) gettext_noop (String) 7160484Sobrien# else 7260484Sobrien# define N_(String) (String) 7360484Sobrien# endif 7460484Sobrien#else 7577298Sobrien# define gettext(Msgid) (Msgid) 7677298Sobrien# define dgettext(Domainname, Msgid) (Msgid) 7777298Sobrien# define dcgettext(Domainname, Msgid, Category) (Msgid) 7877298Sobrien# define textdomain(Domainname) while (0) /* nothing */ 7977298Sobrien# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ 8060484Sobrien# define _(String) (String) 8160484Sobrien# define N_(String) (String) 8260484Sobrien#endif 8360484Sobrien 8433965Sjdp/* Look in this environment name for the linker to pretend to be */ 8533965Sjdp#define EMULATION_ENVIRON "LDEMULATION" 8633965Sjdp/* If in there look for the strings: */ 8733965Sjdp 8833965Sjdp/* Look in this variable for a target format */ 8933965Sjdp#define TARGET_ENVIRON "GNUTARGET" 9033965Sjdp 9133965Sjdp/* Input sections which are put in a section of this name are actually 9233965Sjdp discarded. */ 9333965Sjdp#define DISCARD_SECTION_NAME "/DISCARD/" 9433965Sjdp 9560484Sobrien/* A file name list */ 9677298Sobrientypedef struct name_list { 9777298Sobrien const char *name; 9877298Sobrien struct name_list *next; 9977298Sobrien} 10077298Sobrienname_list; 10160484Sobrien 102218822Sdim/* A wildcard specification. */ 10360484Sobrien 104218822Sdimtypedef enum { 105218822Sdim none, by_name, by_alignment, by_name_alignment, by_alignment_name 106218822Sdim} sort_type; 107218822Sdim 108218822Sdimextern sort_type sort_section; 109218822Sdim 11077298Sobrienstruct wildcard_spec { 11160484Sobrien const char *name; 11260484Sobrien struct name_list *exclude_name_list; 113218822Sdim sort_type sorted; 11460484Sobrien}; 11560484Sobrien 11689857Sobrienstruct wildcard_list { 11789857Sobrien struct wildcard_list *next; 11889857Sobrien struct wildcard_spec spec; 11989857Sobrien}; 12089857Sobrien 121218822Sdimstruct map_symbol_def { 122218822Sdim struct bfd_link_hash_entry *entry; 123218822Sdim struct map_symbol_def *next; 124218822Sdim}; 12533965Sjdp 126218822Sdim/* The initial part of fat_user_section_struct has to be idential with 127218822Sdim lean_user_section_struct. */ 128218822Sdimtypedef struct fat_user_section_struct { 129218822Sdim /* For input sections, when writing a map file: head / tail of a linked 130218822Sdim list of hash table entries for symbols defined in this section. */ 131218822Sdim struct map_symbol_def *map_symbol_def_head; 132218822Sdim struct map_symbol_def **map_symbol_def_tail; 133218822Sdim} fat_section_userdata_type; 134218822Sdim 13533965Sjdp#define get_userdata(x) ((x)->userdata) 13633965Sjdp 13733965Sjdp#define BYTE_SIZE (1) 13833965Sjdp#define SHORT_SIZE (2) 13933965Sjdp#define LONG_SIZE (4) 14033965Sjdp#define QUAD_SIZE (8) 14133965Sjdp 14277298Sobrientypedef struct { 14333965Sjdp /* 1 => assign space to common symbols even if `relocatable_output'. */ 144130561Sobrien bfd_boolean force_common_definition; 14589857Sobrien 146104834Sobrien /* 1 => do not assign addresses to common symbols. */ 147130561Sobrien bfd_boolean inhibit_common_definition; 148130561Sobrien bfd_boolean relax; 14933965Sjdp 150130561Sobrien /* If TRUE, build MIPS embedded PIC relocation tables in the output 15133965Sjdp file. */ 152130561Sobrien bfd_boolean embedded_relocs; 15333965Sjdp 154130561Sobrien /* If TRUE, force generation of a file with a .exe file. */ 155130561Sobrien bfd_boolean force_exe_suffix; 15633965Sjdp 157130561Sobrien /* If TRUE, generate a cross reference report. */ 158130561Sobrien bfd_boolean cref; 15933965Sjdp 160130561Sobrien /* If TRUE (which is the default), warn about mismatched input 16138889Sjdp files. */ 162130561Sobrien bfd_boolean warn_mismatch; 16338889Sjdp 164218822Sdim /* Warn on attempting to open an incompatible library during a library 165218822Sdim search. */ 166218822Sdim bfd_boolean warn_search_mismatch; 16760484Sobrien 168218822Sdim 169218822Sdim /* If TRUE (the default) check section addresses, once compute, 170218822Sdim fpor overlaps. */ 171218822Sdim bfd_boolean check_section_addresses; 172218822Sdim 173218822Sdim /* If TRUE allow the linking of input files in an unknown architecture 174218822Sdim assuming that the user knows what they are doing. This was the old 175218822Sdim behaviour of the linker. The new default behaviour is to reject such 176218822Sdim input files. */ 177218822Sdim bfd_boolean accept_unknown_input_arch; 178218822Sdim 179218822Sdim /* Big or little endian as set on command line. */ 180218822Sdim enum { ENDIAN_UNSET = 0, ENDIAN_BIG, ENDIAN_LITTLE } endian; 181218822Sdim 182218822Sdim /* -Bsymbolic and -Bsymbolic-functions, as set on command line. */ 183218822Sdim enum 184218822Sdim { 185218822Sdim symbolic_unset = 0, 186218822Sdim symbolic, 187218822Sdim symbolic_functions, 188218822Sdim } symbolic; 189218822Sdim 190218822Sdim /* --dynamic-list, --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo 191218822Sdim and --dynamic-list FILE, as set on command line. */ 192218822Sdim enum 193218822Sdim { 194218822Sdim dynamic_list_unset = 0, 195218822Sdim dynamic_list_data, 196218822Sdim dynamic_list 197218822Sdim } dynamic_list; 198218822Sdim 199218822Sdim /* Name of runtime interpreter to invoke. */ 200218822Sdim char *interpreter; 201218822Sdim 202218822Sdim /* Name to give runtime libary from the -soname argument. */ 203218822Sdim char *soname; 204218822Sdim 205218822Sdim /* Runtime library search path from the -rpath argument. */ 206218822Sdim char *rpath; 207218822Sdim 208218822Sdim /* Link time runtime library search path from the -rpath-link 209218822Sdim argument. */ 210218822Sdim char *rpath_link; 211218822Sdim 21233965Sjdp /* Name of shared object whose symbol table should be filtered with 21333965Sjdp this shared object. From the --filter option. */ 21433965Sjdp char *filter_shlib; 21533965Sjdp 21633965Sjdp /* Name of shared object for whose symbol table this shared object 21733965Sjdp is an auxiliary filter. From the --auxiliary option. */ 21833965Sjdp char **auxiliary_filters; 21960484Sobrien 22060484Sobrien /* A version symbol to be applied to the symbol names found in the 22160484Sobrien .exports sections. */ 22260484Sobrien char *version_exports_section; 22360484Sobrien 224218822Sdim /* Default linker script. */ 225218822Sdim char *default_script; 22633965Sjdp} args_type; 22733965Sjdp 22833965Sjdpextern args_type command_line; 22933965Sjdp 23033965Sjdptypedef int token_code_type; 23133965Sjdp 23277298Sobrientypedef struct { 233130561Sobrien bfd_boolean magic_demand_paged; 234130561Sobrien bfd_boolean make_executable; 23533965Sjdp 236130561Sobrien /* If TRUE, doing a dynamic link. */ 237130561Sobrien bfd_boolean dynamic_link; 23833965Sjdp 239130561Sobrien /* If TRUE, -shared is supported. */ 24060484Sobrien /* ??? A better way to do this is perhaps to define this in the 24160484Sobrien ld_emulation_xfer_struct since this is really a target dependent 24260484Sobrien parameter. */ 243130561Sobrien bfd_boolean has_shared; 24460484Sobrien 245130561Sobrien /* If TRUE, build constructors. */ 246130561Sobrien bfd_boolean build_constructors; 24733965Sjdp 248130561Sobrien /* If TRUE, warn about any constructors. */ 249130561Sobrien bfd_boolean warn_constructors; 25033965Sjdp 251130561Sobrien /* If TRUE, warn about merging common symbols with others. */ 252130561Sobrien bfd_boolean warn_common; 25333965Sjdp 254130561Sobrien /* If TRUE, only warn once about a particular undefined symbol. */ 255130561Sobrien bfd_boolean warn_once; 25633965Sjdp 257130561Sobrien /* If TRUE, warn if multiple global-pointers are needed (Alpha 25833965Sjdp only). */ 259130561Sobrien bfd_boolean warn_multiple_gp; 26033965Sjdp 261130561Sobrien /* If TRUE, warn if the starting address of an output section 26233965Sjdp changes due to the alignment of an input section. */ 263130561Sobrien bfd_boolean warn_section_align; 26433965Sjdp 265130561Sobrien /* If TRUE, warning messages are fatal */ 266130561Sobrien bfd_boolean fatal_warnings; 26789857Sobrien 268130561Sobrien bfd_boolean sort_common; 26933965Sjdp 270130561Sobrien bfd_boolean text_read_only; 27133965Sjdp 272130561Sobrien bfd_boolean stats; 27333965Sjdp 27477298Sobrien /* If set, orphan input sections will be mapped to separate output 27577298Sobrien sections. */ 276130561Sobrien bfd_boolean unique_orphan_sections; 27777298Sobrien 278218822Sdim /* If set, only search library directories explicitly selected 279218822Sdim on the command line. */ 280218822Sdim bfd_boolean only_cmd_line_lib_dirs; 281218822Sdim 282218822Sdim /* The rpath separation character. Usually ':'. */ 283218822Sdim char rpath_separator; 284218822Sdim 285218822Sdim char *map_filename; 286218822Sdim FILE *map_file; 287218822Sdim 28877298Sobrien unsigned int split_by_reloc; 28977298Sobrien bfd_size_type split_by_file; 29089857Sobrien 291218822Sdim bfd_size_type specified_data_size; 292218822Sdim 293218822Sdim /* The size of the hash table to use. */ 294218822Sdim bfd_size_type hash_table_size; 295218822Sdim 296218822Sdim /* The maximum page size for ELF. */ 297218822Sdim bfd_vma maxpagesize; 298218822Sdim 299218822Sdim /* The common page size for ELF. */ 300218822Sdim bfd_vma commonpagesize; 30133965Sjdp} ld_config_type; 30233965Sjdp 30333965Sjdpextern ld_config_type config; 30433965Sjdp 30589857Sobrienextern FILE * saved_script_handle; 306130561Sobrienextern bfd_boolean force_make_executable; 30733965Sjdp 30833965Sjdp/* Non-zero if we are processing a --defsym from the command line. */ 30933965Sjdpextern int parsing_defsym; 31033965Sjdp 311130561Sobrienextern int yyparse (void); 312130561Sobrienextern void add_cref (const char *, bfd *, asection *, bfd_vma); 313218822Sdimextern bfd_boolean handle_asneeded_cref (bfd *, enum notice_asneeded_action); 314130561Sobrienextern void output_cref (FILE *); 315130561Sobrienextern void check_nocrossrefs (void); 316130561Sobrienextern void ld_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; 31733965Sjdp 31860484Sobrien/* If gcc >= 2.6, we can give a function name, too. */ 31960484Sobrien#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) 320130561Sobrien#define __PRETTY_FUNCTION__ NULL 32133965Sjdp#endif 32260484Sobrien 32360484Sobrien#undef abort 32460484Sobrien#define abort() ld_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__) 32560484Sobrien 32660484Sobrien#endif 327