Back to index

cell-binutils  2.17cvs20070401
ld.h
Go to the documentation of this file.
00001 /* ld.h -- general linker header file
00002    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
00003    2001, 2002, 2003, 2004, 2005, 2006, 2007
00004    Free Software Foundation, Inc.
00005 
00006    This file is part of GLD, the Gnu Linker.
00007 
00008    GLD is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2, or (at your option)
00011    any later version.
00012 
00013    GLD is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with GLD; see the file COPYING.  If not, write to the Free
00020    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00021    02110-1301, USA.  */
00022 
00023 #ifndef LD_H
00024 #define LD_H
00025 
00026 #ifdef HAVE_LOCALE_H
00027 #endif
00028 #ifndef SEEK_CUR
00029 #define SEEK_CUR 1
00030 #endif
00031 #ifndef SEEK_END
00032 #define SEEK_END 2
00033 #endif
00034 
00035 #if defined(__GNUC__) && !defined(C_ALLOCA)
00036 # undef alloca
00037 # define alloca __builtin_alloca
00038 #else
00039 # if defined(HAVE_ALLOCA_H) && !defined(C_ALLOCA)
00040 #  include <alloca.h>
00041 # else
00042 #  ifndef alloca /* predefined by HP cc +Olibcalls */
00043 #   if !defined (__STDC__) && !defined (__hpux)
00044 char *alloca ();
00045 #   else
00046 void *alloca ();
00047 #   endif /* __STDC__, __hpux */
00048 #  endif /* alloca */
00049 # endif /* HAVE_ALLOCA_H */
00050 #endif
00051 
00052 
00053 #ifdef HAVE_LOCALE_H
00054 # ifndef ENABLE_NLS
00055    /* The Solaris version of locale.h always includes libintl.h.  If we have
00056       been configured with --disable-nls then ENABLE_NLS will not be defined
00057       and the dummy definitions of bindtextdomain (et al) below will conflict
00058       with the defintions in libintl.h.  So we define these values to prevent
00059       the bogus inclusion of libintl.h.  */
00060 #  define _LIBINTL_H
00061 #  define _LIBGETTEXT_H
00062 # endif
00063 # include <locale.h>
00064 #endif
00065 
00066 #ifdef ENABLE_NLS
00067 # include <libintl.h>
00068 # define _(String) gettext (String)
00069 # ifdef gettext_noop
00070 #  define N_(String) gettext_noop (String)
00071 # else
00072 #  define N_(String) (String)
00073 # endif
00074 #else
00075 # define gettext(Msgid) (Msgid)
00076 # define dgettext(Domainname, Msgid) (Msgid)
00077 # define dcgettext(Domainname, Msgid, Category) (Msgid)
00078 # define textdomain(Domainname) while (0) /* nothing */
00079 # define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
00080 # define _(String) (String)
00081 # define N_(String) (String)
00082 #endif
00083 
00084 /* Look in this environment name for the linker to pretend to be */
00085 #define EMULATION_ENVIRON "LDEMULATION"
00086 /* If in there look for the strings: */
00087 
00088 /* Look in this variable for a target format */
00089 #define TARGET_ENVIRON "GNUTARGET"
00090 
00091 /* Input sections which are put in a section of this name are actually
00092    discarded.  */
00093 #define DISCARD_SECTION_NAME "/DISCARD/"
00094 
00095 /* A file name list */
00096 typedef struct name_list {
00097   const char *name;
00098   struct name_list *next;
00099 }
00100 name_list;
00101 
00102 /* A wildcard specification.  */
00103 
00104 typedef enum {
00105   none, by_name, by_alignment, by_name_alignment, by_alignment_name
00106 } sort_type;
00107 
00108 extern sort_type sort_section;
00109 
00110 struct wildcard_spec {
00111   const char *name;
00112   struct name_list *exclude_name_list;
00113   sort_type sorted;
00114 };
00115 
00116 struct wildcard_list {
00117   struct wildcard_list *next;
00118   struct wildcard_spec spec;
00119 };
00120 
00121 struct map_symbol_def {
00122   struct bfd_link_hash_entry *entry;
00123   struct map_symbol_def *next;
00124 };
00125 
00126 /* The initial part of fat_user_section_struct has to be idential with
00127    lean_user_section_struct.  */
00128 typedef struct fat_user_section_struct {
00129   /* For input sections, when writing a map file: head / tail of a linked
00130      list of hash table entries for symbols defined in this section.  */
00131   struct map_symbol_def *map_symbol_def_head;
00132   struct map_symbol_def **map_symbol_def_tail;
00133 } fat_section_userdata_type;
00134 
00135 #define get_userdata(x) ((x)->userdata)
00136 
00137 #define BYTE_SIZE    (1)
00138 #define SHORT_SIZE   (2)
00139 #define LONG_SIZE    (4)
00140 #define QUAD_SIZE    (8)
00141 
00142 typedef struct {
00143   /* 1 => assign space to common symbols even if `relocatable_output'.  */
00144   bfd_boolean force_common_definition;
00145 
00146   /* 1 => do not assign addresses to common symbols.  */
00147   bfd_boolean inhibit_common_definition;
00148   bfd_boolean relax;
00149 
00150   /* Name of runtime interpreter to invoke.  */
00151   char *interpreter;
00152 
00153   /* Name to give runtime libary from the -soname argument.  */
00154   char *soname;
00155 
00156   /* Runtime library search path from the -rpath argument.  */
00157   char *rpath;
00158 
00159   /* Link time runtime library search path from the -rpath-link
00160      argument.  */
00161   char *rpath_link;
00162 
00163   /* Big or little endian as set on command line.  */
00164   enum { ENDIAN_UNSET = 0, ENDIAN_BIG, ENDIAN_LITTLE } endian;
00165 
00166   /* If TRUE, build MIPS embedded PIC relocation tables in the output
00167      file.  */
00168   bfd_boolean embedded_relocs;
00169 
00170   /* If TRUE, force generation of a file with a .exe file.  */
00171   bfd_boolean force_exe_suffix;
00172 
00173   /* If TRUE, generate a cross reference report.  */
00174   bfd_boolean cref;
00175 
00176   /* If TRUE (which is the default), warn about mismatched input
00177      files.  */
00178   bfd_boolean warn_mismatch;
00179 
00180   /* Name of shared object whose symbol table should be filtered with
00181      this shared object.  From the --filter option.  */
00182   char *filter_shlib;
00183 
00184   /* Name of shared object for whose symbol table this shared object
00185      is an auxiliary filter.  From the --auxiliary option.  */
00186   char **auxiliary_filters;
00187 
00188   /* A version symbol to be applied to the symbol names found in the
00189      .exports sections.  */
00190   char *version_exports_section;
00191 
00192   /* Default linker script.  */
00193   char *default_script;
00194 
00195   /* If TRUE (the default) check section addresses, once compute,
00196      fpor overlaps.  */
00197   bfd_boolean check_section_addresses;
00198 
00199   /* If TRUE allow the linking of input files in an unknown architecture
00200      assuming that the user knows what they are doing.  This was the old
00201      behaviour of the linker.  The new default behaviour is to reject such
00202      input files.  */
00203   bfd_boolean accept_unknown_input_arch;
00204 
00205   /* -Bsymbolic and -Bsymbolic-functions, as set on command line.  */
00206   enum
00207     {
00208       symbolic_unset = 0,
00209       symbolic,
00210       symbolic_functions,
00211     } symbolic;
00212 
00213   /* --dynamic-list, --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo
00214      and --dynamic-list FILE, as set on command line.  */
00215   enum
00216     {
00217       dynamic_list_unset = 0,
00218       dynamic_list_data,
00219       dynamic_list
00220     } dynamic_list;
00221 } args_type;
00222 
00223 extern args_type command_line;
00224 
00225 typedef int token_code_type;
00226 
00227 typedef struct {
00228   bfd_size_type specified_data_size;
00229   bfd_boolean magic_demand_paged;
00230   bfd_boolean make_executable;
00231 
00232   /* If TRUE, doing a dynamic link.  */
00233   bfd_boolean dynamic_link;
00234 
00235   /* If TRUE, -shared is supported.  */
00236   /* ??? A better way to do this is perhaps to define this in the
00237      ld_emulation_xfer_struct since this is really a target dependent
00238      parameter.  */
00239   bfd_boolean has_shared;
00240 
00241   /* If TRUE, build constructors.  */
00242   bfd_boolean build_constructors;
00243 
00244   /* If TRUE, warn about any constructors.  */
00245   bfd_boolean warn_constructors;
00246 
00247   /* If TRUE, warn about merging common symbols with others.  */
00248   bfd_boolean warn_common;
00249 
00250   /* If TRUE, only warn once about a particular undefined symbol.  */
00251   bfd_boolean warn_once;
00252 
00253   /* If TRUE, warn if multiple global-pointers are needed (Alpha
00254      only).  */
00255   bfd_boolean warn_multiple_gp;
00256 
00257   /* If TRUE, warn if the starting address of an output section
00258      changes due to the alignment of an input section.  */
00259   bfd_boolean warn_section_align;
00260 
00261   /* If TRUE, warning messages are fatal */
00262   bfd_boolean fatal_warnings;
00263 
00264   bfd_boolean sort_common;
00265 
00266   bfd_boolean text_read_only;
00267 
00268   char *map_filename;
00269   FILE *map_file;
00270 
00271   bfd_boolean stats;
00272 
00273   /* If set, orphan input sections will be mapped to separate output
00274      sections.  */
00275   bfd_boolean unique_orphan_sections;
00276 
00277   unsigned int split_by_reloc;
00278   bfd_size_type split_by_file;
00279 
00280   /* The rpath separation character.  Usually ':'.  */
00281   char rpath_separator;
00282 
00283   /* If set, only search library directories explicitly selected
00284      on the command line.  */
00285   bfd_boolean only_cmd_line_lib_dirs;
00286 
00287   /* The size of the hash table to use.  */
00288   bfd_size_type hash_table_size;
00289 
00290   /* The maximum page size for ELF.  */
00291   bfd_vma maxpagesize;
00292 
00293   /* The common page size for ELF.  */
00294   bfd_vma commonpagesize;
00295 } ld_config_type;
00296 
00297 extern ld_config_type config;
00298 
00299 extern FILE * saved_script_handle;
00300 extern bfd_boolean force_make_executable;
00301 
00302 /* Non-zero if we are processing a --defsym from the command line.  */
00303 extern int parsing_defsym;
00304 
00305 extern int yyparse (void);
00306 extern void add_cref (const char *, bfd *, asection *, bfd_vma);
00307 extern bfd_boolean handle_asneeded_cref (bfd *, enum notice_asneeded_action);
00308 extern void output_cref (FILE *);
00309 extern void check_nocrossrefs (void);
00310 extern void ld_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
00311 
00312 /* If gcc >= 2.6, we can give a function name, too.  */
00313 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
00314 #define __PRETTY_FUNCTION__  NULL
00315 #endif
00316 
00317 #undef abort
00318 #define abort() ld_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
00319 
00320 #endif