Re: [RFC PATCH 6/7] x86/kexec: Debugging support: Dump registers on exception

From: H. Peter Anvin
Date: Tue Nov 05 2024 - 17:58:09 EST


On 11/5/24 14:27, H. Peter Anvin wrote:

I don't know if it is necessary, but you can do something like this to make absolutely sure you don't end up with non-relative symbol references:

static inline __constfunc void * sym_addr(const void *sym)
{
    void *addr;
    asm("lea %c1(%%rip),%0" : "=r" (addr) : "i" (sym));
    return addr;
}


Compiling with "-fpic -fvisibility=hidden -mcmodel=medium" can also be used to suppress non-relative references. If you have external symbol references they at least *should* be emitted as GOTPCRELX relocations which the linker should relax to relative references; however, I would think that you really don't want any of those :)

-hpa