[PATCH v2] aarch64: Fix error messages for GCS and BTI incompatible modules
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Jan 6 14:53:03 GMT 2026
On 06/01/26 08:17, Yury Khrustalev wrote:
> When either program path of module name is empty, don't print an
> empty string followed by a colon.
>
> Also fix-up test for a static BTI binary to check error message
> for this case.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
PS: CCing Andreas to give the final ack to install it.
> ---
> sysdeps/aarch64/Makefile | 1 +
> sysdeps/aarch64/dl-bti.c | 20 +++++++++++++++-----
> sysdeps/aarch64/dl-gcs.c | 19 ++++++++++++++-----
> sysdeps/aarch64/tst-bti-abort-static.c | 4 ++++
> 4 files changed, 34 insertions(+), 10 deletions(-)
>
> diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile
> index b939bcfc11..ee3981e3f6 100644
> --- a/sysdeps/aarch64/Makefile
> +++ b/sysdeps/aarch64/Makefile
> @@ -90,6 +90,7 @@ ifeq (yes,$(have-test-bti))
>
> tests += \
> tst-bti-abort-imm \
> + tst-bti-abort-static \
> tst-bti-abort-transitive \
> tst-bti-abort-unprot \
> tst-bti-dep-prot \
> diff --git a/sysdeps/aarch64/dl-bti.c b/sysdeps/aarch64/dl-bti.c
> index 5d743e775f..1301ce2e73 100644
> --- a/sysdeps/aarch64/dl-bti.c
> +++ b/sysdeps/aarch64/dl-bti.c
> @@ -66,13 +66,23 @@ _dl_bti_protect (struct link_map *map, int fd)
> static void
> bti_failed (struct link_map *l, const char *program)
> {
> - if (program)
> - _dl_fatal_printf ("%s: %s: failed to turn on BTI protection\n",
> - program, l->l_name);
> + if (program != NULL)
> + {
> + if (program[0] != '\0' && l->l_name[0] != '\0')
> + /* A program's dependency is not BTI compatible. */
> + _dl_fatal_printf ("%s: %s: failed to turn on BTI protection\n",
> + program, l->l_name);
> + if (program[0] != '\0')
> + /* The program itself is not BTI compatible. */
> + _dl_fatal_printf ("%s: failed to turn on BTI protection\n", program);
> + /* For static binaries, program will be an empty string. */
> + _dl_fatal_printf ("error: failed to turn on BTI protection\n");
> + }
> else
> - /* Note: the errno value is not available any more. */
> + /* If program is NULL, we are processing a dlopen operation.
> + Note: the errno value is not available any more. */
> _dl_signal_error (0, l->l_name, "dlopen",
> - N_("failed to turn on BTI protection"));
> + "failed to turn on BTI protection");
> }
>
>
> diff --git a/sysdeps/aarch64/dl-gcs.c b/sysdeps/aarch64/dl-gcs.c
> index 7a80e14933..1c6944562d 100644
> --- a/sysdeps/aarch64/dl-gcs.c
> +++ b/sysdeps/aarch64/dl-gcs.c
> @@ -33,18 +33,27 @@
> static void
> fail (struct link_map *l, const char *program)
> {
> - if (program && program[0])
> - _dl_fatal_printf ("%s: %s: %s\n", program, l->l_name, "not GCS compatible");
> - else if (program)
> - _dl_fatal_printf ("%s\n", "not GCS compatible");
> + if (program != NULL)
> + {
> + if (program[0] != '\0' && l->l_name[0] != '\0')
> + /* A program's dependency is not GCS compatible. */
> + _dl_fatal_printf ("%s: %s: not GCS compatible\n", program, l->l_name);
> + if (program[0] != '\0')
> + /* The program itself is not GCS compatible. */
> + _dl_fatal_printf ("%s: not GCS compatible\n", program);
> + /* For static binaries, program will be an empty string. */
> + _dl_fatal_printf ("error: not GCS compatible\n");
> + }
> else
> + /* If program is NULL, we are processing a dlopen operation.
> + Note: the errno value is not available any more. */
> _dl_signal_error (0, l->l_name, "dlopen", "not GCS compatible");
> }
>
> static void
> unsupported (void)
> {
> - _dl_fatal_printf ("%s\n", "unsupported GCS policy");
> + _dl_fatal_printf ("unsupported GCS policy\n");
> }
>
> /* This function is called only when binary markings are not
> diff --git a/sysdeps/aarch64/tst-bti-abort-static.c b/sysdeps/aarch64/tst-bti-abort-static.c
> index 83871b1fdb..6385e41c65 100644
> --- a/sysdeps/aarch64/tst-bti-abort-static.c
> +++ b/sysdeps/aarch64/tst-bti-abort-static.c
> @@ -22,6 +22,7 @@
> #include <stddef.h>
> #include <stdint.h>
> #include <string.h>
> +#include <sys/auxv.h>
>
> #include <support/check.h>
> #include <support/support.h>
> @@ -30,6 +31,9 @@
> static int
> do_test (void)
> {
> + unsigned long hwcap2 = getauxval (AT_HWCAP2);
> + if ((hwcap2 & HWCAP2_BTI) == 0)
> + FAIL_UNSUPPORTED ("BTI is not supported by this system");
> return 0;
> }
>
More information about the Libc-alpha
mailing list