aboutsummaryrefslogtreecommitdiff
path: root/ld/ldgram.y
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-02-15 02:11:05 +0000
committerAlan Modra <amodra@gmail.com>2002-02-15 02:11:05 +0000
commit2c382fb6f5499e01ce83c221f4b35f39e5b414f0 (patch)
treec5cf3c67e969823eb990910eeb4f777db60fdb22 /ld/ldgram.y
parentfd96f80fc8159f92a6d80a36ddbcfd274c4ef96a (diff)
downloadbinutils-2c382fb6f5499e01ce83c221f4b35f39e5b414f0.zip
binutils-2c382fb6f5499e01ce83c221f4b35f39e5b414f0.tar.gz
binutils-2c382fb6f5499e01ce83c221f4b35f39e5b414f0.tar.bz2
Support arbitrary length fill patterns.
* ldexp.h (etree_value_type): Add "str" field. (union etree_union): Add "str" to "value" struct. (exp_bigintop): Declare. (exp_get_fill): Declare. * ldexp.c: Include "safe-ctype.h". (exp_intop): Set value.str to NULL. (exp_bigintop): New function. (new_rel): Pass in "str", and set new.str from it. (new_rel_from_section): Set new.str to NULL. (fold_name): Adjust calls to new_rel. (exp_fold_tree): Likewise. (exp_get_fill): New function. * ldgram.y (struct big_int bigint, fill_type *fill): New. (INT): Returns a "bigint". Adjust all code handling INTs. (fill_opt): Returns a "fill". (fill_exp): Split out of fill_opt, use for FILL. * ldlang.h (struct _fill_type): New. (fill_type): Move typedef to ldexp.h. (lang_output_section_statement_type): "fill" is now a pointer. (lang_fill_statement_type): Likewise. (lang_padding_statement_type): Likewise. (lang_add_fill): Now takes a "fill_type *" param. (lang_leave_output_section_statement): Likewise. (lang_do_assignments): Likewise. (lang_size_sections): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. * ldlang.c: Include ldgram.h after ldexp.h. (lang_output_section_statement_lookup): Adjust for fill_type change. (print_fill_statement): Likewise. (print_padding_statement): Likewise. (insert_pad): Now takes a "fill_type *" arg. (size_input_section): Likewise. (lang_size_sections_1): Likewise. (lang_size_sections): Likewise. (lang_do_assignments): Likewise. (lang_add_fill): Likewise. (lang_leave_output_section_statement): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. Adjust all callers of the above function. * ldlex.l: Include ldgram.h after ldexp.h. Allow hex numbers starting with "0X" as well as "0x". Return bigint.str for hex numbers starting with "0x" or "0X", zero bigint.str otherwise. Always use base 16 for numbers starting with "$". * ldmain.c: Include ldgram.h after ldexp.h. * ldwrite.c (build_link_order): Use bfd_data_link_order in place of bfd_fill_link_order. * pe-dll.c: Adjust lang_do_assignments calls. * emultempl/elf32.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/beos.em: Include ldgram.h after ldexp.h, adjust lang_add_assignment call. * emultempl/pe.em: Likewise.
Diffstat (limited to 'ld/ldgram.y')
-rw-r--r--ld/ldgram.y49
1 files changed, 27 insertions, 22 deletions
diff --git a/ld/ldgram.y b/ld/ldgram.y
index 2df9756..655a726 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -1,6 +1,6 @@
/* A YACC grammar to parse a superset of the AT&T linker scripting language.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001 Free Software Foundation, Inc.
+ 2001, 2002 Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
This file is part of GNU ld.
@@ -66,6 +66,12 @@ static int error_index;
%}
%union {
bfd_vma integer;
+ struct big_int
+ {
+ bfd_vma integer;
+ char *str;
+ } bigint;
+ fill_type *fill;
char *name;
const char *cname;
struct wildcard_spec wildcard;
@@ -89,14 +95,14 @@ static int error_index;
%type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
%type <etree> opt_exp_without_type
-%type <integer> fill_opt
+%type <fill> fill_opt fill_exp
%type <name_list> exclude_name_list
%type <wildcard_list> file_NAME_list
%type <name> memspec_opt casesymlist
%type <name> memspec_at_opt
%type <cname> wildcard_name
%type <wildcard> wildcard_spec
-%token <integer> INT
+%token <bigint> INT
%token <name> NAME LNAME
%type <integer> length
%type <phdr> phdr_qualifiers
@@ -230,11 +236,11 @@ mri_script_command:
| ALIAS NAME ',' NAME
{ mri_alias($2,$4,0);}
| ALIAS NAME ',' INT
- { mri_alias($2,0,(int) $4);}
+ { mri_alias ($2, 0, (int) $4.integer); }
| BASE exp
{ mri_base($2); }
- | TRUNCATE INT
- { mri_truncate((unsigned int) $2); }
+ | TRUNCATE INT
+ { mri_truncate ((unsigned int) $2.integer); }
| CASE casesymlist
| EXTERN extern_name_list
| INCLUDE filename
@@ -512,16 +518,12 @@ statement:
| input_section_spec
| length '(' mustbe_exp ')'
{
- lang_add_data((int) $1,$3);
+ lang_add_data ((int) $1, $3);
}
- | FILL '(' mustbe_exp ')'
+ | FILL '(' fill_exp ')'
{
- lang_add_fill
- (exp_get_value_int($3,
- 0,
- "fill value",
- lang_first_phase_enum));
+ lang_add_fill ($3);
}
;
@@ -548,18 +550,21 @@ length:
{ $$ = $1; }
;
-fill_opt:
- '=' mustbe_exp
+fill_exp:
+ mustbe_exp
{
- $$ = exp_get_value_int($2,
- 0,
- "fill value",
- lang_first_phase_enum);
+ $$ = exp_get_fill ($1,
+ 0,
+ "fill value",
+ lang_first_phase_enum);
}
- | { $$ = 0; }
;
-
+fill_opt:
+ '=' fill_exp
+ { $$ = $2; }
+ | { $$ = (fill_type *) 0; }
+ ;
assign_op:
PLUSEQ
@@ -781,7 +786,7 @@ exp :
| DEFINED '(' NAME ')'
{ $$ = exp_nameop(DEFINED, $3); }
| INT
- { $$ = exp_intop($1); }
+ { $$ = exp_bigintop ($1.integer, $1.str); }
| SIZEOF_HEADERS
{ $$ = exp_nameop(SIZEOF_HEADERS,0); }