X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=binutils%2Fdefparse.y;h=c05254a0557497b37febb2f526ec972e28e7899e;hb=8ea5bce59057ef1906bf1180843c0900b191dcab;hp=21b687655986a6923a7e52770076a1e8bfc0eea9;hpb=8eb693acc4a7051f665020456b8e0de59679a8cf;p=binutils-gdb.git diff --git a/binutils/defparse.y b/binutils/defparse.y index 21b68765598..c05254a0557 100644 --- a/binutils/defparse.y +++ b/binutils/defparse.y @@ -1,25 +1,28 @@ %{ /* defparse.y - parser for .def files */ -/* Copyright (C) 1995, 1997 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - +/* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2005, 2007 + 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, + MA 02110-1301, USA. */ + +#include "sysdep.h" #include "bfd.h" -#include "bucomm.h" +#include "libiberty.h" #include "dlltool.h" %} @@ -28,14 +31,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ int number; }; -%token NAME, LIBRARY, DESCRIPTION, STACKSIZE, HEAPSIZE, CODE, DATA -%token SECTIONS, EXPORTS, IMPORTS, VERSION, BASE, CONSTANT -%token READ WRITE EXECUTE SHARED NONAME +%token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA +%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 +%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_equal_name opt_import_name %% @@ -45,7 +50,7 @@ start: start command command: NAME opt_name opt_base { def_name ($2, $3); } - | LIBRARY opt_name opt_base { def_library ($2, $3); } + | LIBRARY opt_name opt_base option_list { def_library ($2, $3); } | EXPORTS explist | DESCRIPTION ID { def_description ($2);} | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);} @@ -54,19 +59,20 @@ command: | DATA attr_list { def_data ($2);} | SECTIONS seclist | IMPORTS implist - | VERSION NUMBER { def_version ($2,0);} - | VERSION NUMBER '.' NUMBER { def_version ($2,$4);} + | VERSIONK NUMBER { def_version ($2,0);} + | VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);} ; explist: - explist expline - | expline + /* EMPTY */ + | explist expline ; expline: - ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA - { def_exports ($1, $2, $3, $4, $5, $6);} + ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE + opt_import_name + { def_exports ($1, $2, $3, $4, $5, $6, $7, $8);} ; implist: implist impline @@ -74,9 +80,24 @@ implist: ; impline: - ID '=' ID '.' ID { def_import ($1,$3,$5);} - | ID '.' ID { def_import (0, $1,$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: seclist secline | secline @@ -100,10 +121,13 @@ opt_number: ',' NUMBER { $$=$2;} ; attr: - READ { $$ = 1;} - | WRITE { $$ = 2;} - | EXECUTE { $$=4;} - | SHARED { $$=8;} + READ { $$ = 1; } + | WRITE { $$ = 2; } + | EXECUTE { $$ = 4; } + | SHARED { $$ = 8; } + | NONSHARED { $$ = 0; } + | SINGLE { $$ = 0; } + | MULTIPLE { $$ = 0; } ; opt_CONSTANT: @@ -121,7 +145,18 @@ opt_DATA: | { $$ = 0; } ; +opt_PRIVATE: + PRIVATE { $$ = 1; } + | { $$ = 0; } + ; + opt_name: ID { $$ =$1; } + | ID '.' ID + { + char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1); + sprintf (name, "%s.%s", $1, $3); + $$ = name; + } | { $$=""; } ; @@ -130,8 +165,19 @@ opt_ordinal: | { $$=-1;} ; +opt_import_name: + EQUAL ID { $$ = $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; } ; @@ -139,5 +185,14 @@ opt_base: BASE '=' NUMBER { $$= $3;} | { $$=-1;} ; - +option_list: + /* empty */ + | option_list opt_comma option + ; +option: + INITINSTANCE + | INITGLOBAL + | TERMINSTANCE + | TERMGLOBAL + ;