* gdb.threads/current-lwp-dead.exp: Only run this on Linux.
[deliverable/binutils-gdb.git] / ld / ldexp.h
CommitLineData
252b5132 1/* ldexp.h -
e5caa5e0 2 Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002,
f96b4a7b 3 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
252b5132 4
f96b4a7b 5 This file is part of the GNU Binutils.
252b5132 6
f96b4a7b 7 This program is free software; you can redistribute it and/or modify
252b5132 8 it under the terms of the GNU General Public License as published by
f96b4a7b
NC
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
252b5132 11
f96b4a7b 12 This program is distributed in the hope that it will be useful,
252b5132
RH
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
f96b4a7b
NC
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
252b5132
RH
21
22#ifndef LDEXP_H
23#define LDEXP_H
24
25/* The result of an expression tree */
89cdebba 26typedef 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 33typedef struct {
252b5132 34 int node_code;
f856040a 35 unsigned int lineno;
b34976b6
AM
36 enum {
37 etree_binary,
38 etree_trinary,
39 etree_unary,
40 etree_name,
41 etree_assign,
42 etree_provide,
43 etree_provided,
b34976b6
AM
44 etree_value,
45 etree_assert,
46 etree_rel
47 } node_class;
252b5132
RH
48} node_type;
49
89cdebba 50typedef union etree_union {
252b5132
RH
51 node_type type;
52 struct {
53 node_type type;
54 union etree_union *lhs;
55 union etree_union *rhs;
56 } binary;
57 struct {
58 node_type type;
59 union etree_union *cond;
60 union etree_union *lhs;
61 union etree_union *rhs;
62 } trinary;
63 struct {
64 node_type type;
2c382fb6 65 const char *dst;
252b5132 66 union etree_union *src;
7af8e998 67 bfd_boolean hidden;
252b5132 68 } assign;
252b5132
RH
69 struct {
70 node_type type;
89cdebba 71 union etree_union *child;
252b5132
RH
72 } unary;
73 struct {
74 node_type type;
2c382fb6 75 const char *name;
252b5132
RH
76 } name;
77 struct {
78 node_type type;
79 bfd_vma value;
2c382fb6 80 char *str;
252b5132
RH
81 } value;
82 struct {
83 node_type type;
84 asection *section;
85 bfd_vma value;
86 } rel;
87 struct {
88 node_type type;
89 union etree_union *child;
90 const char *message;
91 } assert_s;
92} etree_type;
2d20f7bf 93
e9ee469a
AM
94typedef enum {
95 lang_first_phase_enum,
96 lang_mark_phase_enum,
97 lang_allocating_phase_enum,
98 lang_final_phase_enum
99} lang_phase_type;
100
b10a8ae0
L
101union lang_statement_union;
102
e9ee469a
AM
103struct ldexp_control {
104 /* Modify expression evaluation depending on this. */
105 lang_phase_type phase;
106
107 /* Principally used for diagnostics. */
108 bfd_boolean assigning_to_dot;
109
110 /* Working results. */
111 etree_value_type result;
112 bfd_vma dot;
113
114 /* Current dot and section passed to ldexp folder. */
115 bfd_vma *dotp;
116 asection *section;
117
118 /* State machine and results for DATASEG. */
119 struct {
120 enum {
121 exp_dataseg_none,
122 exp_dataseg_align_seen,
123 exp_dataseg_relro_seen,
124 exp_dataseg_end_seen,
125 exp_dataseg_relro_adjust,
126 exp_dataseg_adjust
127 } phase;
128
129 bfd_vma base, min_base, relro_end, end, pagesize, maxpagesize;
b10a8ae0
L
130
131 enum {
132 exp_dataseg_relro_none,
133 exp_dataseg_relro_start,
134 exp_dataseg_relro_end,
135 } relro;
136
137 union lang_statement_union *relro_start_stat;
138 union lang_statement_union *relro_end_stat;
e9ee469a
AM
139 } dataseg;
140};
141
142extern struct ldexp_control expld;
252b5132 143
ba916c8a
MM
144/* A maps from a segment name to a base address. */
145typedef struct segment_struct {
146 /* The next segment in the linked list. */
147 struct segment_struct *next;
148 /* The name of the sgement. */
149 const char *name;
150 /* The base address for the segment. */
151 bfd_vma value;
152 /* True if a SEGMENT_START directive corresponding to this segment
153 has been seen. */
154 bfd_boolean used;
155} segment_type;
156
157/* The segments specified by the user on the command-line. */
158extern segment_type *segments;
159
2c382fb6
AM
160typedef struct _fill_type fill_type;
161
b34976b6 162etree_type *exp_intop
1579bae1 163 (bfd_vma);
b34976b6 164etree_type *exp_bigintop
1579bae1 165 (bfd_vma, char *);
b34976b6 166etree_type *exp_relop
1579bae1 167 (asection *, bfd_vma);
e9ee469a
AM
168void exp_fold_tree
169 (etree_type *, asection *, bfd_vma *);
b34976b6 170etree_type *exp_binop
1579bae1 171 (int, etree_type *, etree_type *);
b34976b6 172etree_type *exp_trinop
1579bae1 173 (int,etree_type *, etree_type *, etree_type *);
b34976b6 174etree_type *exp_unop
1579bae1 175 (int, etree_type *);
b34976b6 176etree_type *exp_nameop
1579bae1 177 (int, const char *);
b34976b6 178etree_type *exp_assop
1579bae1 179 (int, const char *, etree_type *);
b34976b6 180etree_type *exp_provide
7af8e998 181 (const char *, etree_type *, bfd_boolean);
b34976b6 182etree_type *exp_assert
1579bae1 183 (etree_type *, const char *);
b34976b6 184void exp_print_tree
1579bae1 185 (etree_type *);
b34976b6 186bfd_vma exp_get_vma
e9ee469a 187 (etree_type *, bfd_vma, char *);
b34976b6 188int exp_get_value_int
e9ee469a 189 (etree_type *, int, char *);
b34976b6 190fill_type *exp_get_fill
e9ee469a 191 (etree_type *, fill_type *, char *);
b34976b6 192bfd_vma exp_get_abs_int
e9ee469a 193 (etree_type *, int, char *);
252b5132
RH
194
195#endif
This page took 0.477972 seconds and 4 git commands to generate.