|
|
8a8cfb |
commit 2a764c6ee848dfe92cb2921ed3b14085f15d9e79
|
|
|
8a8cfb |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
8a8cfb |
Date: Thu Oct 31 13:23:06 2019 +0100
|
|
|
8a8cfb |
|
|
|
8a8cfb |
Enhance _dl_catch_exception to allow disabling exception handling
|
|
|
8a8cfb |
|
|
|
8a8cfb |
In some cases, it is necessary to introduce noexcept regions
|
|
|
8a8cfb |
where raised dynamic loader exceptions (e.g., from lazy binding)
|
|
|
8a8cfb |
are fatal, despite being nested in a code region with an active
|
|
|
8a8cfb |
exception handler. This change enhances _dl_catch_exception with
|
|
|
8a8cfb |
to provide such a capability. The existing function is reused,
|
|
|
8a8cfb |
so that it is not necessary to introduce yet another function with
|
|
|
8a8cfb |
a similar purpose.
|
|
|
8a8cfb |
|
|
|
8a8cfb |
Change-Id: Iec1bf642ff95a349fdde8040e9baf851ac7b8904
|
|
|
8a8cfb |
|
|
|
8a8cfb |
diff --git a/elf/dl-error-skeleton.c b/elf/dl-error-skeleton.c
|
|
|
8a8cfb |
index d5f418ab1848f0c4..9cb002ccfed2c7b4 100644
|
|
|
8a8cfb |
--- a/elf/dl-error-skeleton.c
|
|
|
8a8cfb |
+++ b/elf/dl-error-skeleton.c
|
|
|
8a8cfb |
@@ -173,6 +173,18 @@ int
|
|
|
8a8cfb |
_dl_catch_exception (struct dl_exception *exception,
|
|
|
8a8cfb |
void (*operate) (void *), void *args)
|
|
|
8a8cfb |
{
|
|
|
8a8cfb |
+ /* If exception is NULL, temporarily disable exception handling.
|
|
|
8a8cfb |
+ Exceptions during operate (args) are fatal. */
|
|
|
8a8cfb |
+ if (exception == NULL)
|
|
|
8a8cfb |
+ {
|
|
|
8a8cfb |
+ struct catch *const old = catch_hook;
|
|
|
8a8cfb |
+ catch_hook = NULL;
|
|
|
8a8cfb |
+ operate (args);
|
|
|
8a8cfb |
+ /* If we get here, the operation was successful. */
|
|
|
8a8cfb |
+ catch_hook = old;
|
|
|
8a8cfb |
+ return 0;
|
|
|
8a8cfb |
+ }
|
|
|
8a8cfb |
+
|
|
|
8a8cfb |
/* We need not handle `receiver' since setting a `catch' is handled
|
|
|
8a8cfb |
before it. */
|
|
|
8a8cfb |
|
|
|
8a8cfb |
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
|
|
8a8cfb |
index 95dc87519b80e0ec..cc2484033fe0d902 100644
|
|
|
8a8cfb |
--- a/sysdeps/generic/ldsodefs.h
|
|
|
8a8cfb |
+++ b/sysdeps/generic/ldsodefs.h
|
|
|
8a8cfb |
@@ -852,7 +852,9 @@ libc_hidden_proto (_dl_catch_error)
|
|
|
8a8cfb |
|
|
|
8a8cfb |
/* Call OPERATE (ARGS). If no error occurs, set *EXCEPTION to zero.
|
|
|
8a8cfb |
Otherwise, store a copy of the raised exception in *EXCEPTION,
|
|
|
8a8cfb |
- which has to be freed by _dl_exception_free. */
|
|
|
8a8cfb |
+ which has to be freed by _dl_exception_free. As a special case, if
|
|
|
8a8cfb |
+ EXCEPTION is null, call OPERATE (ARGS) with exception handling
|
|
|
8a8cfb |
+ disabled (so that exceptions are fatal). */
|
|
|
8a8cfb |
int _dl_catch_exception (struct dl_exception *exception,
|
|
|
8a8cfb |
void (*operate) (void *), void *args);
|
|
|
8a8cfb |
libc_hidden_proto (_dl_catch_exception)
|