diff mbox

PR dynamic-link/17711: copy relocations against protected symbols don't work

Message ID 20150227212418.GA5072@intel.com
State New
Headers show

Commit Message

H.J. Lu Feb. 27, 2015, 9:24 p.m. UTC
Protocted symbol in shared library can only be accessed from PIE
or shared library.  Linker in binutils 2.26 enforces it.  We must
compile vismain with -fPIE and link it with -pie.  OK for master?

Thanks.


H.J.
---
	PR dynamic-link/17711
	* elf/Makefile (tests): Add vismain only if PIE is enabled.
	(tests-pie): Add vismain.
	(CFLAGS-vismain.c): New.
---
 elf/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Roland McGrath Feb. 27, 2015, 9:35 p.m. UTC | #1
> Protocted symbol in shared library can only be accessed from PIE
> or shared library.  Linker in binutils 2.26 enforces it.  We must
> compile vismain with -fPIE and link it with -pie.  OK for master?

Add some comments (in vismain.c is probably fine) explaining that it must
be a PIE and why.

> 	PR dynamic-link/17711
	[BZ #17711]

> 	* elf/Makefile (tests): Add vismain only if PIE is enabled.
> 	(tests-pie): Add vismain.
> 	(CFLAGS-vismain.c): New.
Rich Felker Feb. 28, 2015, 1:41 a.m. UTC | #2
On Fri, Feb 27, 2015 at 01:24:19PM -0800, H.J. Lu wrote:
> Protocted symbol in shared library can only be accessed from PIE
> or shared library.  Linker in binutils 2.26 enforces it.  We must
> compile vismain with -fPIE and link it with -pie.  OK for master?

This is a bug in GCC. It's ignoring the fact that copy relocations are
an implementation detail and don't carry a semantic of symbol
replacement, and it makes protected visibility basically unusable. :(

Rich
diff mbox

Patch

diff --git a/elf/Makefile b/elf/Makefile
index f78642e..20b1682 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -130,7 +130,7 @@  endif
 tests += $(tests-static)
 ifeq (yes,$(build-shared))
 tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
-	 constload1 order vismain noload filter unload \
+	 constload1 order noload filter unload \
 	 reldep reldep2 reldep3 reldep4 nodelete nodelete2 \
 	 nodlopen nodlopen2 neededtest neededtest2 \
 	 neededtest3 neededtest4 unload2 lateglobal initfirst global \
@@ -218,6 +218,9 @@  ifeq (yesyes,$(have-fpie)$(build-shared))
 modules-names += tst-piemod1
 tests += tst-pie1 tst-pie2
 tests-pie += tst-pie1 tst-pie2
+tests += vismain
+tests-pie += vismain
+CFLAGS-vismain.c = $(PIE-ccflag)
 endif
 modules-execstack-yes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))