public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] PR ld/18329: Turn off PROTECTED visibility with -Bsymbolic
@ 2015-04-25 21:46 H.J. Lu
  2015-04-25 23:46 ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2015-04-25 21:46 UTC (permalink / raw)
  To: binutils

If a global protected symbol is bound locally by -Bsymbolic, there is no
need to keep protected visibility which hich may have overhead at run-time.
OK for master branch?

Thanks.

H.J.
---
bfd/

	PR ld/18329
	* elflink.c (elf_link_output_extsym): Turn off protected
	visibility on locally bound symbol.

ld/testsuite/

	PR ld/18329
	* ld-elf/pr18329.d: New file.
	* ld-elf/pr18329.s: Likewise.
---
 bfd/elflink.c                 |  3 +++
 ld/testsuite/ld-elf/pr18329.d |  8 ++++++++
 ld/testsuite/ld-elf/pr18329.s | 11 +++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 ld/testsuite/ld-elf/pr18329.d
 create mode 100644 ld/testsuite/ld-elf/pr18329.s

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 6efe1e4..9cc5742 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8973,6 +8973,9 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
     sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
   else
     sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
+  if (SYMBOLIC_BIND (flinfo->info, h))
+    /* Turn off protected visibility on locally bound symbol.  */
+    sym.st_other &= ~ELF_ST_VISIBILITY (STV_PROTECTED);
   sym.st_target_internal = h->target_internal;
 
   switch (h->root.type)
diff --git a/ld/testsuite/ld-elf/pr18329.d b/ld/testsuite/ld-elf/pr18329.d
new file mode 100644
index 0000000..6770847
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr18329.d
@@ -0,0 +1,8 @@
+#ld: -shared -Bsymbolic
+#readelf: --wide --dyn-syms
+#target: *-*-linux* *-*-gnu*
+#notarget: cris*-*-elf frv-*-*
+
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +OBJECT +GLOBAL +DEFAULT +[1-9]+ xxxxx
+#pass
diff --git a/ld/testsuite/ld-elf/pr18329.s b/ld/testsuite/ld-elf/pr18329.s
new file mode 100644
index 0000000..27fa2d0
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr18329.s
@@ -0,0 +1,11 @@
+	.text
+	.globl	bar
+	.type	bar, %function
+bar:
+	.dc.a xxxxx
+	.data
+	.globl xxxxx
+	.type   xxxxx, %object
+	.protected	xxxxx
+xxxxx:
+	.byte 0
-- 
2.1.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-26 13:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-25 21:46 [PATCH] PR ld/18329: Turn off PROTECTED visibility with -Bsymbolic H.J. Lu
2015-04-25 23:46 ` Alan Modra
2015-04-26  0:45   ` H.J. Lu
2015-04-26  1:48     ` Alan Modra
2015-04-26 13:38       ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).