public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [committed] Return to caller when _dl_fixup fails on hppa
@ 2017-07-16 17:50 John David Anglin
  2017-07-16 18:53 ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: John David Anglin @ 2017-07-16 17:50 UTC (permalink / raw)
  To: GNU C Library; +Cc: Carlos O'Donell

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

The attached change modifies _dl_runtime_resolve to return to its caller when _dl_fixup
fails.  This can occur on hppa when the caller attempts to call an undefined weak function.
The old code would fault when _dl_fixup fails.

The most problematic function in this regard is __gmon_start__.  Currently, it is linked into
every shared object.  This breaks the --as-needed ld option.

On Debian, we have an additional patch to treat __gmon_start__ as a true weak symbol.
I don't plan to apply this change as it becomes tricky to rebuild a distribution.  Rebuilding
a shared library removes __gmon_start__ and this may break a package using the library.
This isn't a problem after everything is rebuilt.

Dave
--
John David Anglin	dave.anglin@bell.net



[-- Attachment #2: dl-trampoline.S.d.txt --]
[-- Type: text/plain, Size: 989 bytes --]

2017-07-16  John David Anglin  <danglin@gcc.gnu.org>

	* sysdeps/hppa/dl-trampoline.S (_dl_runtime_resolve): Return to caller
	if _dl_fixup fails.

diff --git a/sysdeps/hppa/dl-trampoline.S b/sysdeps/hppa/dl-trampoline.S
index 856339bffe..f1294a931f 100644
--- a/sysdeps/hppa/dl-trampoline.S
+++ b/sysdeps/hppa/dl-trampoline.S
@@ -82,6 +82,11 @@ _dl_runtime_resolve:
 	bl	_dl_fixup,%rp
 	copy	%r21,%r19		/* set fixup func ltp */
 
+	/* Sometimes a final executable may attempt to call an undefined
+	   weak function (e.g., __gmon_start__).  Return if the function
+	   was not resolved by _dl_fixup */
+	comib,=	0,%r28,1f
+
 	/* Load up the returned func descriptor */
 	copy	%r28, %r22
 	copy	%r29, %r19
@@ -107,6 +112,13 @@ _dl_runtime_resolve:
 	/* Jump to new function, but return to previous function */
 	bv	%r0(%r22)
 	ldw	-20(%sp),%rp
+
+1:
+	/* Return to previous function */
+	ldw	-148(%sp),%rp
+	bv	%r0(%rp)
+	ldo	-128(%sp),%sp
+
         .EXIT
         .PROCEND
 	cfi_endproc

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

end of thread, other threads:[~2017-07-23 17:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-16 17:50 [committed] Return to caller when _dl_fixup fails on hppa John David Anglin
2017-07-16 18:53 ` Andreas Schwab
2017-07-16 19:46   ` John David Anglin
2017-07-16 21:31     ` Andreas Schwab
2017-07-16 22:02       ` John David Anglin
2017-07-17  7:10         ` Andreas Schwab
2017-07-17 11:11           ` Carlos O'Donell
2017-07-17 11:52             ` John David Anglin
2017-07-23 23:58             ` John David Anglin

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).