Back to index

cell-binutils  2.17cvs20070401
ldexp.h
Go to the documentation of this file.
00001 /* ldexp.h -
00002    Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002,
00003    2003, 2004, 2005 Free Software Foundation, Inc.
00004 
00005    This file is part of GLD, the Gnu Linker.
00006 
00007    GLD is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    GLD is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with GLD; see the file COPYING.  If not, write to the Free
00019    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00020    02110-1301, USA.  */
00021 
00022 #ifndef LDEXP_H
00023 #define LDEXP_H
00024 
00025 /* The result of an expression tree */
00026 typedef struct {
00027   bfd_vma value;
00028   char *str;
00029   asection *section;
00030   bfd_boolean valid_p;
00031 } etree_value_type;
00032 
00033 typedef struct {
00034   int node_code;
00035   enum {
00036     etree_binary,
00037     etree_trinary,
00038     etree_unary,
00039     etree_name,
00040     etree_assign,
00041     etree_provide,
00042     etree_provided,
00043     etree_value,
00044     etree_assert,
00045     etree_rel
00046   } node_class;
00047 } node_type;
00048 
00049 typedef union etree_union {
00050   node_type type;
00051   struct {
00052     node_type type;
00053     union etree_union *lhs;
00054     union etree_union *rhs;
00055   } binary;
00056   struct {
00057     node_type type;
00058     union etree_union *cond;
00059     union etree_union *lhs;
00060     union etree_union *rhs;
00061   } trinary;
00062   struct {
00063     node_type type;
00064     const char *dst;
00065     union etree_union *src;
00066     bfd_boolean hidden;
00067   } assign;
00068   struct {
00069     node_type type;
00070     union etree_union *child;
00071   } unary;
00072   struct {
00073     node_type type;
00074     const char *name;
00075   } name;
00076   struct {
00077     node_type type;
00078     bfd_vma value;
00079     char *str;
00080   } value;
00081   struct {
00082     node_type type;
00083     asection *section;
00084     bfd_vma value;
00085   } rel;
00086   struct {
00087     node_type type;
00088     union etree_union *child;
00089     const char *message;
00090   } assert_s;
00091 } etree_type;
00092 
00093 typedef enum {
00094   lang_first_phase_enum,
00095   lang_mark_phase_enum,
00096   lang_allocating_phase_enum,
00097   lang_final_phase_enum
00098 } lang_phase_type;
00099 
00100 struct ldexp_control {
00101   /* Modify expression evaluation depending on this.  */
00102   lang_phase_type phase;
00103 
00104   /* Principally used for diagnostics.  */
00105   bfd_boolean assigning_to_dot;
00106 
00107   /* Working results.  */
00108   etree_value_type result;
00109   bfd_vma dot;
00110 
00111   /* Current dot and section passed to ldexp folder.  */
00112   bfd_vma *dotp;
00113   asection *section;
00114 
00115   /* State machine and results for DATASEG.  */
00116   struct {
00117     enum {
00118       exp_dataseg_none,
00119       exp_dataseg_align_seen,
00120       exp_dataseg_relro_seen,
00121       exp_dataseg_end_seen,
00122       exp_dataseg_relro_adjust,
00123       exp_dataseg_adjust
00124     } phase;
00125 
00126     bfd_vma base, min_base, relro_end, end, pagesize, maxpagesize;
00127   } dataseg;
00128 };
00129 
00130 extern struct ldexp_control expld;
00131 
00132 /* A maps from a segment name to a base address.  */
00133 typedef struct segment_struct {
00134   /* The next segment in the linked list.  */
00135   struct segment_struct *next;
00136   /* The name of the sgement.  */
00137   const char *name;
00138   /* The base address for the segment.  */
00139   bfd_vma value;
00140   /* True if a SEGMENT_START directive corresponding to this segment
00141      has been seen.  */
00142   bfd_boolean used;
00143 } segment_type;
00144 
00145 /* The segments specified by the user on the command-line.  */
00146 extern segment_type *segments;
00147 
00148 typedef struct _fill_type fill_type;
00149 
00150 etree_type *exp_intop
00151   (bfd_vma);
00152 etree_type *exp_bigintop
00153   (bfd_vma, char *);
00154 etree_type *exp_relop
00155   (asection *, bfd_vma);
00156 void exp_fold_tree
00157   (etree_type *, asection *, bfd_vma *);
00158 etree_type *exp_binop
00159   (int, etree_type *, etree_type *);
00160 etree_type *exp_trinop
00161   (int,etree_type *, etree_type *, etree_type *);
00162 etree_type *exp_unop
00163   (int, etree_type *);
00164 etree_type *exp_nameop
00165   (int, const char *);
00166 etree_type *exp_assop
00167   (int, const char *, etree_type *);
00168 etree_type *exp_provide
00169   (const char *, etree_type *, bfd_boolean);
00170 etree_type *exp_assert
00171   (etree_type *, const char *);
00172 void exp_print_tree
00173   (etree_type *);
00174 bfd_vma exp_get_vma
00175   (etree_type *, bfd_vma, char *);
00176 int exp_get_value_int
00177   (etree_type *, int, char *);
00178 fill_type *exp_get_fill
00179   (etree_type *, fill_type *, char *);
00180 bfd_vma exp_get_abs_int
00181   (etree_type *, int, char *);
00182 
00183 #endif