x86: Don't remove empty GNU_PROPERTY_X86_UINT32_OR_AND properties
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 4 Dec 2018 14:00:57 +0000 (06:00 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 4 Dec 2018 14:01:14 +0000 (06:01 -0800)
For GNU_PROPERTY_X86_COMPAT_ISA_1_USED and GNU_PROPERTY_X86_UINT32_OR_AND
properties, a bit in the output pr_data field is set if it is set in any
relocatable input pr_data fields and this property is present in all
relocatable input files.  A missing property implies that its bits have
unknown values.  When all bits in the the output pr_data field are zero,
this property should not be removed from output to indicate it has zero
in all bits.

bfd/

PR ld/23372
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Don't remove
empty properties for GNU_PROPERTY_X86_COMPAT_ISA_1_USED and
GNU_PROPERTY_X86_UINT32_OR_AND.
(_bfd_x86_elf_link_fixup_gnu_properties): Likewise.

ld/

PR ld/23372
* testsuite/ld-i386/pr23372a.d: Updated.
* testsuite/ld-i386/pr23372c.d: Likewise.
* testsuite/ld-x86-64/pr23372a-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372a.d: Likewise.
* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372c.d: Likewise.

bfd/ChangeLog
bfd/elfxx-x86.c
ld/ChangeLog
ld/testsuite/ld-i386/pr23372a.d
ld/testsuite/ld-i386/pr23372c.d
ld/testsuite/ld-x86-64/pr23372a-x32.d
ld/testsuite/ld-x86-64/pr23372a.d
ld/testsuite/ld-x86-64/pr23372c-x32.d
ld/testsuite/ld-x86-64/pr23372c.d

index 30616eb787983533dba87d461cffe8ed9858b67a..618126fffbeb4f485f54bba2e1e523ae84ed44a4 100644 (file)
@@ -1,3 +1,11 @@
+2018-12-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/23372
+       * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Don't remove
+       empty properties for GNU_PROPERTY_X86_COMPAT_ISA_1_USED and
+       GNU_PROPERTY_X86_UINT32_OR_AND.
+       (_bfd_x86_elf_link_fixup_gnu_properties): Likewise.
+
 2018-12-03  Kito Cheng  <kito@andestech.com>
 
        * elfxx-riscv.h (RISCV_DONT_CARE_VERSION): New macro.
index 40aac664f4a060125ecb6b4f540cf64d00ae3cbc..eaa1a82b07aee024b197ac4ecf5ab4cbafec34a6 100644 (file)
@@ -2422,9 +2422,14 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
              aprop->pr_kind = property_remove;
              updated = TRUE;
            }
-         return updated;
        }
-      goto or_property;
+      else
+       {
+         number = aprop->u.number;
+         aprop->u.number = number | bprop->u.number;
+         updated = number != (unsigned int) aprop->u.number;
+       }
+      return updated;
     }
   else if (pr_type == GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED
           || (pr_type >= GNU_PROPERTY_X86_UINT32_OR_LO
@@ -2432,7 +2437,6 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
     {
       if (aprop != NULL && bprop != NULL)
        {
-or_property:
          number = aprop->u.number;
          aprop->u.number = number | bprop->u.number;
          /* Remove the property if all bits are empty.  */
@@ -2957,7 +2961,12 @@ _bfd_x86_elf_link_fixup_gnu_properties (struct bfd_link_info *info,
          || (type >= GNU_PROPERTY_X86_UINT32_OR_AND_LO
              && type <= GNU_PROPERTY_X86_UINT32_OR_AND_HI))
        {
-         if (p->property.u.number == 0)
+         if (p->property.u.number == 0
+             && (type == GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED
+                 || (type >= GNU_PROPERTY_X86_UINT32_AND_LO
+                     && type <= GNU_PROPERTY_X86_UINT32_AND_HI)
+                 || (type >= GNU_PROPERTY_X86_UINT32_OR_LO
+                     && type <= GNU_PROPERTY_X86_UINT32_OR_HI)))
            {
              /* Remove empty property.  */
              *listp = p->next;
index 80fd06c1cae8a3eff5d4375c3c0500712d4d60c4..51382253d6ccbdaf2023a5fe155fb43590ba1387 100644 (file)
@@ -1,3 +1,13 @@
+2018-12-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/23372
+       * testsuite/ld-i386/pr23372a.d: Updated.
+       * testsuite/ld-i386/pr23372c.d: Likewise.
+       * testsuite/ld-x86-64/pr23372a-x32.d: Likewise.
+       * testsuite/ld-x86-64/pr23372a.d: Likewise.
+       * testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
+       * testsuite/ld-x86-64/pr23372c.d: Likewise.
+
 2018-12-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/23930
index b75523bdc381e559d05f2488bbcc4f572f00f3fb..7af7efb06562f7df2a711b59392f539a8a8a6c97 100644 (file)
@@ -3,3 +3,8 @@
 #as: --32
 #ld: -r -m elf_i386
 #readelf: -n
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size      Description
+  GNU                  0x[0-9a-f]+     NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA used: 
index 987ae4cfe54aed1d5af1fa7d6cbad2d95bb67137..d5bcc4d7b2bac65a5d00862e25d2662e4b7f910c 100644 (file)
@@ -3,3 +3,8 @@
 #as: --32
 #ld: -r -m elf_i386
 #readelf: -n
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size      Description
+  GNU                  0x[0-9a-f]+     NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA used: 
index 9f93642364432378d0ec0c2bb2e3487295549113..84e460299418f8037bc373db5db391d5fb6580ee 100644 (file)
@@ -3,3 +3,8 @@
 #as: --x32
 #ld: -r -m elf32_x86_64
 #readelf: -n
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size      Description
+  GNU                  0x[0-9a-f]+     NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA used: 
index ee688fc2e27b818ec2aab9fe6e044170bac4c5d7..d988a6a4cbf6881df51c855a407bf033e3545ac4 100644 (file)
@@ -3,3 +3,8 @@
 #as: --64 -defsym __64_bit__=1
 #ld: -r -m elf_x86_64
 #readelf: -n
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size      Description
+  GNU                  0x[0-9a-f]+     NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA used: 
index 863f4b7e442e54d0c675af78ac3db815fcae44a3..efd6e84aa2268ba5d2e503dac713ef16b7d24ded 100644 (file)
@@ -3,3 +3,8 @@
 #as: --x32
 #ld: -r -m elf32_x86_64
 #readelf: -n
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size      Description
+  GNU                  0x[0-9a-f]+     NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA used: 
index 23bdaa786a7d189f6ed5adcb25cbc35d645559c7..f56859a014f4ae9fcedba280e62fb3a0fbe4c3db 100644 (file)
@@ -3,3 +3,8 @@
 #as: --64 -defsym __64_bit__=1
 #ld: -r -m elf_x86_64
 #readelf: -n
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size      Description
+  GNU                  0x[0-9a-f]+     NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA used: