Message ID | 3C95024E-2059-4D16-B135-EFB4A57D5591@bell.net |
---|---|
State | New |
Headers | show |
On Jul 16 2017, John David Anglin <dave.anglin@bell.net> wrote:
> The most problematic function in this regard is __gmon_start__.
The caller needs to check for NULL before calling it.
Andreas.
On 2017-07-16, at 2:52 PM, Andreas Schwab wrote: > On Jul 16 2017, John David Anglin <dave.anglin@bell.net> wrote: > >> The most problematic function in this regard is __gmon_start__. > > The caller needs to check for NULL before calling it. That's assumed. However, it doesn't work on hppa. The caller has access to a non NULL pointer to a function descriptor. In the typical case with deferred binding, the function pointer is not resolved until _dl_fixup is called. Dave -- John David Anglin dave.anglin@bell.net
On Jul 16 2017, John David Anglin <dave.anglin@bell.net> wrote: > That's assumed. However, it doesn't work on hppa. The caller has access to a non NULL pointer > to a function descriptor. It works well on ia64 and ppc64, why not on hppa? Andreas.
On 2017-07-16, at 5:31 PM, Andreas Schwab wrote: >> That's assumed. However, it doesn't work on hppa. The caller has access to a non NULL pointer >> to a function descriptor. > > It works well on ia64 and ppc64, why not on hppa? 32-bit hppa doesn't have official procedure descriptors (OPDs). Carlos at one time indicated that he wanted to rework binutils elf32-hppa.c to use OPDs but it never happened. As a result, undefined weak symbols are poorly supported. It was a bad design and HP recognized it when they created the 64-bit hppa and ia64 runtimes. The 32-bit hpux linker doesn't support undefined weak symbols at all. We worked around it with one-only support in gcc. Anyway, one compare instruction checking the return of _dl_fixup doesn't affect performance much. It could be removed if the problems with undefined weak functions are resolved. Dave -- John David Anglin dave.anglin@bell.net
This information should be added in a comment. Andreas.
On 07/17/2017 03:10 AM, Andreas Schwab wrote:
> This information should be added in a comment.
Dave, Thanks for all the fixes. I agree with Andreas, this should be
documented with a comment.
On 2017-07-17, at 7:11 AM, Carlos O'Donell wrote: > Dave, Thanks for all the fixes. I agree with Andreas, this should be > documented with a comment. No problem. Probably next weekend. Dave -- John David Anglin dave.anglin@bell.net
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