]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix generation of IDATA[6] for PE files.
authorRudy Y <rudyy.id@gmail.com>
Thu, 1 Dec 2016 14:43:36 +0000 (14:43 +0000)
committerNick Clifton <nickc@redhat.com>
Thu, 1 Dec 2016 14:43:36 +0000 (14:43 +0000)
PR ld/20880
* pe-dll.c (make_one): Use the hint if the ordinal is -1.

ld/ChangeLog
ld/pe-dll.c

index 446a4afa9a31f20a615dc4659bbfa137dda9a44b..65c2854e9da72523ddadd5ad3412c8f148b282a5 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-01  Rudy Y  <rudyy.id@gmail.com>
+
+       PR ld/20880
+       * pe-dll.c (make_one): Use the hint if the ordinal is -1.
+
 2016-12-01  Yury Norov  <ynorov@caviumnetworks.com>
 
        PR ld/20868
index 055a6cf32c0ef7b873ce8864d367e10ee59d9c97..9d87cd2306a0ed87178f78f75445d1605f435b3f 100644 (file)
@@ -2266,6 +2266,8 @@ make_one (def_file_export *exp, bfd *parent, bfd_boolean include_jmp_stub)
     }
   else
     {
+      int ord;
+
       /* { short, asciz }  */
       if (exp->its_name)
        len = 2 + strlen (exp->its_name) + 1;
@@ -2277,8 +2279,13 @@ make_one (def_file_export *exp, bfd *parent, bfd_boolean include_jmp_stub)
       d6 = xmalloc (len);
       id6->contents = d6;
       memset (d6, 0, len);
-      d6[0] = exp->hint & 0xff;
-      d6[1] = exp->hint >> 8;
+
+      /* PR 20880:  Use exp->hint as a backup, just in case exp->ordinal
+        contains an invalid value (-1).  */
+      ord = (exp->ordinal >= 0) ? exp->ordinal : exp->hint;
+      d6[0] = ord;
+      d6[1] = ord >> 8;
+
       if (exp->its_name)
        strcpy ((char*) d6 + 2, exp->its_name);
       else