arm64: kernel: force ET_DYN ELF type for CONFIG_RELOCATABLE=y
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 20 Oct 2016 10:12:57 +0000 (11:12 +0100)
committerWill Deacon <will.deacon@arm.com>
Thu, 20 Oct 2016 10:37:25 +0000 (11:37 +0100)
commitb9dce7f1ba01be340975c17bd37a46ec6054bd2b
tree0b2b77604395067db7e05e0a6472ce2ff208d14e
parentd08544127d9fb4505635e3cb6871fd50a42947bd
arm64: kernel: force ET_DYN ELF type for CONFIG_RELOCATABLE=y

GNU ld used to set the ELF file type to ET_DYN for PIE executables, which
is the same file type used for shared libraries. However, this was changed
recently, and now PIE executables are emitted as ET_EXEC instead.

The distinction is only relevant for ELF loaders, and so there is little
reason to care about the difference when building the kernel, which is
why the change has gone unnoticed until now.

However, debuggers do use the ELF binary, and expect ET_EXEC type files
to appear in memory at the exact offset described in the ELF metadata.
This means source level debugging is no longer possible when KASLR is in
effect or when executing the stub.

So add the -shared LD option when building with CONFIG_RELOCATABLE=y. This
forces the ELF file type to be set to ET_DYN (which is what you get when
building with binutils 2.24 and earlier anyway), and has no other ill
effects.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/Makefile