• Ard Biesheuvel's avatar
    arm64: kernel: force ET_DYN ELF type for CONFIG_RELOCATABLE=y · b9dce7f1
    Ard Biesheuvel authored
    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: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    b9dce7f1
Makefile 4.52 KB