This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR ld/18329: Turn off PROTECTED visibility with -Bsymbolic


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]