aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2023-12-27 17:17:11 +0000
committerYury Khrustalev <yury.khrustalev@arm.com>2025-01-20 09:36:19 +0000
commitd3df351338ce275b6c0fd9cb1c01a7d8eceedb47 (patch)
tree6d03d5814e67d8bf005c7d19319f1345ed77691a
parent29476485f90a0c3460149349367a45085cc57c65 (diff)
downloadglibc-d3df351338ce275b6c0fd9cb1c01a7d8eceedb47.zip
glibc-d3df351338ce275b6c0fd9cb1c01a7d8eceedb47.tar.gz
glibc-d3df351338ce275b6c0fd9cb1c01a7d8eceedb47.tar.bz2
aarch64: Process gnu properties in static exe
Unlike for BTI, the kernel does not process GCS properties so update GL(dl_aarch64_gcs) before the GCS status is set. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/libc-start.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc-start.h b/sysdeps/unix/sysv/linux/aarch64/libc-start.h
index 2ea61bf..75ae0a8 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc-start.h
+++ b/sysdeps/unix/sysv/linux/aarch64/libc-start.h
@@ -21,6 +21,8 @@
#ifndef SHARED
+# include <dl-prop.h>
+
# ifndef PR_SET_SHADOW_STACK_STATUS
# define PR_SET_SHADOW_STACK_STATUS 75
# define PR_SHADOW_STACK_ENABLE (1UL << 0)
@@ -31,6 +33,18 @@ static inline void __attribute__((always_inline))
aarch64_libc_setup_tls (void)
{
__libc_setup_tls ();
+
+ struct link_map *main_map = _dl_get_dl_main_map ();
+ const ElfW(Phdr) *phdr = GL(dl_phdr);
+ const ElfW(Phdr) *ph;
+ for (ph = phdr; ph < phdr + GL(dl_phnum); ph++)
+ if (ph->p_type == PT_GNU_PROPERTY)
+ {
+ _dl_process_pt_gnu_property (main_map, -1, ph);
+ _rtld_main_check (main_map, _dl_argv[0]);
+ break;
+ }
+
if (GL(dl_aarch64_gcs) != 0)
{
int ret = INLINE_SYSCALL_CALL (prctl, PR_SET_SHADOW_STACK_STATUS,