Package: binutils / 2.31.1-16

pr24276.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

Skip symbol defined by linker when checking copy reloc on protected
symbol.

bfd/

	PR ld/24276
	* elf64-x86-64.c (elf_x86_64_check_relocs): Skip symbol defined
	by linker when checking copy reloc on protected symbol.

ld/

	PR ld/24276
	* testsuite/ld-i386/i386.exp: Run PR ld/24276 test.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr24276.dso: New file.
	* testsuite/ld-i386/pr24276.warn: Likewise.
	* testsuite/ld-x86-64/pr24276.dso: Likewise.
	* testsuite/ld-x86-64/pr24276.warn: Likewise.
---
 bfd/elf64-x86-64.c                  | 2 ++
 ld/testsuite/ld-i386/i386.exp       | 9 +++++++++
 ld/testsuite/ld-i386/pr24276.dso    | 9 +++++++++
 ld/testsuite/ld-i386/pr24276.warn   | 1 +
 ld/testsuite/ld-x86-64/pr24276.dso  | 9 +++++++++
 ld/testsuite/ld-x86-64/pr24276.warn | 1 +
 ld/testsuite/ld-x86-64/x86-64.exp   | 9 +++++++++
 7 files changed, 40 insertions(+)
 create mode 100644 ld/testsuite/ld-i386/pr24276.dso
 create mode 100644 ld/testsuite/ld-i386/pr24276.warn
 create mode 100644 ld/testsuite/ld-x86-64/pr24276.dso
 create mode 100644 ld/testsuite/ld-x86-64/pr24276.warn

diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 6a4b366fdd..e193f44e93 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2238,6 +2238,8 @@ check_pic:
 	      bfd_boolean no_copyreloc_p
 		= (info->nocopyreloc
 		   || (h != NULL
+		       && !h->root.linker_def
+		       && !h->root.ldscript_def
 		       && eh->def_protected
 		       && elf_has_no_copy_on_protected (h->root.u.def.section->owner)));
 	      if ((sec->flags & SEC_ALLOC) != 0
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 5b90362cb0..e51a4c30f6 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -804,6 +804,15 @@ if { [isnative]
 	    {{objdump {-dw} pr19319.dd}} \
 	    "pr19319" \
 	] \
+	[list \
+	    "Build pr24276.so" \
+	    "-shared -nostdlib -nostartfiles \
+	     -Ltmpdir $srcdir/$subdir/pr24276.dso" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr19319b.S } \
+	    {{warning_output pr24276.warn}} \
+	    "pr24276.so" \
+	] \
 	[list \
 	    "Build property 1" \
 	    "" \
diff --git a/ld/testsuite/ld-i386/pr24276.dso b/ld/testsuite/ld-i386/pr24276.dso
new file mode 100644
index 0000000000..9add115e1c
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr24276.dso
@@ -0,0 +1,9 @@
+INPUT(pr19319.so)
+SECTIONS {
+  my_section : {
+    __start_my_section = .;
+    *(my_section);
+    __stop_my_section = .;
+
+  }
+}
diff --git a/ld/testsuite/ld-i386/pr24276.warn b/ld/testsuite/ld-i386/pr24276.warn
new file mode 100644
index 0000000000..5fcfa343c1
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr24276.warn
@@ -0,0 +1 @@
+.*contains output sections.*
diff --git a/ld/testsuite/ld-x86-64/pr24276.dso b/ld/testsuite/ld-x86-64/pr24276.dso
new file mode 100644
index 0000000000..9add115e1c
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24276.dso
@@ -0,0 +1,9 @@
+INPUT(pr19319.so)
+SECTIONS {
+  my_section : {
+    __start_my_section = .;
+    *(my_section);
+    __stop_my_section = .;
+
+  }
+}
diff --git a/ld/testsuite/ld-x86-64/pr24276.warn b/ld/testsuite/ld-x86-64/pr24276.warn
new file mode 100644
index 0000000000..5fcfa343c1
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24276.warn
@@ -0,0 +1 @@
+.*contains output sections.*
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 5eb556515f..b03aaced91 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -940,6 +940,15 @@ if { [isnative] && [which $CC] != 0 } {
 	    {{objdump {-dw} pr19319.dd}} \
 	    "pr19319" \
 	] \
+	[list \
+	    "Build pr24276.so" \
+	    "-shared -nostdlib -nostartfiles \
+	     -Ltmpdir $srcdir/$subdir/pr24276.dso" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr19319b.S } \
+	    {{warning_output pr24276.warn}} \
+	    "pr24276.so" \
+	] \
 	[list \
 	    "Build property 1" \
 	    "" \