Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* ldexp.h - |
e5caa5e0 | 2 | Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002, |
408082ec | 3 | 2003, 2004, 2005 Free Software Foundation, Inc. |
252b5132 RH |
4 | |
5 | This file is part of GLD, the Gnu Linker. | |
6 | ||
7 | GLD is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GLD is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GLD; see the file COPYING. If not, write to the Free | |
75be928b NC |
19 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
20 | 02110-1301, USA. */ | |
252b5132 RH |
21 | |
22 | #ifndef LDEXP_H | |
23 | #define LDEXP_H | |
24 | ||
25 | /* The result of an expression tree */ | |
89cdebba | 26 | typedef struct { |
252b5132 | 27 | bfd_vma value; |
2c382fb6 | 28 | char *str; |
408082ec | 29 | asection *section; |
b34976b6 | 30 | bfd_boolean valid_p; |
252b5132 RH |
31 | } etree_value_type; |
32 | ||
89cdebba | 33 | typedef struct { |
252b5132 | 34 | int node_code; |
b34976b6 AM |
35 | enum { |
36 | etree_binary, | |
37 | etree_trinary, | |
38 | etree_unary, | |
39 | etree_name, | |
40 | etree_assign, | |
41 | etree_provide, | |
42 | etree_provided, | |
b34976b6 AM |
43 | etree_value, |
44 | etree_assert, | |
45 | etree_rel | |
46 | } node_class; | |
252b5132 RH |
47 | } node_type; |
48 | ||
89cdebba | 49 | typedef union etree_union { |
252b5132 RH |
50 | node_type type; |
51 | struct { | |
52 | node_type type; | |
53 | union etree_union *lhs; | |
54 | union etree_union *rhs; | |
55 | } binary; | |
56 | struct { | |
57 | node_type type; | |
58 | union etree_union *cond; | |
59 | union etree_union *lhs; | |
60 | union etree_union *rhs; | |
61 | } trinary; | |
62 | struct { | |
63 | node_type type; | |
2c382fb6 | 64 | const char *dst; |
252b5132 RH |
65 | union etree_union *src; |
66 | } assign; | |
252b5132 RH |
67 | struct { |
68 | node_type type; | |
89cdebba | 69 | union etree_union *child; |
252b5132 RH |
70 | } unary; |
71 | struct { | |
72 | node_type type; | |
2c382fb6 | 73 | const char *name; |
252b5132 RH |
74 | } name; |
75 | struct { | |
76 | node_type type; | |
77 | bfd_vma value; | |
2c382fb6 | 78 | char *str; |
252b5132 RH |
79 | } value; |
80 | struct { | |
81 | node_type type; | |
82 | asection *section; | |
83 | bfd_vma value; | |
84 | } rel; | |
85 | struct { | |
86 | node_type type; | |
87 | union etree_union *child; | |
88 | const char *message; | |
89 | } assert_s; | |
90 | } etree_type; | |
2d20f7bf | 91 | |
e9ee469a AM |
92 | typedef enum { |
93 | lang_first_phase_enum, | |
94 | lang_mark_phase_enum, | |
95 | lang_allocating_phase_enum, | |
96 | lang_final_phase_enum | |
97 | } lang_phase_type; | |
98 | ||
99 | struct ldexp_control { | |
100 | /* Modify expression evaluation depending on this. */ | |
101 | lang_phase_type phase; | |
102 | ||
103 | /* Principally used for diagnostics. */ | |
104 | bfd_boolean assigning_to_dot; | |
105 | ||
106 | /* Working results. */ | |
107 | etree_value_type result; | |
108 | bfd_vma dot; | |
109 | ||
110 | /* Current dot and section passed to ldexp folder. */ | |
111 | bfd_vma *dotp; | |
112 | asection *section; | |
113 | ||
114 | /* State machine and results for DATASEG. */ | |
115 | struct { | |
116 | enum { | |
117 | exp_dataseg_none, | |
118 | exp_dataseg_align_seen, | |
119 | exp_dataseg_relro_seen, | |
120 | exp_dataseg_end_seen, | |
121 | exp_dataseg_relro_adjust, | |
122 | exp_dataseg_adjust | |
123 | } phase; | |
124 | ||
125 | bfd_vma base, min_base, relro_end, end, pagesize, maxpagesize; | |
126 | } dataseg; | |
127 | }; | |
128 | ||
129 | extern struct ldexp_control expld; | |
252b5132 | 130 | |
ba916c8a MM |
131 | /* A maps from a segment name to a base address. */ |
132 | typedef struct segment_struct { | |
133 | /* The next segment in the linked list. */ | |
134 | struct segment_struct *next; | |
135 | /* The name of the sgement. */ | |
136 | const char *name; | |
137 | /* The base address for the segment. */ | |
138 | bfd_vma value; | |
139 | /* True if a SEGMENT_START directive corresponding to this segment | |
140 | has been seen. */ | |
141 | bfd_boolean used; | |
142 | } segment_type; | |
143 | ||
144 | /* The segments specified by the user on the command-line. */ | |
145 | extern segment_type *segments; | |
146 | ||
2c382fb6 AM |
147 | typedef struct _fill_type fill_type; |
148 | ||
b34976b6 | 149 | etree_type *exp_intop |
1579bae1 | 150 | (bfd_vma); |
b34976b6 | 151 | etree_type *exp_bigintop |
1579bae1 | 152 | (bfd_vma, char *); |
b34976b6 | 153 | etree_type *exp_relop |
1579bae1 | 154 | (asection *, bfd_vma); |
e9ee469a AM |
155 | void exp_fold_tree |
156 | (etree_type *, asection *, bfd_vma *); | |
b34976b6 | 157 | etree_type *exp_binop |
1579bae1 | 158 | (int, etree_type *, etree_type *); |
b34976b6 | 159 | etree_type *exp_trinop |
1579bae1 | 160 | (int,etree_type *, etree_type *, etree_type *); |
b34976b6 | 161 | etree_type *exp_unop |
1579bae1 | 162 | (int, etree_type *); |
b34976b6 | 163 | etree_type *exp_nameop |
1579bae1 | 164 | (int, const char *); |
b34976b6 | 165 | etree_type *exp_assop |
1579bae1 | 166 | (int, const char *, etree_type *); |
b34976b6 | 167 | etree_type *exp_provide |
1579bae1 | 168 | (const char *, etree_type *); |
b34976b6 | 169 | etree_type *exp_assert |
1579bae1 | 170 | (etree_type *, const char *); |
b34976b6 | 171 | void exp_print_tree |
1579bae1 | 172 | (etree_type *); |
b34976b6 | 173 | bfd_vma exp_get_vma |
e9ee469a | 174 | (etree_type *, bfd_vma, char *); |
b34976b6 | 175 | int exp_get_value_int |
e9ee469a | 176 | (etree_type *, int, char *); |
b34976b6 | 177 | fill_type *exp_get_fill |
e9ee469a | 178 | (etree_type *, fill_type *, char *); |
b34976b6 | 179 | bfd_vma exp_get_abs_int |
e9ee469a | 180 | (etree_type *, int, char *); |
252b5132 RH |
181 | |
182 | #endif |