[PATCH] x86/mkelf32: correct VA/PA of PT_NOTE / .note

Jan Beulich posted 1 patch 3 days, 7 hours ago
[PATCH] x86/mkelf32: correct VA/PA of PT_NOTE / .note
Posted by Jan Beulich 3 days, 7 hours ago
For the .p_paddr, .p_vaddr, and .sh_addr fields the image load base
(passed in by command line argument) also needs taking into account. It is
_not_ merely the delta between incoming PT_NOTE and PT_LOAD segments. (The
fields aren't really used anywhere, so this is largely a cosmetic issue;
static analysis tools may be affected, though.)

Fixes: a353cab905af ("build_id: Provide ld-embedded build-ids")
Reported-by: Barr Detwix <timotheecisnard@gmail.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/boot/mkelf32.c
+++ b/xen/arch/x86/boot/mkelf32.c
@@ -362,7 +362,7 @@ int main(int argc, char **argv)
         (void)lseek(infd, offset, SEEK_SET);
 
         note_sz = in64_phdr.p_memsz;
-        note_base = in64_phdr.p_vaddr - note_base;
+        note_base = in64_phdr.p_vaddr - note_base + loadbase;
 
         if ( in64_phdr.p_offset < offset ||
              in64_phdr.p_offset + in64_phdr.p_filesz > offset + dat_siz )