elf: Remove the property after reporting its removal
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 24 Jun 2019 18:08:40 +0000 (11:08 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 24 Jun 2019 18:08:57 +0000 (11:08 -0700)
commit d2ef37ebd9f771d06edf1fdea37970f60b242b2d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Dec 7 08:30:30 2018 -0800

    elf: Report property change when merging properties

failed to remove the property after reporting it has been removed.  This
patch corrects it.

bfd/

PR ld/24721
* elf-properties.c (elf_merge_gnu_property_list): Remove the
property after reporting property removal.

ld/

PR ld/24721
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests.
* testsuite/ld-x86-64/pr24721-x32.d: New file.
* testsuite/ld-x86-64/pr24721.d: Likewise.
* testsuite/ld-x86-64/pr24721.map: Likewise.
* testsuite/ld-x86-64/pr24721a.s: Likewise.
* testsuite/ld-x86-64/pr24721b.s: Likewise.

bfd/ChangeLog
bfd/elf-properties.c
ld/ChangeLog
ld/testsuite/ld-x86-64/pr24721-x32.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr24721.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr24721.map [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr24721a.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr24721b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 0914e7d633642bc6d102b959755eb8f6ac69592f..ec272a873131f95f79b1527a316691496bba3dbc 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/24721
+       * elf-properties.c (elf_merge_gnu_property_list): Remove the
+       property after reporting property removal.
+
 2019-06-23  Alan Modra  <amodra@gmail.com>
 
        PR 24704
index 94ef2351cb632828c66127907137e7d523cb719d..a297c9c5c24f291e1f0259551149f99eb08d9a59 100644 (file)
@@ -322,12 +322,10 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd,
                         (bfd_vma) p->property.pr_type, first_pbfd, abfd);
                  }
              }
-           else
-             {
-               /* Remove this property.  */
-               *lastp = p->next;
-               continue;
-             }
+
+           /* Remove this property.  */
+           *lastp = p->next;
+           continue;
          }
        else if (number_p)
          {
index 6dcfe30696836eba186cb9bd4d01c69972aaa3a2..2c11a66c5c5af52cf65254ae53674d0f752ca49d 100644 (file)
@@ -1,3 +1,13 @@
+2019-06-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/24721
+       * testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests.
+       * testsuite/ld-x86-64/pr24721-x32.d: New file.
+       * testsuite/ld-x86-64/pr24721.d: Likewise.
+       * testsuite/ld-x86-64/pr24721.map: Likewise.
+       * testsuite/ld-x86-64/pr24721a.s: Likewise.
+       * testsuite/ld-x86-64/pr24721b.s: Likewise.
+
 2019-06-23  Alan Modra  <amodra@gmail.com>
 
        PR 24704
diff --git a/ld/testsuite/ld-x86-64/pr24721-x32.d b/ld/testsuite/ld-x86-64/pr24721-x32.d
new file mode 100644 (file)
index 0000000..9b067ef
--- /dev/null
@@ -0,0 +1,6 @@
+#source: pr24721a.s
+#source: pr24721b.s
+#as: --x32 -mx86-used-note=no
+#ld: -r -m elf32_x86_64 -Map tmpdir/pr24721.map
+#readelf: -n
+#map: pr24721.map
diff --git a/ld/testsuite/ld-x86-64/pr24721.d b/ld/testsuite/ld-x86-64/pr24721.d
new file mode 100644 (file)
index 0000000..efa88db
--- /dev/null
@@ -0,0 +1,6 @@
+#source: pr24721a.s
+#source: pr24721b.s
+#as: --64 -defsym __64_bit__=1 -mx86-used-note=no
+#ld: -r -melf_x86_64 -Map tmpdir/pr24721.map
+#readelf: -n
+#map: pr24721.map
diff --git a/ld/testsuite/ld-x86-64/pr24721.map b/ld/testsuite/ld-x86-64/pr24721.map
new file mode 100644 (file)
index 0000000..9e63fff
--- /dev/null
@@ -0,0 +1,3 @@
+#...
+Removed property 0xc0000002 to merge tmpdir/pr24721a.o \(0x1\) and tmpdir/pr24721b.o \(not found\)
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr24721a.s b/ld/testsuite/ld-x86-64/pr24721a.s
new file mode 100644 (file)
index 0000000..b229d19
--- /dev/null
@@ -0,0 +1,34 @@
+       .text
+       .globl foo
+       .type foo,@function
+       .p2align 4
+foo:
+       ret
+
+       .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+       .p2align 3
+.else
+       .p2align 2
+.endif
+       .long 1f - 0f           /* name length */
+       .long 5f - 2f           /* data length */
+       .long 5                 /* note type */
+0:     .asciz "GNU"            /* vendor name */
+1:
+.ifdef __64_bit__
+       .p2align 3
+.else
+       .p2align 2
+.endif
+2:     .long 0xc0000002        /* pr_type.  */
+       .long 4f - 3f           /* pr_datasz.  */
+3:
+       .long 0x1
+4:
+.ifdef __64_bit__
+       .p2align 3
+.else
+       .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-x86-64/pr24721b.s b/ld/testsuite/ld-x86-64/pr24721b.s
new file mode 100644 (file)
index 0000000..3d11691
--- /dev/null
@@ -0,0 +1,6 @@
+       .text
+       .globl bar
+       .type bar,@function
+       .p2align 4
+bar:
+       ret
index 23f202017cadf7378d9e2d411ed4ab1fdca78c94..d815e5d633cc1b8f95336d8f3b89d487a8405ec7 100644 (file)
@@ -456,6 +456,8 @@ run_dump_test "pr24458b"
 run_dump_test "pr24458b-x32"
 run_dump_test "pr24458c"
 run_dump_test "pr24458c-x32"
+run_dump_test "pr24721"
+run_dump_test "pr24721-x32"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return