%union {
char *id;
+ const char *id_const;
int number;
char *digits;
};
%type <digits> opt_digits
%type <number> opt_base opt_ordinal
%type <number> attr attr_list opt_number exp_opt_list exp_opt
-%type <id> opt_name opt_equal_name dot_name anylang_id opt_id
+%type <id> opt_name opt_name2 opt_equal_name anylang_id opt_id
%type <id> opt_equalequal_name
+%type <id_const> keyword_as_name
%%
/* The opt_comma is necessary to support both the usual
DEF file syntax as well as .drectve syntax which
mandates <expsym>,<expoptlist>. */
- dot_name opt_equal_name opt_ordinal opt_comma exp_opt_list opt_comma opt_equalequal_name
+ opt_name2 opt_equal_name opt_ordinal opt_comma exp_opt_list opt_comma opt_equalequal_name
{ def_exports ($1, $2, $3, $5, $7); }
;
exp_opt_list:
| SHARED { $$=8;}
;
-opt_name: ID { $$ = $1; }
- | '.' ID
+
+keyword_as_name: BASE { $$ = "BASE"; }
+ | CODE { $$ = "CODE"; }
+ | CONSTANTU { $$ = "CONSTANT"; }
+ | CONSTANTL { $$ = "constant"; }
+ | DATAU { $$ = "DATA"; }
+ | DATAL { $$ = "data"; }
+ | DESCRIPTION { $$ = "DESCRIPTION"; }
+ | DIRECTIVE { $$ = "DIRECTIVE"; }
+ | EXECUTE { $$ = "EXECUTE"; }
+ | EXPORTS { $$ = "EXPORTS"; }
+ | HEAPSIZE { $$ = "HEAPSIZE"; }
+ | IMPORTS { $$ = "IMPORTS"; }
+/* Disable LIBRARY keyword as valid symbol-name. This is necessary
+ for libtool, which places this command after EXPORTS command.
+ This behavior is illegal by specification, but sadly required by
+ by compatibility reasons.
+ See PR binutils/13710
+ | LIBRARY { $$ = "LIBRARY"; } */
+ | NAME { $$ = "NAME"; }
+ | NONAMEU { $$ = "NONAME"; }
+ | NONAMEL { $$ = "noname"; }
+ | PRIVATEU { $$ = "PRIVATE"; }
+ | PRIVATEL { $$ = "private"; }
+ | READ { $$ = "READ"; }
+ | SHARED { $$ = "SHARED"; }
+ | STACKSIZE_K { $$ = "STACKSIZE"; }
+ | VERSIONK { $$ = "VERSION"; }
+ | WRITE { $$ = "WRITE"; }
+ ;
+
+opt_name2: ID { $$ = $1; }
+ | '.' keyword_as_name
{
+ char *name = xmalloc (strlen ($2) + 2);
+ sprintf (name, ".%s", $2);
+ $$ = name;
+ }
+ | '.' opt_name2
+ {
char *name = def_pool_alloc (strlen ($2) + 2);
sprintf (name, ".%s", $2);
$$ = name;
}
- | ID '.' ID
+ | keyword_as_name '.' opt_name2
+ {
+ char *name = def_pool_alloc (strlen ($1) + 1 + strlen ($3) + 1);
+ sprintf (name, "%s.%s", $1, $3);
+ $$ = name;
+ }
+ | ID '.' opt_name2
{
char *name = def_pool_alloc (strlen ($1) + 1 + strlen ($3) + 1);
sprintf (name, "%s.%s", $1, $3);
$$ = name;
}
+ ;
+
+opt_name: opt_name2 { $$ = $1; }
| { $$ = ""; }
;
;
opt_equal_name:
- '=' dot_name { $$ = $2; }
+ '=' opt_name2 { $$ = $2; }
| { $$ = 0; }
;
| { $$ = -1;}
;
-dot_name: ID { $$ = $1; }
- | '.' ID
- {
- char *name = def_pool_alloc (strlen ($2) + 2);
- sprintf (name, ".%s", $2);
- $$ = name;
- }
- | dot_name '.' ID
- {
- char *name = def_pool_alloc (strlen ($1) + 1 + strlen ($3) + 1);
- sprintf (name, "%s.%s", $1, $3);
- $$ = name;
- }
- ;
-
anylang_id: ID { $$ = $1; }
| '.' ID
{
if (!max)
return 0;
if ((e = cmp_export_elem (b, ex_name, in_name, its_name, ord)) <= 0)
- return 0;
+ {
+ if (!e)
+ *is_ident = 1;
+ return 0;
+ }
if (max == 1)
return 1;
if ((e = cmp_export_elem (b + (max - 1), ex_name, in_name, its_name, ord)) > 0)
return max;
else if (!e || max == 2)
- return max - 1;
+ {
+ if (!e)
+ *is_ident = 1;
+ return max - 1;
+ }
l = 0; r = max - 1;
while (l < r)
{
{
int r;
+ if ((r = are_names_equal (module, (e->module ? e->module->name : NULL))))
+ return r;
if ((r = are_names_equal (ex_name, e->name)) != 0)
return r;
if ((r = are_names_equal (in_name, e->internal_name)) != 0)
return r;
if (ord != e->ordinal)
return (ord < e->ordinal ? -1 : 1);
- return are_names_equal (module, (e->module ? e->module->name : NULL));
+ return 0;
}
/* Search the position of the identical element, or returns the position
if (!max)
return 0;
if ((e = cmp_import_elem (b, ex_name, in_name, module, ord)) <= 0)
- return 0;
+ {
+ if (!e)
+ *is_ident = 1;
+ return 0;
+ }
if (max == 1)
return 1;
if ((e = cmp_import_elem (b + (max - 1), ex_name, in_name, module, ord)) > 0)
return max;
else if (!e || max == 2)
- return max - 1;
+ {
+ if (!e)
+ *is_ident = 1;
+ return max - 1;
+ }
l = 0; r = max - 1;
while (l < r)
{
static void
def_aligncomm (char *str, int align)
{
- def_file_aligncomm *c = xmalloc (sizeof (def_file_aligncomm));
+ def_file_aligncomm *c, *p;
+
+ p = NULL;
+ c = def->aligncomms;
+ while (c != NULL)
+ {
+ int e = strcmp (c->symbol_name, str);
+ if (!e)
+ {
+ /* Not sure if we want to allow here duplicates with
+ different alignments, but for now we keep them. */
+ e = (int) c->alignment - align;
+ if (!e)
+ return;
+ }
+ if (e > 0)
+ break;
+ c = (p = c)->next;
+ }
+ c = xmalloc (sizeof (def_file_aligncomm));
c->symbol_name = xstrdup (str);
c->alignment = (unsigned int) align;
-
- c->next = def->aligncomms;
- def->aligncomms = c;
+ if (!p)
+ {
+ c->next = def->aligncomms;
+ def->aligncomms = c;
+ }
+ else
+ {
+ c->next = p->next;
+ p->next = c;
+ }
}
static int