aarch64: fix static PIE start code for BTI [BZ #27068]

Message ID 20201215141659.28444-1-szabolcs.nagy@arm.com
State Committed
Commit d4136903a29baabeec8987b53081def8b4a49826
Headers
Series aarch64: fix static PIE start code for BTI [BZ #27068] |

Commit Message

Szabolcs Nagy Dec. 15, 2020, 2:16 p.m. UTC
  From: Guillaume Gardet <guillaume.gardet@arm.com>

A bti c was missing from rcrt1.o which made all -static-pie
binaries fail at program startup on BTI enabled systems.

Fixes bug 27068.
---
 sysdeps/aarch64/start.S | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Szabolcs Nagy Dec. 15, 2020, 2:29 p.m. UTC | #1
The 12/15/2020 14:16, Szabolcs Nagy via Libc-alpha wrote:
> From: Guillaume Gardet <guillaume.gardet@arm.com>
> 
> A bti c was missing from rcrt1.o which made all -static-pie
> binaries fail at program startup on BTI enabled systems.
> 
> Fixes bug 27068.

note that normally BTI c is added by the ENTRY macro which
is why it was missed here.

__wrap_main could be made a separate function with its own
ENTRY/END macros, but i think it is semantically not a
separate function just a local label used as a work around
to avoid using unprocessed relative relocs for main before
the static pie binary does self relocation so explicit bti
is appropriate.

i'm commiting this as is.

> ---
>  sysdeps/aarch64/start.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
> index 108f602721..1998ea95d4 100644
> --- a/sysdeps/aarch64/start.S
> +++ b/sysdeps/aarch64/start.S
> @@ -99,6 +99,7 @@ ENTRY(_start)
>  	   because crt1.o and rcrt1.o share code and the later must avoid the
>  	   use of GOT relocations before __libc_start_main is called.  */
>  __wrap_main:
> +	BTI_C
>  	b	main
>  #endif
>  END(_start)
> -- 
> 2.17.1
> 

--
  

Patch

diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
index 108f602721..1998ea95d4 100644
--- a/sysdeps/aarch64/start.S
+++ b/sysdeps/aarch64/start.S
@@ -99,6 +99,7 @@  ENTRY(_start)
 	   because crt1.o and rcrt1.o share code and the later must avoid the
 	   use of GOT relocations before __libc_start_main is called.  */
 __wrap_main:
+	BTI_C
 	b	main
 #endif
 END(_start)