138889Sjdp%{ /* defparse.y - parser for .def files */ 233965Sjdp 3218822Sdim/* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2007 4218822Sdim Free Software Foundation, Inc. 533965Sjdp 6218822Sdim This file is part of GNU Binutils. 733965Sjdp 8218822Sdim This program is free software; you can redistribute it and/or modify 9218822Sdim it under the terms of the GNU General Public License as published by 10218822Sdim the Free Software Foundation; either version 2 of the License, or 11218822Sdim (at your option) any later version. 1233965Sjdp 13218822Sdim This program is distributed in the hope that it will be useful, 14218822Sdim but WITHOUT ANY WARRANTY; without even the implied warranty of 15218822Sdim MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16218822Sdim GNU General Public License for more details. 1733965Sjdp 18218822Sdim You should have received a copy of the GNU General Public License 19218822Sdim along with this program; if not, write to the Free Software 20218822Sdim Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 2133965Sjdp 22218822Sdim#include "sysdep.h" 2338889Sjdp#include "bfd.h" 24218822Sdim#include "libiberty.h" 2538889Sjdp#include "dlltool.h" 2638889Sjdp%} 2733965Sjdp 2833965Sjdp%union { 2933965Sjdp char *id; 3033965Sjdp int number; 3133965Sjdp}; 3233965Sjdp 33218822Sdim%token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA 34218822Sdim%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT 35218822Sdim%token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE 3660484Sobrien%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL 3733965Sjdp%token <id> ID 3833965Sjdp%token <number> NUMBER 39218822Sdim%type <number> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE 4038889Sjdp%type <number> attr attr_list opt_number 4133965Sjdp%type <id> opt_name opt_equal_name 4233965Sjdp 4333965Sjdp%% 4433965Sjdp 4533965Sjdpstart: start command 4633965Sjdp | command 4733965Sjdp ; 4833965Sjdp 4933965Sjdpcommand: 5033965Sjdp NAME opt_name opt_base { def_name ($2, $3); } 5160484Sobrien | LIBRARY opt_name opt_base option_list { def_library ($2, $3); } 5233965Sjdp | EXPORTS explist 5333965Sjdp | DESCRIPTION ID { def_description ($2);} 5433965Sjdp | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);} 5533965Sjdp | HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);} 5633965Sjdp | CODE attr_list { def_code ($2);} 5733965Sjdp | DATA attr_list { def_data ($2);} 5833965Sjdp | SECTIONS seclist 5933965Sjdp | IMPORTS implist 6038889Sjdp | VERSIONK NUMBER { def_version ($2,0);} 6138889Sjdp | VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);} 6233965Sjdp ; 6333965Sjdp 6433965Sjdp 6533965Sjdpexplist: 6638889Sjdp /* EMPTY */ 6738889Sjdp | explist expline 6833965Sjdp ; 6933965Sjdp 7033965Sjdpexpline: 71218822Sdim ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE 72218822Sdim { def_exports ($1, $2, $3, $4, $5, $6, $7);} 7333965Sjdp ; 7433965Sjdpimplist: 7533965Sjdp implist impline 7633965Sjdp | impline 7733965Sjdp ; 7833965Sjdp 7933965Sjdpimpline: 8060484Sobrien ID '=' ID '.' ID '.' ID { def_import ($1,$3,$5,$7, 0); } 8160484Sobrien | ID '=' ID '.' ID '.' NUMBER { def_import ($1,$3,$5, 0,$7); } 8260484Sobrien | ID '=' ID '.' ID { def_import ($1,$3, 0,$5, 0); } 8360484Sobrien | ID '=' ID '.' NUMBER { def_import ($1,$3, 0, 0,$5); } 8460484Sobrien | ID '.' ID '.' ID { def_import ( 0,$1,$3,$5, 0); } 8560484Sobrien | ID '.' ID '.' NUMBER { def_import ( 0,$1,$3, 0,$5); } 8660484Sobrien | ID '.' ID { def_import ( 0,$1, 0,$3, 0); } 8760484Sobrien | ID '.' NUMBER { def_import ( 0,$1, 0, 0,$3); } 8860484Sobrien; 8960484Sobrien 9033965Sjdpseclist: 9133965Sjdp seclist secline 9233965Sjdp | secline 9333965Sjdp ; 9433965Sjdp 9533965Sjdpsecline: 9633965Sjdp ID attr_list { def_section ($1,$2);} 9733965Sjdp ; 9833965Sjdp 9933965Sjdpattr_list: 10033965Sjdp attr_list opt_comma attr 10133965Sjdp | attr 10233965Sjdp ; 10333965Sjdp 10433965Sjdpopt_comma: 10533965Sjdp ',' 10633965Sjdp | 10733965Sjdp ; 10833965Sjdpopt_number: ',' NUMBER { $$=$2;} 10933965Sjdp | { $$=-1;} 11033965Sjdp ; 11133965Sjdp 11233965Sjdpattr: 11360484Sobrien READ { $$ = 1; } 11460484Sobrien | WRITE { $$ = 2; } 11560484Sobrien | EXECUTE { $$ = 4; } 11660484Sobrien | SHARED { $$ = 8; } 11760484Sobrien | NONSHARED { $$ = 0; } 11860484Sobrien | SINGLE { $$ = 0; } 11960484Sobrien | MULTIPLE { $$ = 0; } 12033965Sjdp ; 12133965Sjdp 12233965Sjdpopt_CONSTANT: 12333965Sjdp CONSTANT {$$=1;} 12433965Sjdp | {$$=0;} 12533965Sjdp ; 12638889Sjdp 12733965Sjdpopt_NONAME: 12833965Sjdp NONAME {$$=1;} 12933965Sjdp | {$$=0;} 13033965Sjdp ; 13133965Sjdp 13238889Sjdpopt_DATA: 13338889Sjdp DATA { $$ = 1; } 13438889Sjdp | { $$ = 0; } 13538889Sjdp ; 13638889Sjdp 137218822Sdimopt_PRIVATE: 138218822Sdim PRIVATE { $$ = 1; } 139218822Sdim | { $$ = 0; } 140218822Sdim ; 141218822Sdim 14233965Sjdpopt_name: ID { $$ =$1; } 14360484Sobrien | ID '.' ID 14460484Sobrien { 14560484Sobrien char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1); 14660484Sobrien sprintf (name, "%s.%s", $1, $3); 14760484Sobrien $$ = name; 14860484Sobrien } 14933965Sjdp | { $$=""; } 15033965Sjdp ; 15133965Sjdp 15233965Sjdpopt_ordinal: 15333965Sjdp '@' NUMBER { $$=$2;} 15433965Sjdp | { $$=-1;} 15533965Sjdp ; 15633965Sjdp 15733965Sjdpopt_equal_name: 15833965Sjdp '=' ID { $$ = $2; } 15989857Sobrien | '=' ID '.' ID 16089857Sobrien { 16189857Sobrien char *name = xmalloc (strlen ($2) + 1 + strlen ($4) + 1); 16289857Sobrien sprintf (name, "%s.%s", $2, $4); 16389857Sobrien $$ = name; 16489857Sobrien } 16533965Sjdp | { $$ = 0; } 16633965Sjdp ; 16733965Sjdp 16833965Sjdpopt_base: BASE '=' NUMBER { $$= $3;} 16933965Sjdp | { $$=-1;} 17033965Sjdp ; 17133965Sjdp 17260484Sobrienoption_list: 17360484Sobrien /* empty */ 17460484Sobrien | option_list opt_comma option 17560484Sobrien ; 17633965Sjdp 17760484Sobrienoption: 17860484Sobrien INITINSTANCE 17960484Sobrien | INITGLOBAL 18060484Sobrien | TERMINSTANCE 18160484Sobrien | TERMGLOBAL 18260484Sobrien ; 183