X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=binutils%2Fdefparse.y;h=0ad5b5c3fc3fef952ac142bd018fd05f7d201c12;hb=55c144e691ec05a7b8231b5c58dc6d6659a1c4eb;hp=6493c12e0fe5893f6dd88ebcb0762f3b157385c2;hpb=aa820537ead0135a7c38c619039dce8a6fc74ed1;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/defparse.y b/binutils/defparse.y index 6493c12e0f..0ad5b5c3fc 100644 --- a/binutils/defparse.y +++ b/binutils/defparse.y @@ -1,20 +1,19 @@ %{ /* defparse.y - parser for .def files */ -/* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2005, 2007 - Free Software Foundation, Inc. - +/* Copyright (C) 1995-2015 Free Software Foundation, Inc. + This file is part of GNU Binutils. - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, @@ -28,6 +27,7 @@ %union { char *id; + const char *id_const; int number; }; @@ -35,11 +35,13 @@ %token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT %token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE %token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL +%token EQUAL %token ID %token NUMBER %type opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE %type attr attr_list opt_number -%type opt_name opt_equal_name +%type opt_name opt_name2 opt_equal_name opt_import_name +%type keyword_as_name %% @@ -47,10 +49,10 @@ start: start command | command ; -command: +command: NAME opt_name opt_base { def_name ($2, $3); } | LIBRARY opt_name opt_base option_list { def_library ($2, $3); } - | EXPORTS explist + | EXPORTS explist | DESCRIPTION ID { def_description ($2);} | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);} | HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);} @@ -70,22 +72,31 @@ explist: expline: ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE - { def_exports ($1, $2, $3, $4, $5, $6, $7);} + opt_import_name + { def_exports ($1, $2, $3, $4, $5, $6, $7, $8);} ; -implist: +implist: implist impline | impline ; impline: - ID '=' ID '.' ID '.' ID { def_import ($1,$3,$5,$7, 0); } - | ID '=' ID '.' ID '.' NUMBER { def_import ($1,$3,$5, 0,$7); } - | ID '=' ID '.' ID { def_import ($1,$3, 0,$5, 0); } - | ID '=' ID '.' NUMBER { def_import ($1,$3, 0, 0,$5); } - | ID '.' ID '.' ID { def_import ( 0,$1,$3,$5, 0); } - | ID '.' ID '.' NUMBER { def_import ( 0,$1,$3, 0,$5); } - | ID '.' ID { def_import ( 0,$1, 0,$3, 0); } - | ID '.' NUMBER { def_import ( 0,$1, 0, 0,$3); } + ID '=' ID '.' ID '.' ID opt_import_name + { def_import ($1,$3,$5,$7, 0, $8); } + | ID '=' ID '.' ID '.' NUMBER opt_import_name + { def_import ($1,$3,$5, 0,$7, $8); } + | ID '=' ID '.' ID opt_import_name + { def_import ($1,$3, 0,$5, 0, $6); } + | ID '=' ID '.' NUMBER opt_import_name + { def_import ($1,$3, 0, 0,$5, $6); } + | ID '.' ID '.' ID opt_import_name + { def_import ( 0,$1,$3,$5, 0, $6); } + | ID '.' ID '.' NUMBER opt_import_name + { def_import ( 0,$1,$3, 0,$5, $6); } + | ID '.' ID opt_import_name + { def_import ( 0,$1, 0,$3, 0, $4); } + | ID '.' NUMBER opt_import_name + { def_import ( 0,$1, 0, 0,$3, $4); } ; seclist: @@ -104,12 +115,12 @@ attr_list: opt_comma: ',' - | + | ; opt_number: ',' NUMBER { $$=$2;} | { $$=-1;} ; - + attr: READ { $$ = 1; } | WRITE { $$ = 2; } @@ -140,30 +151,80 @@ opt_PRIVATE: | { $$ = 0; } ; -opt_name: ID { $$ =$1; } - | ID '.' ID - { +keyword_as_name: NAME { $$ = "NAME"; } +/* Disabled LIBRARY keyword for a quirk in libtool. It places LIBRARY + command after EXPORTS list, which is illegal by specification. + See PR binutils/13710 + | LIBRARY { $$ = "LIBRARY"; } */ + | DESCRIPTION { $$ = "DESCRIPTION"; } + | STACKSIZE { $$ = "STACKSIZE"; } + | HEAPSIZE { $$ = "HEAPSIZE"; } + | CODE { $$ = "CODE"; } + | DATA { $$ = "DATA"; } + | SECTIONS { $$ = "SECTIONS"; } + | EXPORTS { $$ = "EXPORTS"; } + | IMPORTS { $$ = "IMPORTS"; } + | VERSIONK { $$ = "VERSION"; } + | BASE { $$ = "BASE"; } + | CONSTANT { $$ = "CONSTANT"; } + | NONAME { $$ = "NONAME"; } + | PRIVATE { $$ = "PRIVATE"; } + | READ { $$ = "READ"; } + | WRITE { $$ = "WRITE"; } + | EXECUTE { $$ = "EXECUTE"; } + | SHARED { $$ = "SHARED"; } + | NONSHARED { $$ = "NONSHARED"; } + | SINGLE { $$ = "SINGLE"; } + | MULTIPLE { $$ = "MULTIPLE"; } + | INITINSTANCE { $$ = "INITINSTANCE"; } + | INITGLOBAL { $$ = "INITGLOBAL"; } + | TERMINSTANCE { $$ = "TERMINSTANCE"; } + | TERMGLOBAL { $$ = "TERMGLOBAL"; } + ; + +opt_name2: ID { $$ = $1; } + | '.' keyword_as_name + { + char *name = xmalloc (strlen ($2) + 2); + sprintf (name, ".%s", $2); + $$ = name; + } + | '.' opt_name2 + { + char *name = xmalloc (strlen ($2) + 2); + sprintf (name, ".%s", $2); + $$ = name; + } + | keyword_as_name '.' opt_name2 + { char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1); sprintf (name, "%s.%s", $1, $3); $$ = name; } + | ID '.' opt_name2 + { + char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1); + sprintf (name, "%s.%s", $1, $3); + $$ = name; + } + ; +opt_name: opt_name2 { $$ =$1; } | { $$=""; } ; -opt_ordinal: +opt_ordinal: '@' NUMBER { $$=$2;} | { $$=-1;} ; +opt_import_name: + EQUAL opt_name2 { $$ = $2; } + | { $$ = 0; } + ; + opt_equal_name: - '=' ID { $$ = $2; } - | '=' ID '.' ID - { - char *name = xmalloc (strlen ($2) + 1 + strlen ($4) + 1); - sprintf (name, "%s.%s", $2, $4); - $$ = name; - } - | { $$ = 0; } + '=' opt_name2 { $$ = $2; } + | { $$ = 0; } ; opt_base: BASE '=' NUMBER { $$= $3;}