[llvm] [Bolt] Fix address translation for KASLR kernel (PR #114261)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 21:19:53 PST 2024


================
@@ -530,8 +530,11 @@ Error RewriteInstance::discoverStorage() {
           Phdr.p_vaddr,  Phdr.p_memsz, Phdr.p_offset,
           Phdr.p_filesz, Phdr.p_align, ((Phdr.p_flags & ELF::PF_X) != 0)};
       if (BC->TheTriple->getArch() == llvm::Triple::x86_64 &&
-          Phdr.p_vaddr >= BinaryContext::KernelStartX86_64)
+          Phdr.p_vaddr >= BinaryContext::KernelStartX86_64) {
         BC->IsLinuxKernel = true;
+        BC->HasFixedLoadAddress = false;
----------------
maksfb wrote:

Is there any way to detect KASLR by looking at `vmlinux` ELF and only then set `HasFixedLoadAddress`. 

https://github.com/llvm/llvm-project/pull/114261


More information about the llvm-commits mailing list