Commit | Line | Data |
---|---|---|
8e5a525c AM |
1 | /* A YACC grammar to parse a superset of the AT&T linker scripting language. |
2 | Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, | |
02a38f92 | 3 | 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
252b5132 RH |
4 | Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com). |
5 | ||
3ec57632 | 6 | This file is part of GNU ld. |
252b5132 | 7 | |
3ec57632 NC |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
252b5132 | 12 | |
3ec57632 NC |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
252b5132 | 17 | |
3ec57632 NC |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | |
75be928b | 20 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
252b5132 RH |
21 | |
22 | %{ | |
23 | /* | |
24 | ||
25 | */ | |
26 | ||
27 | #define DONTDECLARE_MALLOC | |
28 | ||
29 | #include "bfd.h" | |
30 | #include "sysdep.h" | |
31 | #include "bfdlink.h" | |
d038301c | 32 | #include "ld.h" |
252b5132 RH |
33 | #include "ldexp.h" |
34 | #include "ldver.h" | |
35 | #include "ldlang.h" | |
252b5132 | 36 | #include "ldfile.h" |
b71e2778 | 37 | #include "ldemul.h" |
252b5132 RH |
38 | #include "ldmisc.h" |
39 | #include "ldmain.h" | |
40 | #include "mri.h" | |
41 | #include "ldctor.h" | |
42 | #include "ldlex.h" | |
43 | ||
44 | #ifndef YYDEBUG | |
45 | #define YYDEBUG 1 | |
46 | #endif | |
47 | ||
48 | static enum section_type sectype; | |
279e75dc | 49 | static lang_memory_region_type *region; |
252b5132 | 50 | |
b34976b6 AM |
51 | FILE *saved_script_handle = NULL; |
52 | bfd_boolean force_make_executable = FALSE; | |
252b5132 | 53 | |
b34976b6 AM |
54 | bfd_boolean ldgram_in_script = FALSE; |
55 | bfd_boolean ldgram_had_equals = FALSE; | |
56 | bfd_boolean ldgram_had_keep = FALSE; | |
252b5132 RH |
57 | char *ldgram_vers_current_lang = NULL; |
58 | ||
59 | #define ERROR_NAME_MAX 20 | |
60 | static char *error_names[ERROR_NAME_MAX]; | |
61 | static int error_index; | |
62 | #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++; | |
63 | #define POP_ERROR() error_index--; | |
64 | %} | |
65 | %union { | |
66 | bfd_vma integer; | |
2c382fb6 AM |
67 | struct big_int |
68 | { | |
69 | bfd_vma integer; | |
70 | char *str; | |
71 | } bigint; | |
72 | fill_type *fill; | |
252b5132 RH |
73 | char *name; |
74 | const char *cname; | |
75 | struct wildcard_spec wildcard; | |
b6bf44ba | 76 | struct wildcard_list *wildcard_list; |
18625d54 | 77 | struct name_list *name_list; |
252b5132 RH |
78 | int token; |
79 | union etree_union *etree; | |
80 | struct phdr_info | |
81 | { | |
b34976b6 AM |
82 | bfd_boolean filehdr; |
83 | bfd_boolean phdrs; | |
252b5132 RH |
84 | union etree_union *at; |
85 | union etree_union *flags; | |
86 | } phdr; | |
87 | struct lang_nocrossref *nocrossref; | |
88 | struct lang_output_section_phdr_list *section_phdr; | |
89 | struct bfd_elf_version_deps *deflist; | |
90 | struct bfd_elf_version_expr *versyms; | |
91 | struct bfd_elf_version_tree *versnode; | |
92 | } | |
93 | ||
94 | %type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val | |
bbf115d3 | 95 | %type <etree> opt_exp_without_type opt_subalign opt_align |
2c382fb6 | 96 | %type <fill> fill_opt fill_exp |
18625d54 | 97 | %type <name_list> exclude_name_list |
b6bf44ba | 98 | %type <wildcard_list> file_NAME_list |
252b5132 | 99 | %type <name> memspec_opt casesymlist |
562d3460 | 100 | %type <name> memspec_at_opt |
252b5132 RH |
101 | %type <cname> wildcard_name |
102 | %type <wildcard> wildcard_spec | |
d038301c | 103 | %token <bigint> INT |
252b5132 RH |
104 | %token <name> NAME LNAME |
105 | %type <integer> length | |
106 | %type <phdr> phdr_qualifiers | |
107 | %type <nocrossref> nocrossref_list | |
108 | %type <section_phdr> phdr_opt | |
109 | %type <integer> opt_nocrossrefs | |
110 | ||
d038301c | 111 | %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ |
252b5132 RH |
112 | %right <token> '?' ':' |
113 | %left <token> OROR | |
114 | %left <token> ANDAND | |
115 | %left <token> '|' | |
116 | %left <token> '^' | |
117 | %left <token> '&' | |
118 | %left <token> EQ NE | |
119 | %left <token> '<' '>' LE GE | |
120 | %left <token> LSHIFT RSHIFT | |
121 | ||
122 | %left <token> '+' '-' | |
123 | %left <token> '*' '/' '%' | |
124 | ||
125 | %right UNARY | |
d038301c | 126 | %token END |
252b5132 RH |
127 | %left <token> '(' |
128 | %token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE | |
bcaa7b3e L |
129 | %token SECTIONS PHDRS DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END |
130 | %token SORT_BY_NAME SORT_BY_ALIGNMENT | |
252b5132 RH |
131 | %token '{' '}' |
132 | %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH | |
4818e05f | 133 | %token INHIBIT_COMMON_ALLOCATION |
ba916c8a | 134 | %token SEGMENT_START |
252b5132 | 135 | %token INCLUDE |
ed9ef263 | 136 | %token MEMORY |
252b5132 | 137 | %token NOLOAD DSECT COPY INFO OVERLAY |
ed9ef263 | 138 | %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY |
252b5132 RH |
139 | %token <integer> NEXT |
140 | %token SIZEOF ADDR LOADADDR MAX_K MIN_K | |
141 | %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS | |
142 | %token ORIGIN FILL | |
143 | %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS | |
7af8e998 | 144 | %token ALIGNMOD AT SUBALIGN PROVIDE PROVIDE_HIDDEN AS_NEEDED |
0841712e | 145 | %type <token> assign_op atype attributes_opt sect_constraint |
252b5132 RH |
146 | %type <name> filename |
147 | %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K | |
148 | %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL | |
149 | %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START | |
150 | %token <name> VERS_TAG VERS_IDENTIFIER | |
151 | %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT | |
0cf7d72c | 152 | %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL |
252b5132 | 153 | %token EXCLUDE_FILE |
24718e3b | 154 | %token CONSTANT |
252b5132 RH |
155 | %type <versyms> vers_defns |
156 | %type <versnode> vers_tag | |
157 | %type <deflist> verdep | |
55255dae | 158 | %token INPUT_DYNAMIC_LIST |
252b5132 RH |
159 | |
160 | %% | |
161 | ||
d038301c | 162 | file: |
252b5132 RH |
163 | INPUT_SCRIPT script_file |
164 | | INPUT_MRI_SCRIPT mri_script_file | |
165 | | INPUT_VERSION_SCRIPT version_script_file | |
55255dae | 166 | | INPUT_DYNAMIC_LIST dynamic_list_file |
252b5132 RH |
167 | | INPUT_DEFSYM defsym_expr |
168 | ; | |
169 | ||
170 | ||
171 | filename: NAME; | |
172 | ||
173 | ||
174 | defsym_expr: | |
175 | { ldlex_defsym(); } | |
176 | NAME '=' exp | |
177 | { | |
178 | ldlex_popstate(); | |
179 | lang_add_assignment(exp_assop($3,$2,$4)); | |
180 | } | |
944cd72c | 181 | ; |
252b5132 | 182 | |
d038301c | 183 | /* SYNTAX WITHIN AN MRI SCRIPT FILE */ |
252b5132 RH |
184 | mri_script_file: |
185 | { | |
186 | ldlex_mri_script (); | |
187 | PUSH_ERROR (_("MRI style script")); | |
188 | } | |
189 | mri_script_lines | |
190 | { | |
191 | ldlex_popstate (); | |
192 | mri_draw_tree (); | |
193 | POP_ERROR (); | |
194 | } | |
195 | ; | |
196 | ||
197 | mri_script_lines: | |
198 | mri_script_lines mri_script_command NEWLINE | |
199 | | | |
200 | ; | |
201 | ||
202 | mri_script_command: | |
d038301c | 203 | CHIP exp |
252b5132 RH |
204 | | CHIP exp ',' exp |
205 | | NAME { | |
206 | einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1); | |
207 | } | |
208 | | LIST { | |
209 | config.map_filename = "-"; | |
210 | } | |
211 | | ORDER ordernamelist | |
d038301c | 212 | | ENDWORD |
252b5132 RH |
213 | | PUBLIC NAME '=' exp |
214 | { mri_public($2, $4); } | |
215 | | PUBLIC NAME ',' exp | |
216 | { mri_public($2, $4); } | |
d038301c | 217 | | PUBLIC NAME exp |
252b5132 RH |
218 | { mri_public($2, $3); } |
219 | | FORMAT NAME | |
220 | { mri_format($2); } | |
221 | | SECT NAME ',' exp | |
222 | { mri_output_section($2, $4);} | |
223 | | SECT NAME exp | |
224 | { mri_output_section($2, $3);} | |
225 | | SECT NAME '=' exp | |
226 | { mri_output_section($2, $4);} | |
227 | | ALIGN_K NAME '=' exp | |
228 | { mri_align($2,$4); } | |
229 | | ALIGN_K NAME ',' exp | |
230 | { mri_align($2,$4); } | |
231 | | ALIGNMOD NAME '=' exp | |
232 | { mri_alignmod($2,$4); } | |
233 | | ALIGNMOD NAME ',' exp | |
234 | { mri_alignmod($2,$4); } | |
235 | | ABSOLUTE mri_abs_name_list | |
236 | | LOAD mri_load_name_list | |
d038301c RM |
237 | | NAMEWORD NAME |
238 | { mri_name($2); } | |
252b5132 RH |
239 | | ALIAS NAME ',' NAME |
240 | { mri_alias($2,$4,0);} | |
241 | | ALIAS NAME ',' INT | |
2c382fb6 | 242 | { mri_alias ($2, 0, (int) $4.integer); } |
252b5132 RH |
243 | | BASE exp |
244 | { mri_base($2); } | |
2c382fb6 AM |
245 | | TRUNCATE INT |
246 | { mri_truncate ((unsigned int) $2.integer); } | |
252b5132 RH |
247 | | CASE casesymlist |
248 | | EXTERN extern_name_list | |
249 | | INCLUDE filename | |
b47c4208 AM |
250 | { ldlex_script (); ldfile_open_command_file($2); } |
251 | mri_script_lines END | |
252 | { ldlex_popstate (); } | |
252b5132 | 253 | | START NAME |
b34976b6 | 254 | { lang_add_entry ($2, FALSE); } |
252b5132 RH |
255 | | |
256 | ; | |
257 | ||
258 | ordernamelist: | |
259 | ordernamelist ',' NAME { mri_order($3); } | |
260 | | ordernamelist NAME { mri_order($2); } | |
261 | | | |
262 | ; | |
263 | ||
264 | mri_load_name_list: | |
265 | NAME | |
266 | { mri_load($1); } | |
267 | | mri_load_name_list ',' NAME { mri_load($3); } | |
268 | ; | |
269 | ||
270 | mri_abs_name_list: | |
271 | NAME | |
272 | { mri_only_load($1); } | |
273 | | mri_abs_name_list ',' NAME | |
274 | { mri_only_load($3); } | |
275 | ; | |
276 | ||
277 | casesymlist: | |
278 | /* empty */ { $$ = NULL; } | |
279 | | NAME | |
280 | | casesymlist ',' NAME | |
281 | ; | |
282 | ||
283 | extern_name_list: | |
284 | NAME | |
285 | { ldlang_add_undef ($1); } | |
286 | | extern_name_list NAME | |
287 | { ldlang_add_undef ($2); } | |
288 | | extern_name_list ',' NAME | |
289 | { ldlang_add_undef ($3); } | |
290 | ; | |
291 | ||
292 | script_file: | |
293 | { | |
294 | ldlex_both(); | |
295 | } | |
296 | ifile_list | |
297 | { | |
298 | ldlex_popstate(); | |
299 | } | |
300 | ; | |
301 | ||
302 | ||
303 | ifile_list: | |
304 | ifile_list ifile_p1 | |
305 | | | |
306 | ; | |
307 | ||
308 | ||
309 | ||
310 | ifile_p1: | |
311 | memory | |
312 | | sections | |
313 | | phdrs | |
314 | | startup | |
315 | | high_level_library | |
316 | | low_level_library | |
317 | | floating_point_support | |
318 | | statement_anywhere | |
319 | | version | |
320 | | ';' | |
321 | | TARGET_K '(' NAME ')' | |
322 | { lang_add_target($3); } | |
323 | | SEARCH_DIR '(' filename ')' | |
b34976b6 | 324 | { ldfile_add_library_path ($3, FALSE); } |
252b5132 RH |
325 | | OUTPUT '(' filename ')' |
326 | { lang_add_output($3, 1); } | |
327 | | OUTPUT_FORMAT '(' NAME ')' | |
328 | { lang_add_output_format ($3, (char *) NULL, | |
329 | (char *) NULL, 1); } | |
330 | | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')' | |
331 | { lang_add_output_format ($3, $5, $7, 1); } | |
332 | | OUTPUT_ARCH '(' NAME ')' | |
5e2f1575 | 333 | { ldfile_set_output_arch ($3, bfd_arch_unknown); } |
252b5132 | 334 | | FORCE_COMMON_ALLOCATION |
b34976b6 | 335 | { command_line.force_common_definition = TRUE ; } |
4818e05f | 336 | | INHIBIT_COMMON_ALLOCATION |
b34976b6 | 337 | { command_line.inhibit_common_definition = TRUE ; } |
252b5132 RH |
338 | | INPUT '(' input_list ')' |
339 | | GROUP | |
340 | { lang_enter_group (); } | |
341 | '(' input_list ')' | |
342 | { lang_leave_group (); } | |
343 | | MAP '(' filename ')' | |
344 | { lang_add_map($3); } | |
d038301c | 345 | | INCLUDE filename |
b47c4208 AM |
346 | { ldlex_script (); ldfile_open_command_file($2); } |
347 | ifile_list END | |
348 | { ldlex_popstate (); } | |
252b5132 RH |
349 | | NOCROSSREFS '(' nocrossref_list ')' |
350 | { | |
351 | lang_add_nocrossref ($3); | |
352 | } | |
353 | | EXTERN '(' extern_name_list ')' | |
354 | ; | |
355 | ||
356 | input_list: | |
357 | NAME | |
358 | { lang_add_input_file($1,lang_input_file_is_search_file_enum, | |
359 | (char *)NULL); } | |
360 | | input_list ',' NAME | |
361 | { lang_add_input_file($3,lang_input_file_is_search_file_enum, | |
362 | (char *)NULL); } | |
363 | | input_list NAME | |
364 | { lang_add_input_file($2,lang_input_file_is_search_file_enum, | |
365 | (char *)NULL); } | |
366 | | LNAME | |
367 | { lang_add_input_file($1,lang_input_file_is_l_enum, | |
368 | (char *)NULL); } | |
369 | | input_list ',' LNAME | |
370 | { lang_add_input_file($3,lang_input_file_is_l_enum, | |
371 | (char *)NULL); } | |
372 | | input_list LNAME | |
373 | { lang_add_input_file($2,lang_input_file_is_l_enum, | |
374 | (char *)NULL); } | |
b717d30e JJ |
375 | | AS_NEEDED '(' |
376 | { $<integer>$ = as_needed; as_needed = TRUE; } | |
377 | input_list ')' | |
378 | { as_needed = $<integer>3; } | |
379 | | input_list ',' AS_NEEDED '(' | |
380 | { $<integer>$ = as_needed; as_needed = TRUE; } | |
381 | input_list ')' | |
382 | { as_needed = $<integer>5; } | |
383 | | input_list AS_NEEDED '(' | |
384 | { $<integer>$ = as_needed; as_needed = TRUE; } | |
385 | input_list ')' | |
386 | { as_needed = $<integer>4; } | |
252b5132 RH |
387 | ; |
388 | ||
389 | sections: | |
390 | SECTIONS '{' sec_or_group_p1 '}' | |
391 | ; | |
392 | ||
393 | sec_or_group_p1: | |
394 | sec_or_group_p1 section | |
395 | | sec_or_group_p1 statement_anywhere | |
396 | | | |
397 | ; | |
398 | ||
399 | statement_anywhere: | |
400 | ENTRY '(' NAME ')' | |
b34976b6 | 401 | { lang_add_entry ($3, FALSE); } |
252b5132 | 402 | | assignment end |
b6ca8815 NS |
403 | | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')' |
404 | { ldlex_popstate (); | |
405 | lang_add_assignment (exp_assert ($4, $6)); } | |
252b5132 RH |
406 | ; |
407 | ||
408 | /* The '*' and '?' cases are there because the lexer returns them as | |
409 | separate tokens rather than as NAME. */ | |
410 | wildcard_name: | |
411 | NAME | |
412 | { | |
413 | $$ = $1; | |
414 | } | |
415 | | '*' | |
416 | { | |
417 | $$ = "*"; | |
418 | } | |
419 | | '?' | |
420 | { | |
421 | $$ = "?"; | |
422 | } | |
423 | ; | |
424 | ||
425 | wildcard_spec: | |
426 | wildcard_name | |
427 | { | |
428 | $$.name = $1; | |
bcaa7b3e | 429 | $$.sorted = none; |
18625d54 | 430 | $$.exclude_name_list = NULL; |
252b5132 | 431 | } |
18625d54 | 432 | | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name |
252b5132 RH |
433 | { |
434 | $$.name = $5; | |
bcaa7b3e | 435 | $$.sorted = none; |
18625d54 | 436 | $$.exclude_name_list = $3; |
252b5132 | 437 | } |
bcaa7b3e | 438 | | SORT_BY_NAME '(' wildcard_name ')' |
252b5132 RH |
439 | { |
440 | $$.name = $3; | |
bcaa7b3e | 441 | $$.sorted = by_name; |
18625d54 | 442 | $$.exclude_name_list = NULL; |
252b5132 | 443 | } |
bcaa7b3e L |
444 | | SORT_BY_ALIGNMENT '(' wildcard_name ')' |
445 | { | |
446 | $$.name = $3; | |
447 | $$.sorted = by_alignment; | |
448 | $$.exclude_name_list = NULL; | |
449 | } | |
450 | | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')' | |
451 | { | |
452 | $$.name = $5; | |
453 | $$.sorted = by_name_alignment; | |
454 | $$.exclude_name_list = NULL; | |
455 | } | |
456 | | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')' | |
457 | { | |
458 | $$.name = $5; | |
459 | $$.sorted = by_name; | |
460 | $$.exclude_name_list = NULL; | |
461 | } | |
462 | | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')' | |
463 | { | |
464 | $$.name = $5; | |
465 | $$.sorted = by_alignment_name; | |
466 | $$.exclude_name_list = NULL; | |
467 | } | |
468 | | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')' | |
469 | { | |
470 | $$.name = $5; | |
471 | $$.sorted = by_alignment; | |
472 | $$.exclude_name_list = NULL; | |
473 | } | |
474 | | SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')' | |
252b5132 RH |
475 | { |
476 | $$.name = $7; | |
bcaa7b3e | 477 | $$.sorted = by_name; |
18625d54 | 478 | $$.exclude_name_list = $5; |
252b5132 RH |
479 | } |
480 | ; | |
481 | ||
18625d54 | 482 | exclude_name_list: |
765b7cbe | 483 | exclude_name_list wildcard_name |
18625d54 CM |
484 | { |
485 | struct name_list *tmp; | |
486 | tmp = (struct name_list *) xmalloc (sizeof *tmp); | |
765b7cbe | 487 | tmp->name = $2; |
18625d54 | 488 | tmp->next = $1; |
d038301c | 489 | $$ = tmp; |
18625d54 CM |
490 | } |
491 | | | |
492 | wildcard_name | |
493 | { | |
494 | struct name_list *tmp; | |
495 | tmp = (struct name_list *) xmalloc (sizeof *tmp); | |
496 | tmp->name = $1; | |
497 | tmp->next = NULL; | |
498 | $$ = tmp; | |
499 | } | |
500 | ; | |
501 | ||
252b5132 | 502 | file_NAME_list: |
b6bf44ba | 503 | file_NAME_list opt_comma wildcard_spec |
252b5132 | 504 | { |
b6bf44ba AM |
505 | struct wildcard_list *tmp; |
506 | tmp = (struct wildcard_list *) xmalloc (sizeof *tmp); | |
507 | tmp->next = $1; | |
508 | tmp->spec = $3; | |
509 | $$ = tmp; | |
252b5132 | 510 | } |
b6bf44ba AM |
511 | | |
512 | wildcard_spec | |
252b5132 | 513 | { |
b6bf44ba AM |
514 | struct wildcard_list *tmp; |
515 | tmp = (struct wildcard_list *) xmalloc (sizeof *tmp); | |
516 | tmp->next = NULL; | |
517 | tmp->spec = $1; | |
518 | $$ = tmp; | |
252b5132 RH |
519 | } |
520 | ; | |
521 | ||
522 | input_section_spec_no_keep: | |
523 | NAME | |
524 | { | |
b6bf44ba AM |
525 | struct wildcard_spec tmp; |
526 | tmp.name = $1; | |
527 | tmp.exclude_name_list = NULL; | |
bcaa7b3e | 528 | tmp.sorted = none; |
b6bf44ba | 529 | lang_add_wild (&tmp, NULL, ldgram_had_keep); |
252b5132 | 530 | } |
b6bf44ba | 531 | | '[' file_NAME_list ']' |
252b5132 | 532 | { |
b6bf44ba | 533 | lang_add_wild (NULL, $2, ldgram_had_keep); |
252b5132 | 534 | } |
b6bf44ba | 535 | | wildcard_spec '(' file_NAME_list ')' |
252b5132 | 536 | { |
b6bf44ba | 537 | lang_add_wild (&$1, $3, ldgram_had_keep); |
252b5132 | 538 | } |
252b5132 RH |
539 | ; |
540 | ||
541 | input_section_spec: | |
542 | input_section_spec_no_keep | |
543 | | KEEP '(' | |
b34976b6 | 544 | { ldgram_had_keep = TRUE; } |
252b5132 | 545 | input_section_spec_no_keep ')' |
b34976b6 | 546 | { ldgram_had_keep = FALSE; } |
252b5132 RH |
547 | ; |
548 | ||
549 | statement: | |
550 | assignment end | |
551 | | CREATE_OBJECT_SYMBOLS | |
552 | { | |
d038301c | 553 | lang_add_attribute(lang_object_symbols_statement_enum); |
252b5132 RH |
554 | } |
555 | | ';' | |
556 | | CONSTRUCTORS | |
557 | { | |
d038301c RM |
558 | |
559 | lang_add_attribute(lang_constructors_statement_enum); | |
252b5132 | 560 | } |
bcaa7b3e | 561 | | SORT_BY_NAME '(' CONSTRUCTORS ')' |
252b5132 | 562 | { |
b34976b6 | 563 | constructors_sorted = TRUE; |
252b5132 RH |
564 | lang_add_attribute (lang_constructors_statement_enum); |
565 | } | |
566 | | input_section_spec | |
567 | | length '(' mustbe_exp ')' | |
568 | { | |
2c382fb6 | 569 | lang_add_data ((int) $1, $3); |
252b5132 | 570 | } |
d038301c | 571 | |
2c382fb6 | 572 | | FILL '(' fill_exp ')' |
252b5132 | 573 | { |
2c382fb6 | 574 | lang_add_fill ($3); |
252b5132 RH |
575 | } |
576 | ; | |
577 | ||
578 | statement_list: | |
579 | statement_list statement | |
580 | | statement | |
581 | ; | |
d038301c | 582 | |
252b5132 RH |
583 | statement_list_opt: |
584 | /* empty */ | |
585 | | statement_list | |
586 | ; | |
587 | ||
588 | length: | |
589 | QUAD | |
590 | { $$ = $1; } | |
591 | | SQUAD | |
592 | { $$ = $1; } | |
593 | | LONG | |
594 | { $$ = $1; } | |
595 | | SHORT | |
596 | { $$ = $1; } | |
597 | | BYTE | |
598 | { $$ = $1; } | |
599 | ; | |
600 | ||
2c382fb6 AM |
601 | fill_exp: |
602 | mustbe_exp | |
252b5132 | 603 | { |
e9ee469a | 604 | $$ = exp_get_fill ($1, 0, "fill value"); |
252b5132 | 605 | } |
252b5132 RH |
606 | ; |
607 | ||
2c382fb6 AM |
608 | fill_opt: |
609 | '=' fill_exp | |
610 | { $$ = $2; } | |
611 | | { $$ = (fill_type *) 0; } | |
612 | ; | |
252b5132 RH |
613 | |
614 | assign_op: | |
615 | PLUSEQ | |
616 | { $$ = '+'; } | |
617 | | MINUSEQ | |
618 | { $$ = '-'; } | |
619 | | MULTEQ | |
620 | { $$ = '*'; } | |
621 | | DIVEQ | |
622 | { $$ = '/'; } | |
623 | | LSHIFTEQ | |
624 | { $$ = LSHIFT; } | |
625 | | RSHIFTEQ | |
626 | { $$ = RSHIFT; } | |
627 | | ANDEQ | |
628 | { $$ = '&'; } | |
629 | | OREQ | |
630 | { $$ = '|'; } | |
631 | ||
632 | ; | |
633 | ||
634 | end: ';' | ',' | |
635 | ; | |
636 | ||
637 | ||
638 | assignment: | |
639 | NAME '=' mustbe_exp | |
640 | { | |
641 | lang_add_assignment (exp_assop ($2, $1, $3)); | |
642 | } | |
643 | | NAME assign_op mustbe_exp | |
644 | { | |
645 | lang_add_assignment (exp_assop ('=', $1, | |
646 | exp_binop ($2, | |
647 | exp_nameop (NAME, | |
648 | $1), | |
649 | $3))); | |
650 | } | |
651 | | PROVIDE '(' NAME '=' mustbe_exp ')' | |
652 | { | |
7af8e998 L |
653 | lang_add_assignment (exp_provide ($3, $5, FALSE)); |
654 | } | |
655 | | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')' | |
656 | { | |
657 | lang_add_assignment (exp_provide ($3, $5, TRUE)); | |
252b5132 RH |
658 | } |
659 | ; | |
660 | ||
661 | ||
662 | opt_comma: | |
663 | ',' | ; | |
664 | ||
665 | ||
666 | memory: | |
667 | MEMORY '{' memory_spec memory_spec_list '}' | |
668 | ; | |
669 | ||
670 | memory_spec_list: | |
671 | memory_spec_list memory_spec | |
672 | | memory_spec_list ',' memory_spec | |
673 | | | |
674 | ; | |
675 | ||
676 | ||
2d801b0f | 677 | memory_spec: NAME |
a747ee4d | 678 | { region = lang_memory_region_lookup ($1, TRUE); } |
252b5132 RH |
679 | attributes_opt ':' |
680 | origin_spec opt_comma length_spec | |
2d801b0f | 681 | {} |
74459f0e TW |
682 | ; |
683 | ||
684 | origin_spec: | |
252b5132 | 685 | ORIGIN '=' mustbe_exp |
e9ee469a AM |
686 | { |
687 | region->origin = exp_get_vma ($3, 0, "origin"); | |
688 | region->current = region->origin; | |
689 | } | |
252b5132 RH |
690 | ; |
691 | ||
692 | length_spec: | |
693 | LENGTH '=' mustbe_exp | |
e9ee469a AM |
694 | { |
695 | region->length = exp_get_vma ($3, -1, "length"); | |
252b5132 | 696 | } |
aa8804e4 | 697 | ; |
252b5132 RH |
698 | |
699 | attributes_opt: | |
aa8804e4 ILT |
700 | /* empty */ |
701 | { /* dummy action to avoid bison 1.25 error message */ } | |
702 | | '(' attributes_list ')' | |
703 | ; | |
704 | ||
705 | attributes_list: | |
706 | attributes_string | |
707 | | attributes_list attributes_string | |
708 | ; | |
709 | ||
710 | attributes_string: | |
711 | NAME | |
712 | { lang_set_flags (region, $1, 0); } | |
713 | | '!' NAME | |
714 | { lang_set_flags (region, $2, 1); } | |
252b5132 RH |
715 | ; |
716 | ||
717 | startup: | |
718 | STARTUP '(' filename ')' | |
719 | { lang_startup($3); } | |
720 | ; | |
721 | ||
722 | high_level_library: | |
723 | HLL '(' high_level_library_NAME_list ')' | |
724 | | HLL '(' ')' | |
725 | { ldemul_hll((char *)NULL); } | |
726 | ; | |
727 | ||
728 | high_level_library_NAME_list: | |
729 | high_level_library_NAME_list opt_comma filename | |
730 | { ldemul_hll($3); } | |
731 | | filename | |
732 | { ldemul_hll($1); } | |
733 | ||
734 | ; | |
735 | ||
736 | low_level_library: | |
737 | SYSLIB '(' low_level_library_NAME_list ')' | |
738 | ; low_level_library_NAME_list: | |
739 | low_level_library_NAME_list opt_comma filename | |
740 | { ldemul_syslib($3); } | |
741 | | | |
742 | ; | |
743 | ||
744 | floating_point_support: | |
745 | FLOAT | |
b34976b6 | 746 | { lang_float(TRUE); } |
252b5132 | 747 | | NOFLOAT |
b34976b6 | 748 | { lang_float(FALSE); } |
252b5132 | 749 | ; |
d038301c | 750 | |
252b5132 RH |
751 | nocrossref_list: |
752 | /* empty */ | |
753 | { | |
754 | $$ = NULL; | |
755 | } | |
756 | | NAME nocrossref_list | |
757 | { | |
758 | struct lang_nocrossref *n; | |
759 | ||
760 | n = (struct lang_nocrossref *) xmalloc (sizeof *n); | |
761 | n->name = $1; | |
762 | n->next = $2; | |
763 | $$ = n; | |
764 | } | |
765 | | NAME ',' nocrossref_list | |
766 | { | |
767 | struct lang_nocrossref *n; | |
768 | ||
769 | n = (struct lang_nocrossref *) xmalloc (sizeof *n); | |
770 | n->name = $1; | |
771 | n->next = $3; | |
772 | $$ = n; | |
773 | } | |
774 | ; | |
775 | ||
3ec57632 | 776 | mustbe_exp: { ldlex_expression (); } |
252b5132 | 777 | exp |
3ec57632 | 778 | { ldlex_popstate (); $$=$2;} |
252b5132 RH |
779 | ; |
780 | ||
781 | exp : | |
782 | '-' exp %prec UNARY | |
3ec57632 | 783 | { $$ = exp_unop ('-', $2); } |
252b5132 RH |
784 | | '(' exp ')' |
785 | { $$ = $2; } | |
786 | | NEXT '(' exp ')' %prec UNARY | |
3ec57632 | 787 | { $$ = exp_unop ((int) $1,$3); } |
252b5132 | 788 | | '!' exp %prec UNARY |
3ec57632 | 789 | { $$ = exp_unop ('!', $2); } |
252b5132 RH |
790 | | '+' exp %prec UNARY |
791 | { $$ = $2; } | |
792 | | '~' exp %prec UNARY | |
3ec57632 | 793 | { $$ = exp_unop ('~', $2);} |
252b5132 RH |
794 | |
795 | | exp '*' exp | |
3ec57632 | 796 | { $$ = exp_binop ('*', $1, $3); } |
252b5132 | 797 | | exp '/' exp |
3ec57632 | 798 | { $$ = exp_binop ('/', $1, $3); } |
252b5132 | 799 | | exp '%' exp |
3ec57632 | 800 | { $$ = exp_binop ('%', $1, $3); } |
252b5132 | 801 | | exp '+' exp |
3ec57632 | 802 | { $$ = exp_binop ('+', $1, $3); } |
252b5132 | 803 | | exp '-' exp |
3ec57632 | 804 | { $$ = exp_binop ('-' , $1, $3); } |
252b5132 | 805 | | exp LSHIFT exp |
3ec57632 | 806 | { $$ = exp_binop (LSHIFT , $1, $3); } |
252b5132 | 807 | | exp RSHIFT exp |
3ec57632 | 808 | { $$ = exp_binop (RSHIFT , $1, $3); } |
252b5132 | 809 | | exp EQ exp |
3ec57632 | 810 | { $$ = exp_binop (EQ , $1, $3); } |
252b5132 | 811 | | exp NE exp |
3ec57632 | 812 | { $$ = exp_binop (NE , $1, $3); } |
252b5132 | 813 | | exp LE exp |
3ec57632 | 814 | { $$ = exp_binop (LE , $1, $3); } |
252b5132 | 815 | | exp GE exp |
3ec57632 | 816 | { $$ = exp_binop (GE , $1, $3); } |
252b5132 | 817 | | exp '<' exp |
3ec57632 | 818 | { $$ = exp_binop ('<' , $1, $3); } |
252b5132 | 819 | | exp '>' exp |
3ec57632 | 820 | { $$ = exp_binop ('>' , $1, $3); } |
252b5132 | 821 | | exp '&' exp |
3ec57632 | 822 | { $$ = exp_binop ('&' , $1, $3); } |
252b5132 | 823 | | exp '^' exp |
3ec57632 | 824 | { $$ = exp_binop ('^' , $1, $3); } |
252b5132 | 825 | | exp '|' exp |
3ec57632 | 826 | { $$ = exp_binop ('|' , $1, $3); } |
252b5132 | 827 | | exp '?' exp ':' exp |
3ec57632 | 828 | { $$ = exp_trinop ('?' , $1, $3, $5); } |
252b5132 | 829 | | exp ANDAND exp |
3ec57632 | 830 | { $$ = exp_binop (ANDAND , $1, $3); } |
252b5132 | 831 | | exp OROR exp |
3ec57632 | 832 | { $$ = exp_binop (OROR , $1, $3); } |
252b5132 | 833 | | DEFINED '(' NAME ')' |
3ec57632 | 834 | { $$ = exp_nameop (DEFINED, $3); } |
252b5132 | 835 | | INT |
2c382fb6 | 836 | { $$ = exp_bigintop ($1.integer, $1.str); } |
252b5132 | 837 | | SIZEOF_HEADERS |
3ec57632 | 838 | { $$ = exp_nameop (SIZEOF_HEADERS,0); } |
252b5132 RH |
839 | |
840 | | SIZEOF '(' NAME ')' | |
3ec57632 | 841 | { $$ = exp_nameop (SIZEOF,$3); } |
252b5132 | 842 | | ADDR '(' NAME ')' |
3ec57632 | 843 | { $$ = exp_nameop (ADDR,$3); } |
252b5132 | 844 | | LOADADDR '(' NAME ')' |
3ec57632 | 845 | { $$ = exp_nameop (LOADADDR,$3); } |
24718e3b L |
846 | | CONSTANT '(' NAME ')' |
847 | { $$ = exp_nameop (CONSTANT,$3); } | |
252b5132 | 848 | | ABSOLUTE '(' exp ')' |
3ec57632 | 849 | { $$ = exp_unop (ABSOLUTE, $3); } |
252b5132 | 850 | | ALIGN_K '(' exp ')' |
3ec57632 | 851 | { $$ = exp_unop (ALIGN_K,$3); } |
876f4090 | 852 | | ALIGN_K '(' exp ',' exp ')' |
3ec57632 | 853 | { $$ = exp_binop (ALIGN_K,$3,$5); } |
2d20f7bf JJ |
854 | | DATA_SEGMENT_ALIGN '(' exp ',' exp ')' |
855 | { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); } | |
a4f5ad88 JJ |
856 | | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')' |
857 | { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); } | |
2d20f7bf | 858 | | DATA_SEGMENT_END '(' exp ')' |
3ec57632 | 859 | { $$ = exp_unop (DATA_SEGMENT_END, $3); } |
ba916c8a MM |
860 | | SEGMENT_START '(' NAME ',' exp ')' |
861 | { /* The operands to the expression node are | |
862 | placed in the opposite order from the way | |
863 | in which they appear in the script as | |
864 | that allows us to reuse more code in | |
865 | fold_binary. */ | |
866 | $$ = exp_binop (SEGMENT_START, | |
867 | $5, | |
868 | exp_nameop (NAME, $3)); } | |
252b5132 | 869 | | BLOCK '(' exp ')' |
3ec57632 | 870 | { $$ = exp_unop (ALIGN_K,$3); } |
252b5132 | 871 | | NAME |
3ec57632 | 872 | { $$ = exp_nameop (NAME,$1); } |
252b5132 RH |
873 | | MAX_K '(' exp ',' exp ')' |
874 | { $$ = exp_binop (MAX_K, $3, $5 ); } | |
875 | | MIN_K '(' exp ',' exp ')' | |
876 | { $$ = exp_binop (MIN_K, $3, $5 ); } | |
877 | | ASSERT_K '(' exp ',' NAME ')' | |
878 | { $$ = exp_assert ($3, $5); } | |
3ec57632 NC |
879 | | ORIGIN '(' NAME ')' |
880 | { $$ = exp_nameop (ORIGIN, $3); } | |
881 | | LENGTH '(' NAME ')' | |
882 | { $$ = exp_nameop (LENGTH, $3); } | |
252b5132 RH |
883 | ; |
884 | ||
885 | ||
562d3460 TW |
886 | memspec_at_opt: |
887 | AT '>' NAME { $$ = $3; } | |
9f88b410 | 888 | | { $$ = 0; } |
562d3460 TW |
889 | ; |
890 | ||
252b5132 RH |
891 | opt_at: |
892 | AT '(' exp ')' { $$ = $3; } | |
893 | | { $$ = 0; } | |
894 | ; | |
895 | ||
bbf115d3 L |
896 | opt_align: |
897 | ALIGN_K '(' exp ')' { $$ = $3; } | |
898 | | { $$ = 0; } | |
899 | ; | |
900 | ||
7e7d5768 AM |
901 | opt_subalign: |
902 | SUBALIGN '(' exp ')' { $$ = $3; } | |
903 | | { $$ = 0; } | |
904 | ; | |
905 | ||
0841712e JJ |
906 | sect_constraint: |
907 | ONLY_IF_RO { $$ = ONLY_IF_RO; } | |
908 | | ONLY_IF_RW { $$ = ONLY_IF_RW; } | |
0cf7d72c | 909 | | SPECIAL { $$ = SPECIAL; } |
0841712e JJ |
910 | | { $$ = 0; } |
911 | ; | |
912 | ||
252b5132 | 913 | section: NAME { ldlex_expression(); } |
d038301c | 914 | opt_exp_with_type |
7e7d5768 | 915 | opt_at |
bbf115d3 | 916 | opt_align |
7e7d5768 | 917 | opt_subalign { ldlex_popstate (); ldlex_script (); } |
0841712e | 918 | sect_constraint |
252b5132 RH |
919 | '{' |
920 | { | |
921 | lang_enter_output_section_statement($1, $3, | |
922 | sectype, | |
bbf115d3 | 923 | $5, $6, $4, $8); |
252b5132 | 924 | } |
d038301c | 925 | statement_list_opt |
252b5132 | 926 | '}' { ldlex_popstate (); ldlex_expression (); } |
562d3460 | 927 | memspec_opt memspec_at_opt phdr_opt fill_opt |
252b5132 RH |
928 | { |
929 | ldlex_popstate (); | |
bbf115d3 | 930 | lang_leave_output_section_statement ($17, $14, $16, $15); |
252b5132 RH |
931 | } |
932 | opt_comma | |
2d801b0f | 933 | {} |
252b5132 RH |
934 | | OVERLAY |
935 | { ldlex_expression (); } | |
7e7d5768 | 936 | opt_exp_without_type opt_nocrossrefs opt_at opt_subalign |
252b5132 | 937 | { ldlex_popstate (); ldlex_script (); } |
d038301c | 938 | '{' |
252b5132 | 939 | { |
7e7d5768 | 940 | lang_enter_overlay ($3, $6); |
252b5132 RH |
941 | } |
942 | overlay_section | |
943 | '}' | |
944 | { ldlex_popstate (); ldlex_expression (); } | |
562d3460 | 945 | memspec_opt memspec_at_opt phdr_opt fill_opt |
252b5132 RH |
946 | { |
947 | ldlex_popstate (); | |
9f88b410 | 948 | lang_leave_overlay ($5, (int) $4, |
7e7d5768 | 949 | $16, $13, $15, $14); |
252b5132 RH |
950 | } |
951 | opt_comma | |
952 | | /* The GROUP case is just enough to support the gcc | |
953 | svr3.ifile script. It is not intended to be full | |
954 | support. I'm not even sure what GROUP is supposed | |
955 | to mean. */ | |
956 | GROUP { ldlex_expression (); } | |
957 | opt_exp_with_type | |
958 | { | |
959 | ldlex_popstate (); | |
960 | lang_add_assignment (exp_assop ('=', ".", $3)); | |
961 | } | |
962 | '{' sec_or_group_p1 '}' | |
963 | ; | |
964 | ||
965 | type: | |
966 | NOLOAD { sectype = noload_section; } | |
02a38f92 AM |
967 | | DSECT { sectype = noalloc_section; } |
968 | | COPY { sectype = noalloc_section; } | |
969 | | INFO { sectype = noalloc_section; } | |
970 | | OVERLAY { sectype = noalloc_section; } | |
252b5132 RH |
971 | ; |
972 | ||
973 | atype: | |
974 | '(' type ')' | |
975 | | /* EMPTY */ { sectype = normal_section; } | |
976 | | '(' ')' { sectype = normal_section; } | |
977 | ; | |
978 | ||
979 | opt_exp_with_type: | |
980 | exp atype ':' { $$ = $1; } | |
981 | | atype ':' { $$ = (etree_type *)NULL; } | |
982 | | /* The BIND cases are to support the gcc svr3.ifile | |
983 | script. They aren't intended to implement full | |
984 | support for the BIND keyword. I'm not even sure | |
985 | what BIND is supposed to mean. */ | |
986 | BIND '(' exp ')' atype ':' { $$ = $3; } | |
987 | | BIND '(' exp ')' BLOCK '(' exp ')' atype ':' | |
988 | { $$ = $3; } | |
989 | ; | |
990 | ||
991 | opt_exp_without_type: | |
992 | exp ':' { $$ = $1; } | |
993 | | ':' { $$ = (etree_type *) NULL; } | |
994 | ; | |
995 | ||
996 | opt_nocrossrefs: | |
997 | /* empty */ | |
998 | { $$ = 0; } | |
999 | | NOCROSSREFS | |
1000 | { $$ = 1; } | |
1001 | ; | |
1002 | ||
1003 | memspec_opt: | |
1004 | '>' NAME | |
1005 | { $$ = $2; } | |
a747ee4d | 1006 | | { $$ = DEFAULT_MEMORY_REGION; } |
252b5132 RH |
1007 | ; |
1008 | ||
1009 | phdr_opt: | |
1010 | /* empty */ | |
1011 | { | |
1012 | $$ = NULL; | |
1013 | } | |
1014 | | phdr_opt ':' NAME | |
1015 | { | |
1016 | struct lang_output_section_phdr_list *n; | |
1017 | ||
1018 | n = ((struct lang_output_section_phdr_list *) | |
1019 | xmalloc (sizeof *n)); | |
1020 | n->name = $3; | |
b34976b6 | 1021 | n->used = FALSE; |
252b5132 RH |
1022 | n->next = $1; |
1023 | $$ = n; | |
1024 | } | |
1025 | ; | |
1026 | ||
1027 | overlay_section: | |
1028 | /* empty */ | |
1029 | | overlay_section | |
1030 | NAME | |
1031 | { | |
1032 | ldlex_script (); | |
1033 | lang_enter_overlay_section ($2); | |
1034 | } | |
1035 | '{' statement_list_opt '}' | |
1036 | { ldlex_popstate (); ldlex_expression (); } | |
1037 | phdr_opt fill_opt | |
1038 | { | |
1039 | ldlex_popstate (); | |
1040 | lang_leave_overlay_section ($9, $8); | |
1041 | } | |
1042 | opt_comma | |
1043 | ; | |
1044 | ||
1045 | phdrs: | |
1046 | PHDRS '{' phdr_list '}' | |
1047 | ; | |
1048 | ||
1049 | phdr_list: | |
1050 | /* empty */ | |
1051 | | phdr_list phdr | |
1052 | ; | |
1053 | ||
1054 | phdr: | |
1055 | NAME { ldlex_expression (); } | |
1056 | phdr_type phdr_qualifiers { ldlex_popstate (); } | |
1057 | ';' | |
1058 | { | |
1059 | lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at, | |
1060 | $4.flags); | |
1061 | } | |
1062 | ; | |
1063 | ||
1064 | phdr_type: | |
1065 | exp | |
1066 | { | |
1067 | $$ = $1; | |
1068 | ||
1069 | if ($1->type.node_class == etree_name | |
1070 | && $1->type.node_code == NAME) | |
1071 | { | |
1072 | const char *s; | |
1073 | unsigned int i; | |
1074 | static const char * const phdr_types[] = | |
1075 | { | |
1076 | "PT_NULL", "PT_LOAD", "PT_DYNAMIC", | |
1077 | "PT_INTERP", "PT_NOTE", "PT_SHLIB", | |
d038301c | 1078 | "PT_PHDR", "PT_TLS" |
252b5132 RH |
1079 | }; |
1080 | ||
1081 | s = $1->name.name; | |
1082 | for (i = 0; | |
1083 | i < sizeof phdr_types / sizeof phdr_types[0]; | |
1084 | i++) | |
1085 | if (strcmp (s, phdr_types[i]) == 0) | |
1086 | { | |
1087 | $$ = exp_intop (i); | |
1088 | break; | |
1089 | } | |
d038301c RM |
1090 | if (i == sizeof phdr_types / sizeof phdr_types[0]) |
1091 | { | |
1092 | if (strcmp (s, "PT_GNU_EH_FRAME") == 0) | |
1093 | $$ = exp_intop (0x6474e550); | |
9ee5e499 JJ |
1094 | else if (strcmp (s, "PT_GNU_STACK") == 0) |
1095 | $$ = exp_intop (0x6474e551); | |
d038301c RM |
1096 | else |
1097 | { | |
1098 | einfo (_("\ | |
1099 | %X%P:%S: unknown phdr type `%s' (try integer literal)\n"), | |
1100 | s); | |
1101 | $$ = exp_intop (0); | |
1102 | } | |
1103 | } | |
252b5132 RH |
1104 | } |
1105 | } | |
1106 | ; | |
1107 | ||
1108 | phdr_qualifiers: | |
1109 | /* empty */ | |
1110 | { | |
1111 | memset (&$$, 0, sizeof (struct phdr_info)); | |
1112 | } | |
1113 | | NAME phdr_val phdr_qualifiers | |
1114 | { | |
1115 | $$ = $3; | |
1116 | if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL) | |
b34976b6 | 1117 | $$.filehdr = TRUE; |
252b5132 | 1118 | else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL) |
b34976b6 | 1119 | $$.phdrs = TRUE; |
252b5132 RH |
1120 | else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL) |
1121 | $$.flags = $2; | |
1122 | else | |
1123 | einfo (_("%X%P:%S: PHDRS syntax error at `%s'\n"), $1); | |
1124 | } | |
1125 | | AT '(' exp ')' phdr_qualifiers | |
1126 | { | |
1127 | $$ = $5; | |
1128 | $$.at = $3; | |
1129 | } | |
1130 | ; | |
1131 | ||
1132 | phdr_val: | |
1133 | /* empty */ | |
1134 | { | |
1135 | $$ = NULL; | |
1136 | } | |
1137 | | '(' exp ')' | |
1138 | { | |
1139 | $$ = $2; | |
1140 | } | |
1141 | ; | |
1142 | ||
55255dae L |
1143 | dynamic_list_file: |
1144 | { | |
1145 | ldlex_version_file (); | |
1146 | PUSH_ERROR (_("dynamic list")); | |
1147 | } | |
1148 | dynamic_list_nodes | |
1149 | { | |
1150 | ldlex_popstate (); | |
1151 | POP_ERROR (); | |
1152 | } | |
1153 | ; | |
1154 | ||
1155 | dynamic_list_nodes: | |
1156 | dynamic_list_node | |
1157 | | dynamic_list_nodes dynamic_list_node | |
1158 | ; | |
1159 | ||
1160 | dynamic_list_node: | |
1161 | '{' dynamic_list_tag '}' ';' | |
1162 | ; | |
1163 | ||
1164 | dynamic_list_tag: | |
1165 | vers_defns ';' | |
1166 | { | |
1167 | lang_append_dynamic_list ($1); | |
1168 | } | |
1169 | ; | |
1170 | ||
252b5132 RH |
1171 | /* This syntax is used within an external version script file. */ |
1172 | ||
1173 | version_script_file: | |
1174 | { | |
1175 | ldlex_version_file (); | |
1176 | PUSH_ERROR (_("VERSION script")); | |
1177 | } | |
1178 | vers_nodes | |
1179 | { | |
1180 | ldlex_popstate (); | |
1181 | POP_ERROR (); | |
1182 | } | |
1183 | ; | |
1184 | ||
1185 | /* This is used within a normal linker script file. */ | |
1186 | ||
1187 | version: | |
1188 | { | |
1189 | ldlex_version_script (); | |
1190 | } | |
1191 | VERSIONK '{' vers_nodes '}' | |
1192 | { | |
1193 | ldlex_popstate (); | |
1194 | } | |
1195 | ; | |
1196 | ||
1197 | vers_nodes: | |
1198 | vers_node | |
1199 | | vers_nodes vers_node | |
1200 | ; | |
1201 | ||
1202 | vers_node: | |
6b9b879a JJ |
1203 | '{' vers_tag '}' ';' |
1204 | { | |
1205 | lang_register_vers_node (NULL, $2, NULL); | |
1206 | } | |
1207 | | VERS_TAG '{' vers_tag '}' ';' | |
252b5132 RH |
1208 | { |
1209 | lang_register_vers_node ($1, $3, NULL); | |
1210 | } | |
1211 | | VERS_TAG '{' vers_tag '}' verdep ';' | |
1212 | { | |
1213 | lang_register_vers_node ($1, $3, $5); | |
1214 | } | |
1215 | ; | |
1216 | ||
1217 | verdep: | |
1218 | VERS_TAG | |
1219 | { | |
1220 | $$ = lang_add_vers_depend (NULL, $1); | |
1221 | } | |
1222 | | verdep VERS_TAG | |
1223 | { | |
1224 | $$ = lang_add_vers_depend ($1, $2); | |
1225 | } | |
1226 | ; | |
1227 | ||
1228 | vers_tag: | |
1229 | /* empty */ | |
1230 | { | |
1231 | $$ = lang_new_vers_node (NULL, NULL); | |
1232 | } | |
1233 | | vers_defns ';' | |
1234 | { | |
1235 | $$ = lang_new_vers_node ($1, NULL); | |
1236 | } | |
1237 | | GLOBAL ':' vers_defns ';' | |
1238 | { | |
1239 | $$ = lang_new_vers_node ($3, NULL); | |
1240 | } | |
1241 | | LOCAL ':' vers_defns ';' | |
1242 | { | |
1243 | $$ = lang_new_vers_node (NULL, $3); | |
1244 | } | |
1245 | | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';' | |
1246 | { | |
1247 | $$ = lang_new_vers_node ($3, $7); | |
1248 | } | |
1249 | ; | |
1250 | ||
1251 | vers_defns: | |
1252 | VERS_IDENTIFIER | |
1253 | { | |
86043bbb MM |
1254 | $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, FALSE); |
1255 | } | |
1256 | | NAME | |
1257 | { | |
1258 | $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, TRUE); | |
252b5132 RH |
1259 | } |
1260 | | vers_defns ';' VERS_IDENTIFIER | |
1261 | { | |
86043bbb MM |
1262 | $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, FALSE); |
1263 | } | |
1264 | | vers_defns ';' NAME | |
1265 | { | |
1266 | $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, TRUE); | |
252b5132 | 1267 | } |
8e23b15d AM |
1268 | | vers_defns ';' EXTERN NAME '{' |
1269 | { | |
1270 | $<name>$ = ldgram_vers_current_lang; | |
1271 | ldgram_vers_current_lang = $4; | |
1272 | } | |
1273 | vers_defns opt_semicolon '}' | |
1274 | { | |
96f8ade5 JJ |
1275 | struct bfd_elf_version_expr *pat; |
1276 | for (pat = $7; pat->next != NULL; pat = pat->next); | |
1277 | pat->next = $1; | |
8e23b15d AM |
1278 | $$ = $7; |
1279 | ldgram_vers_current_lang = $<name>6; | |
1280 | } | |
252b5132 RH |
1281 | | EXTERN NAME '{' |
1282 | { | |
1283 | $<name>$ = ldgram_vers_current_lang; | |
1284 | ldgram_vers_current_lang = $2; | |
1285 | } | |
8e23b15d | 1286 | vers_defns opt_semicolon '}' |
252b5132 | 1287 | { |
e06cae36 | 1288 | $$ = $5; |
252b5132 RH |
1289 | ldgram_vers_current_lang = $<name>4; |
1290 | } | |
96f8ade5 JJ |
1291 | | GLOBAL |
1292 | { | |
86043bbb | 1293 | $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, FALSE); |
96f8ade5 JJ |
1294 | } |
1295 | | vers_defns ';' GLOBAL | |
1296 | { | |
86043bbb | 1297 | $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, FALSE); |
96f8ade5 JJ |
1298 | } |
1299 | | LOCAL | |
1300 | { | |
86043bbb | 1301 | $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, FALSE); |
96f8ade5 JJ |
1302 | } |
1303 | | vers_defns ';' LOCAL | |
1304 | { | |
86043bbb | 1305 | $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, FALSE); |
96f8ade5 JJ |
1306 | } |
1307 | | EXTERN | |
1308 | { | |
86043bbb | 1309 | $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, FALSE); |
96f8ade5 JJ |
1310 | } |
1311 | | vers_defns ';' EXTERN | |
1312 | { | |
86043bbb | 1313 | $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, FALSE); |
96f8ade5 | 1314 | } |
252b5132 RH |
1315 | ; |
1316 | ||
8e23b15d AM |
1317 | opt_semicolon: |
1318 | /* empty */ | |
1319 | | ';' | |
1320 | ; | |
1321 | ||
252b5132 RH |
1322 | %% |
1323 | void | |
d038301c | 1324 | yyerror(arg) |
252b5132 | 1325 | const char *arg; |
d038301c | 1326 | { |
252b5132 RH |
1327 | if (ldfile_assumed_script) |
1328 | einfo (_("%P:%s: file format not recognized; treating as linker script\n"), | |
1329 | ldfile_input_filename); | |
1330 | if (error_index > 0 && error_index < ERROR_NAME_MAX) | |
1331 | einfo ("%P%F:%S: %s in %s\n", arg, error_names[error_index-1]); | |
1332 | else | |
1333 | einfo ("%P%F:%S: %s\n", arg); | |
1334 | } |