Re: [PATCH v3 6/7] x86/boot: Remove runtime relocations from head_{32,64}.S

From: Kees Cook
Date: Mon Jun 29 2020 - 15:44:05 EST


On Mon, Jun 29, 2020 at 10:09:27AM -0400, Arvind Sankar wrote:
> The BFD linker generates runtime relocations for z_input_len and
> z_output_len, even though they are absolute symbols.
>
> This is fixed for binutils-2.35 [1]. Work around this for earlier
> versions by defining two variables input_len and output_len in addition
> to the symbols, and use them via position-independent references.
>
> This eliminates the last two runtime relocations in the head code and
> allows us to drop the -z noreloc-overflow flag to the linker.
>
> [1] https://sourceware.org/bugzilla/show_bug.cgi?id=25754
>
> Signed-off-by: Arvind Sankar <nivedita@xxxxxxxxxxxx>
> Reviewed-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
> Reviewed-by: Fangrui Song <maskray@xxxxxxxxxx>
> ---
> arch/x86/boot/compressed/Makefile | 8 --------
> arch/x86/boot/compressed/head_32.S | 17 ++++++++---------
> arch/x86/boot/compressed/head_64.S | 4 ++--
> arch/x86/boot/compressed/mkpiggy.c | 6 ++++++
> 4 files changed, 16 insertions(+), 19 deletions(-)

I continue to really enjoy the smaller code. Anything that makes
mkpiggy.c smaller is a win. :)

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook