1 From df010caac3b33b1d38b6d67024091854c3f77c77 Mon Sep 17 00:00:00 2001
2 From: "H.J. Lu" <hjl.tools@gmail.com>
3 Date: Mon, 24 Jun 2019 11:08:40 -0700
4 Subject: [PATCH] elf: Remove the property after reporting its removal
6 commit d2ef37ebd9f771d06edf1fdea37970f60b242b2d
7 Author: H.J. Lu <hjl.tools@gmail.com>
8 Date: Fri Dec 7 08:30:30 2018 -0800
10 elf: Report property change when merging properties
12 failed to remove the property after reporting it has been removed. This
18 * elf-properties.c (elf_merge_gnu_property_list): Remove the
19 property after reporting property removal.
24 * testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests.
25 * testsuite/ld-x86-64/pr24721-x32.d: New file.
26 * testsuite/ld-x86-64/pr24721.d: Likewise.
27 * testsuite/ld-x86-64/pr24721.map: Likewise.
28 * testsuite/ld-x86-64/pr24721a.s: Likewise.
29 * testsuite/ld-x86-64/pr24721b.s: Likewise.
31 (cherry picked from commit f93ab3a0b8039a1667a666f013cca50b03d67f9b)
33 bfd/ChangeLog | 6 ++++++
34 bfd/elf-properties.c | 10 ++++------
35 ld/ChangeLog | 10 ++++++++++
36 ld/testsuite/ld-x86-64/pr24721-x32.d | 6 ++++++
37 ld/testsuite/ld-x86-64/pr24721.d | 6 ++++++
38 ld/testsuite/ld-x86-64/pr24721.map | 3 +++
39 ld/testsuite/ld-x86-64/pr24721a.s | 34 ++++++++++++++++++++++++++++++++++
40 ld/testsuite/ld-x86-64/pr24721b.s | 6 ++++++
41 ld/testsuite/ld-x86-64/x86-64.exp | 2 ++
42 9 files changed, 77 insertions(+), 6 deletions(-)
43 create mode 100644 ld/testsuite/ld-x86-64/pr24721-x32.d
44 create mode 100644 ld/testsuite/ld-x86-64/pr24721.d
45 create mode 100644 ld/testsuite/ld-x86-64/pr24721.map
46 create mode 100644 ld/testsuite/ld-x86-64/pr24721a.s
47 create mode 100644 ld/testsuite/ld-x86-64/pr24721b.s
49 diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c
50 index 5e48d75..4a9907f 100644
51 --- a/bfd/elf-properties.c
52 +++ b/bfd/elf-properties.c
53 @@ -322,12 +322,10 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd,
54 (bfd_vma) p->property.pr_type, first_pbfd, abfd);
59 - /* Remove this property. */
64 + /* Remove this property. */
70 diff --git a/ld/testsuite/ld-x86-64/pr24721-x32.d b/ld/testsuite/ld-x86-64/pr24721-x32.d
72 index 0000000..9b067ef
74 +++ b/ld/testsuite/ld-x86-64/pr24721-x32.d
78 +#as: --x32 -mx86-used-note=no
79 +#ld: -r -m elf32_x86_64 -Map tmpdir/pr24721.map
82 diff --git a/ld/testsuite/ld-x86-64/pr24721.d b/ld/testsuite/ld-x86-64/pr24721.d
84 index 0000000..efa88db
86 +++ b/ld/testsuite/ld-x86-64/pr24721.d
90 +#as: --64 -defsym __64_bit__=1 -mx86-used-note=no
91 +#ld: -r -melf_x86_64 -Map tmpdir/pr24721.map
94 diff --git a/ld/testsuite/ld-x86-64/pr24721.map b/ld/testsuite/ld-x86-64/pr24721.map
96 index 0000000..9e63fff
98 +++ b/ld/testsuite/ld-x86-64/pr24721.map
101 +Removed property 0xc0000002 to merge tmpdir/pr24721a.o \(0x1\) and tmpdir/pr24721b.o \(not found\)
103 diff --git a/ld/testsuite/ld-x86-64/pr24721a.s b/ld/testsuite/ld-x86-64/pr24721a.s
105 index 0000000..b229d19
107 +++ b/ld/testsuite/ld-x86-64/pr24721a.s
111 + .type foo,@function
116 + .section ".note.gnu.property", "a"
122 + .long 1f - 0f /* name length */
123 + .long 5f - 2f /* data length */
124 + .long 5 /* note type */
125 +0: .asciz "GNU" /* vendor name */
132 +2: .long 0xc0000002 /* pr_type. */
133 + .long 4f - 3f /* pr_datasz. */
143 diff --git a/ld/testsuite/ld-x86-64/pr24721b.s b/ld/testsuite/ld-x86-64/pr24721b.s
145 index 0000000..3d11691
147 +++ b/ld/testsuite/ld-x86-64/pr24721b.s
151 + .type bar,@function
155 diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
156 index 9a76486..707ab89 100644
157 --- a/ld/testsuite/ld-x86-64/x86-64.exp
158 +++ b/ld/testsuite/ld-x86-64/x86-64.exp
159 @@ -432,6 +432,8 @@ run_dump_test "pr24458b"
160 run_dump_test "pr23854"
161 run_dump_test "pr23930"
162 run_dump_test "pr23930-x32"
163 +run_dump_test "pr24721"
164 +run_dump_test "pr24721-x32"
166 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {