• Ard Biesheuvel's avatar
    arm64: kernel: Manage absolute relocations in code built under pi/ · 48157aa3
    Ard Biesheuvel authored
    The mini C runtime runs before relocations are processed, and so it
    cannot rely on statically initialized pointer variables.
    
    Add a check to ensure that such code does not get introduced by
    accident, by going over the relocations in each object, identifying the
    ones that operate on data sections that are part of the executable
    image, and raising an error if any relocations of type R_AARCH64_ABS64
    exist. Note that such relocations are permitted in other places (e.g.,
    debug sections) and will never occur in compiler generated code sections
    when using the small code model, so only check sections that have
    SHF_ALLOC set and SHF_EXECINSTR cleared.
    
    To accommodate cases where statically initialized symbol references are
    unavoidable, introduce a special case for ELF input data sections that
    have ".rodata.prel64" in their names, and in these cases, instead of
    rejecting any encountered ABS64 relocations, convert them into PREL64
    relocations, which don't require any runtime fixups. Note that the code
    in question must still be modified to deal with this, as it needs to
    convert the 64-bit signed offsets into absolute addresses before use.
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Link: https://lore.kernel.org/r/20240214122845.2033971-46-ardb+git@google.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    48157aa3
pi.h 493 Bytes