[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Fri, 25 Sep 2026 14:58:38 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m5Jl5dai22U+/VZ8ekwNoaCGJzjDo+NHI0gO9/ichfY=; b=YCIREIvrNUKQVqleR7VcNvBvjDR/N7hVqL1nHQrL7wNtKQ9uTqfbA03KfGRDgGX6vXQoqZ1H9A7HjqtqNrvSlIB5NwG1DXn1lTbawmD2BxIAB5vvf7Avu+DU9MmEW25uAdqofu3nK7/CuwVw9NCkUgWVFWMnTVl/jSsLtLyxAjrdEZIuZwjm4AIhVn3k4QUxf/P9o5Vdg+HDDSWRmqb0dSHEI1isP1Jjg3A0RvOT7CD8hcR6Gq7mAWBbxuNdNjqZBptUdPEGN7OGMJQtNM0LO8mUNhe24WE1ssIWNSZJlCweD1cu0ollQ//6ctJ31Nlz+7CfIiAja0MP2PArj4mFHg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Am+Hxo1MbpaZph7aF/dmVb5/2GQVDZ+LsBpImJSD+BCY/0n0KHK2CU/xzH+RTxqBvLVkClVk0kciHytmJWHJt0/YZa2OTjGn46eIUvdOUGjW3TEjs/DVO4J2QtGT60H2j50wg7HF8E8aI31IF5QT/50KohLBBRxXN6eAlq1rRfuSmpYCre7MmdRCq8QLoUu917Q/xv6Vt+bJVUlCLmBcQPRxo+mHfoIUitfIgVT8EAiz0MlDAyS/5gpg10/cIia8OwcftQ1j/0bxACD3/XqRKB8OdAM9/KX30jkthujHtdntiJE0yqlQW4KAGqzD9SSaYGQ7rvpOlb5k+P+oKbGuFQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Barr Detwix <timotheecisnard@xxxxxxxxx>
  • Delivery-date: Fri, 25 Sep 2026 13:58:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 9/21/26 11:18 AM, Jan Beulich wrote:
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@xxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- 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 )


The diff before/after shows the note section and program header addresses
moving by 0x200000 as expected (with no other changes):

@@ -24,7 +24,7 @@
   [ 0]                   NULL            00000000 000000 000000 00      0   0  0
   [ 1] .text             PROGBITS        00200000 000080 2df354 00 WAX  0   0 
64
   [ 2] .shstrtab         STRTAB          00000000 2df474 000018 00      0   0  
1
-  [ 3] .note             NOTE            002072b8 207338 000024 00      0   0  
4
+  [ 3] .note             NOTE            004072b8 207338 000024 00      0   0  
4
 Key to Flags:
   W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
   L (link order), O (extra OS processing required), G (group), T (TLS),
@@ -36,7 +36,7 @@
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
   LOAD           0x000080 0x00200000 0x00200000 0x2df354 0x400000 RWE 0x40
-  NOTE           0x207338 0x002072b8 0x002072b8 0x00024 0x00024 R   0x4
+  NOTE           0x207338 0x004072b8 0x004072b8 0x00024 0x00024 R   0x4
Section to Segment mapping:
   Segment Sections...

Reviewed-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.