Do not use IFUNC resolver with potentially unrelocated symbol.
Commit Message
We got some error when upgrading glibc.
https://bugs.chromium.org/p/chromium/issues/detail?id=676693
With the patch below, it fixes the problem.
This does the similar fix from
commit f06f3f05b48c72e2c9b0fa78671f94fd22d67da8
to fix the issue for longjmp.
---
nptl/pt-longjmp.c | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
--
2.8.0.rc3.226.g39d4020
Comments
On 12/27/2016 10:59 PM, Yunlian Jiang wrote:
> We got some error when upgrading glibc.
> https://bugs.chromium.org/p/chromium/issues/detail?id=676693
>
> With the patch below, it fixes the problem.
Thanks. Is the patch covered by Google's copyright assignment for glibc?
Florian
Yes, this is covered by Google's copyright assignment.
Below is the ChangeLog, I put another copy of changelog in the attachment.
Thanks,
2016-12-18 Yunlian Jiang <yunlian@google.com>
Do not use IFUNC resolver with potentially unrelocated symbol.
* nptl/pt-longjmp.c [HAVE_IFUNC]: Remove.
(DEFINE_LONGJMP): Remove macro and inline definition.
(longjmp_alias): Renamed from longjmp_ifunc
(siglongjmp_alias): Renamed from siglongjmp_ifunc.
On Wed, Dec 28, 2016 at 4:51 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 12/27/2016 10:59 PM, Yunlian Jiang wrote:
>>
>> We got some error when upgrading glibc.
>> https://bugs.chromium.org/p/chromium/issues/detail?id=676693
>>
>> With the patch below, it fixes the problem.
>
>
> Thanks. Is the patch covered by Google's copyright assignment for glibc?
>
> Florian
@@ -25,21 +25,14 @@
symbol in libpthread, but the historical ABI requires it. For static
linking, there is no need to provide anything here--the libc version
will be linked in. For shared library ABI compatibility, there must be
- longjmp and siglongjmp symbols in libpthread.so; so we define them using
- IFUNC to redirect to the libc function. */
+ longjmp and siglongjmp symbols in libpthread.so.
-#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)
-
-# if HAVE_IFUNC
-
-# undef INIT_ARCH
-# define INIT_ARCH()
-# define DEFINE_LONGJMP(name) libc_ifunc (name, &__libc_longjmp)
-
-extern __typeof(longjmp) longjmp_ifunc;
-extern __typeof(siglongjmp) siglongjmp_ifunc;
+ With an IFUNC resolver, it would be possible to avoid the
+ indirection, but the IFUNC resolver might run before the
+ __libc_longjmp symbol has been relocated, in which case the IFUNC
+ resolver would not be able to provide the correct address. */
-# else /* !HAVE_IFUNC */
+#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)
static void __attribute__ ((noreturn, used))
longjmp_compat (jmp_buf env, int val)
@@ -47,14 +40,10 @@ longjmp_compat (jmp_buf env, int val)
__libc_longjmp (env, val);
}
-# define DEFINE_LONGJMP(name) strong_alias (longjmp_compat, name)
-
-# endif /* HAVE_IFUNC */
-
-DEFINE_LONGJMP (longjmp_ifunc)
-compat_symbol (libpthread, longjmp_ifunc, longjmp, GLIBC_2_0);
+strong_alias (longjmp_compat, longjmp_alias)
+compat_symbol (libpthread, longjmp_alias, longjmp, GLIBC_2_0);
-strong_alias (longjmp_ifunc, siglongjmp_ifunc)
-compat_symbol (libpthread, siglongjmp_ifunc, siglongjmp, GLIBC_2_0);
+strong_alias (longjmp_compat, siglongjmp_alias)
+compat_symbol (libpthread, siglongjmp_alias, siglongjmp, GLIBC_2_0);
#endif