public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/nsz/pacbti-v6] aarch64: fix RTLD_START for BTI
@ 2020-07-01 14:33 Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2020-07-01 14:33 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=61533cce8675be5a47148caf64a64c6315a4206d

commit 61533cce8675be5a47148caf64a64c6315a4206d
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Tue Mar 31 17:32:14 2020 +0100

    aarch64: fix RTLD_START for BTI
    
    Tailcalls must use x16 or x17 for the indirect branch instruction
    to be compatible with code that uses BTI c at function entries.
    (Other forms of indirect branches can only land on BTI j.)
    
    Also added a BTI c at the ELF entry point of rtld, this is not
    strictly necessary since the kernel does not use indirect branch
    to get there, but it seems safest once building glibc itself with
    BTI is supported.
    
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Diff:
---
 sysdeps/aarch64/dl-machine.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index db3335e5ad..70b9ed3925 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -125,6 +125,8 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 .globl _dl_start_user							\n\
 .type _dl_start_user, %function						\n\
 _start:									\n\
+	// bti c							\n\
+	hint	34							\n\
 	mov	" PTR "0, " PTR_SP "					\n\
 	bl	_dl_start						\n\
 	// returns user entry point in x0				\n\
@@ -178,7 +180,8 @@ _dl_start_user:								\n\
 	adrp	x0, _dl_fini						\n\
 	add	" PTR "0, " PTR "0, #:lo12:_dl_fini			\n\
 	// jump to the user_s entry point				\n\
-	br      x21							\n\
+	mov     x16, x21						\n\
+	br      x16							\n\
 ");
 
 #define elf_machine_type_class(type)					\


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [glibc/nsz/pacbti-v6] aarch64: fix RTLD_START for BTI
@ 2020-07-02  8:38 Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2020-07-02  8:38 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4b3b0a983285237dbe9cce7a45f722b66a507c1d

commit 4b3b0a983285237dbe9cce7a45f722b66a507c1d
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Tue Mar 31 17:32:14 2020 +0100

    aarch64: fix RTLD_START for BTI
    
    Tailcalls must use x16 or x17 for the indirect branch instruction
    to be compatible with code that uses BTI c at function entries.
    (Other forms of indirect branches can only land on BTI j.)
    
    Also added a BTI c at the ELF entry point of rtld, this is not
    strictly necessary since the kernel does not use indirect branch
    to get there, but it seems safest once building glibc itself with
    BTI is supported.
    
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Diff:
---
 sysdeps/aarch64/dl-machine.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index db3335e5ad..70b9ed3925 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -125,6 +125,8 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 .globl _dl_start_user							\n\
 .type _dl_start_user, %function						\n\
 _start:									\n\
+	// bti c							\n\
+	hint	34							\n\
 	mov	" PTR "0, " PTR_SP "					\n\
 	bl	_dl_start						\n\
 	// returns user entry point in x0				\n\
@@ -178,7 +180,8 @@ _dl_start_user:								\n\
 	adrp	x0, _dl_fini						\n\
 	add	" PTR "0, " PTR "0, #:lo12:_dl_fini			\n\
 	// jump to the user_s entry point				\n\
-	br      x21							\n\
+	mov     x16, x21						\n\
+	br      x16							\n\
 ");
 
 #define elf_machine_type_class(type)					\


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-02  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 14:33 [glibc/nsz/pacbti-v6] aarch64: fix RTLD_START for BTI Szabolcs Nagy
2020-07-02  8:38 Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).