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

Arm64's xen.efi vs GNU binutils (and alike)


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 11 Jul 2022 16:32:17 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=y5ilYfVvTdvnaDfIBOkumYXWZCHNCtVKRfl1EGELMhY=; b=m+T8FbnJ690pqM8XBtWALBOC1bOvdGNEqujRCv9drMq+W15TE39tv5ItmqN5tHkbMJbRHFgLtPiT/0TISF6FkkbvwH5QpyhT5faHbQyFzpbY3C/sAugcjtF+ChyQVyR0RSShDc+XLQ9AN8PzuiYQ4ydwtZQ+Qa8rxfL6TidFtlghyRcVNe1rSvjymhc4Z04IfULdz25UQ6CRLp4JQJjFm7Xu7mYXO3gIS9JXot53/7r+2DRfnbGuhub8Te0PEs4VHQzbCgRTTOnvHuCINKbRjodXLHWyeQL871f6cUdJZouRIby8T+p3Eh4B4PHqEx8kkV5Wsi85R9+8pRguyD0flA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lZ1avI9fmZ7GD0zK5pxgQBGLMYojyK/OE8aH8KPpFk0a0b/7cte6bWR6yVu8NlEadl4q3GoGetC1CF/2NVUH+IoD50cFAaOvy4VEm5WHzy3b4vVgxR2ZLQ8Sjei7F6hQKiz9Qg4EA4OlUvl190r3+dyjOIJQ3qsuWLcCsvFrH4BmJJoV3hB96XXUjkkquOTMeLxGC40rbJY5DkdvjVFcBnf4c/UqLD09fwl77JSOakHEDzzj7emERNWOkommme+FMPJ8HD3vyuvVKi2cDfIlOz25X1I/p+G4wL0Kpluy3mXZHzX2msgrtKKI/MGlp+mN6+otXjfJNQGHUyaDCpqUzg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Mon, 11 Jul 2022 14:32:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hello,

the other day I wanted to look at the basic structure of xen.efi. First
I used my own dumping tool, which didn't work. Then I used objdump,
which appeared to work. I decided that I should look into what they do
different, and whether I could make mine work as well, or whether
instead objdump is broken and shouldn't work on this sort of binary.
While I'm not fully certain yet, I'm leaning to the latter. This is
supported by GNU objcopy corrupting the binary (I assume this is known
and considered okay-ish).

Many problems boil down to the (ab)use of the DOS executable header
fields, yielding an invalid header. The first 8 bytes are instructions,
with the first carefully chosen to produce 'MZ' in its low half.
(Oddly enough Xen and Linux use different insns there.) This doesn't
play well with the meaning of the respective fields in the DOS header.
Subsequently there are a number of .quad-s, some of which again yield
an invalid DOS header. I'm therefore inclined to submit a patch to
make objdump properly fail on this binary. But of course with both
Xen and Linux (and who knows who else) using this hairy approach, it
may end up necessary to continue to "support" this special case,
which is why I'm seeking your input here first.

Furthermore the fake .reloc section overlaps the file header. The
section is zero size (i.e. empty), but a reasonable PE loader might
still object to its RVA being zero.

As to objcopy: It shrinks the binary significantly in size, removes
the dummy .reloc section, re-writes fair parts of the DOS header,
and extends the NT header resulting in the file position of .text
changing. The size reduction and possibly the movement of .text may
be okay as long as the resulting binary is to only be used with UEFI
(as it's due to zapping of the embedded DTB and the unnecessary zero-
filling of .bss, afaict), but my understanding is that the other
adjustments are all fatal to the usability of the binary even on
UEFI.

I may easily have forgotten further anomalies.

Jan



 


Rackspace

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