PR binutils/19935
[deliverable/binutils-gdb.git] / ld / deffilep.y
index cbc171469d467116d1b503a50dd0abd93471d418..ccceed04997ca567f46ac4e4800a6a9a98db2318 100644 (file)
@@ -1,7 +1,6 @@
 %{ /* deffilep.y - parser for .def files */
 
-/*   Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
-     2007, 2009 Free Software Foundation, Inc.
+/*   Copyright (C) 1995-2017 Free Software Foundation, Inc.
 
      This file is part of GNU Binutils.
 
@@ -94,7 +93,7 @@ static void def_exports (const char *, const char *, int, int, const char *);
 static void def_heapsize (int, int);
 static void def_import (const char *, const char *, const char *, const char *,
                        int, const char *);
-static void def_image_name (const char *, int, int);
+static void def_image_name (const char *, bfd_vma, int);
 static void def_section (const char *, int);
 static void def_section_alt (const char *, const char *);
 static void def_stacksize (int, int);
@@ -115,6 +114,7 @@ static const char *lex_parse_string_end = 0;
   char *id;
   const char *id_const;
   int number;
+  bfd_vma vma;
   char *digits;
 };
 
@@ -125,8 +125,9 @@ static const char *lex_parse_string_end = 0;
 %token <id> ID
 %token <digits> DIGITS
 %type  <number> NUMBER
+%type  <vma> VMA opt_base
 %type  <digits> opt_digits
-%type  <number> opt_base opt_ordinal
+%type  <number> opt_ordinal
 %type  <number> attr attr_list opt_number exp_opt_list exp_opt
 %type  <id> opt_name opt_name2 opt_equal_name anylang_id opt_id
 %type  <id> opt_equalequal_name
@@ -312,8 +313,8 @@ opt_equal_name:
         |              { $$ =  0; }
        ;
 
-opt_base: BASE '=' NUMBER      { $$ = $3;}
-       |       { $$ = -1;}
+opt_base: BASE '=' VMA { $$ = $3;}
+       |       { $$ = (bfd_vma) -1;}
        ;
 
 anylang_id: ID         { $$ = $1; }
@@ -340,6 +341,8 @@ opt_id: ID          { $$ = $1; }
        ;
 
 NUMBER: DIGITS         { $$ = strtoul ($1, 0, 0); }
+       ;
+VMA: DIGITS            { $$ = (bfd_vma) strtoull ($1, 0, 0); }
 
 %%
 
@@ -509,7 +512,11 @@ def_file_print (FILE *file, def_file *fdef)
   if (fdef->is_dll != -1)
     fprintf (file, "  is dll: %s\n", fdef->is_dll ? "yes" : "no");
   if (fdef->base_address != (bfd_vma) -1)
-    fprintf (file, "  base address: 0x%08x\n", fdef->base_address);
+    {
+      fprintf (file, "  base address: 0x");
+      fprintf_vma (file, fdef->base_address);
+      fprintf (file, "\n");
+    }
   if (fdef->description)
     fprintf (file, "  description: `%s'\n", fdef->description);
   if (fdef->stack_reserve != -1)
@@ -897,8 +904,8 @@ def_file_add_directive (def_file *my_def, const char *param, int len)
       /* Scan forward until we encounter any of:
           - the end of the buffer
          - the start of a new option
-         - a newline seperating options
-          - a NUL seperating options.  */
+         - a newline separating options
+          - a NUL separating options.  */
       for (tend = (char *) (param + 1);
           (tend < pend
            && !(ISSPACE (tend[-1]) && *tend == '-')
@@ -926,13 +933,20 @@ def_file_add_directive (def_file *my_def, const char *param, int len)
 
       if (!diropts[i].param)
        {
-         char saved;
+         if (tend < pend)
+           {
+             char saved;
 
-         saved = * tend;
-         * tend = 0;
-         /* xgettext:c-format */
-         einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
-         * tend = saved;
+             saved = * tend;
+             * tend = 0;
+             /* xgettext:c-format */
+             einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
+             * tend = saved;
+           }
+         else
+           {
+             einfo (_("Warning: corrupt .drectve at end of def file\n"));
+           }
        }
 
       lex_parse_string = 0;
@@ -946,7 +960,7 @@ def_file_add_directive (def_file *my_def, const char *param, int len)
 /* Parser Callbacks.  */
 
 static void
-def_image_name (const char *name, int base, int is_dll)
+def_image_name (const char *name, bfd_vma base, int is_dll)
 {
   /* If a LIBRARY or NAME statement is specified without a name, there is nothing
      to do here.  We retain the output filename specified on command line.  */
This page took 0.025465 seconds and 4 git commands to generate.