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

Kees Cook
2020-06-29T19:44:04Z

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@alum.mit.edu>
> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
> Reviewed-by: Fangrui Song <maskray@google.com>
> ---
> 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@chromium.org>

--
Kees Cook