19990502 sourceware import
[external/binutils.git] / ld / ldexp.h
1 /* ldexp.h -
2    Copyright 1991, 92, 93, 94, 95, 1998 Free Software Foundation, Inc.
3
4    This file is part of GLD, the Gnu Linker.
5
6    GLD is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    GLD is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with GLD; see the file COPYING.  If not, write to the Free
18    Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19    02111-1307, USA.  */
20
21 #ifndef LDEXP_H
22 #define LDEXP_H
23
24 /* The result of an expression tree */
25 typedef struct 
26 {
27   bfd_vma value;
28   struct lang_output_section_statement_struct *section;
29   boolean valid_p;
30 } etree_value_type;
31
32
33
34 typedef struct 
35 {
36   int node_code;
37   enum { etree_binary,
38            etree_trinary,
39            etree_unary,
40            etree_name,
41            etree_assign,
42            etree_provide,
43            etree_undef,
44            etree_unspec,
45            etree_value,
46            etree_assert,
47            etree_rel } node_class;
48 } node_type;
49
50
51
52 typedef union etree_union 
53 {
54   node_type type;
55   struct {
56     node_type type;
57     union etree_union *lhs;
58     union etree_union *rhs;
59   } binary;
60   struct {
61     node_type type;
62     union etree_union *cond;
63     union etree_union *lhs;
64     union etree_union *rhs;
65   } trinary;
66   struct {
67     node_type type;
68     CONST char *dst;
69     union etree_union *src;
70   } assign;
71
72   struct {
73     node_type type;
74     union   etree_union *child;
75   } unary;
76   struct {
77     node_type type;
78    CONST char *name;
79   } name;
80   struct {
81     node_type type;
82     bfd_vma value;
83   } value;
84   struct {
85     node_type type;
86     asection *section;
87     bfd_vma value;
88   } rel;
89   struct {
90     node_type type;
91     union etree_union *child;
92     const char *message;
93   } assert_s;
94 } etree_type;
95
96
97 etree_type *exp_intop PARAMS ((bfd_vma));
98 etree_type *exp_relop PARAMS ((asection *, bfd_vma));
99 etree_value_type invalid PARAMS ((void));
100 etree_value_type exp_fold_tree PARAMS ((etree_type *, struct
101                                         lang_output_section_statement_struct *,
102                                         lang_phase_type,
103                                         bfd_vma, bfd_vma *));
104 etree_type *exp_binop PARAMS ((int, etree_type *, etree_type *));
105 etree_type *exp_trinop PARAMS ((int,etree_type *, etree_type *, etree_type *));
106 etree_type *exp_unop PARAMS ((int, etree_type *));
107 etree_type *exp_nameop PARAMS ((int, CONST char *));
108 etree_type *exp_assop PARAMS ((int, CONST char *, etree_type *));
109 etree_type *exp_provide PARAMS ((const char *, etree_type *));
110 etree_type *exp_assert PARAMS ((etree_type *, const char *));
111 void exp_print_tree PARAMS ((etree_type *));
112 bfd_vma exp_get_vma PARAMS ((etree_type *, bfd_vma, char *, lang_phase_type));
113 int exp_get_value_int PARAMS ((etree_type *, int, char *,lang_phase_type));
114 bfd_vma exp_get_abs_int PARAMS ((etree_type *, int, char *,lang_phase_type));
115
116 #endif