This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch ld]: Fix def-file-parser for x64 about BASE-address scalar-width


Hello,

this patch fixes an issue noticed recently for x64 Windows targets.
The base-address is of kind bfd_vma, but was treated always as 32-bit
scalar-interger, which caused on 64-bit targets truncation of the
specified base-address.

ChangeLog

2013-01-25  Kai Tietz

        * deffilep.y (def_image_name): Adjust type of base-address argument.
        (%union): Add new type bfd_vma as vma.
        (VMA):  New rule.
        (opt_base): Use VMA instead of NUMBER rule to evaluate value.
        (def_file_print): Use bfd's fprintf_vma to output base-address.

Tested for i686-w64-mingw32, x86_64-w64-mingw32.  Ok for apply?

Regards,
Kai

Index: deffilep.y
===================================================================
RCS file: /cvs/src/src/ld/deffilep.y,v
retrieving revision 1.41
diff -p -u -r1.41 deffilep.y
--- deffilep.y  10 Jan 2013 20:08:02 -0000      1.41
+++ deffilep.y  25 Jan 2013 11:24:16 -0000
@@ -94,7 +94,7 @@ static void def_exports (const char *, c
 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 +115,7 @@ static const char *lex_parse_string_end
   char *id;
   const char *id_const;
   int number;
+  bfd_vma vma;
   char *digits;
 };

@@ -125,8 +126,9 @@ static const char *lex_parse_string_end
 %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 +314,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 +342,8 @@ opt_id: ID          { $$ = $1; }
        ;

 NUMBER: DIGITS         { $$ = strtoul ($1, 0, 0); }
+       ;
+VMA: DIGITS            { $$ = (bfd_vma) strtoull ($1, 0, 0); }

 %%

@@ -509,7 +513,11 @@ def_file_print (FILE *file, def_file *fd
   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)
@@ -946,7 +954,7 @@ def_file_add_directive (def_file *my_def
 /* 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 is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]