public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Marvin Häuser" <mhaeuser@posteo.de>
To: Ard Biesheuvel <ardb@kernel.org>,devel@edk2.groups.io
Subject: Re: [edk2-devel] [RFT PATCH v2 1/6] BaseTools/tools_def XCODE: Link X64 with -read_only_relocs suppress
Date: Thu, 30 Mar 2023 14:54:02 -0700	[thread overview]
Message-ID: <13330.1680213242478608984@groups.io> (raw)
In-Reply-To: <20230330212101.1566931-2-ardb@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]

Hi Ard,

Sorry, I cannot preserve the CC list as the groups.io interface doesn't seem to allow it. Can you please CC me on future revisions?

This patch will badly corrupt binaries. I cannot cite a source right now (if you want me to, please remind me in your response, so I can look it up tomorrow), but for X64 (but not IA32, which is why this is enabled there), relocs are relative to the first *writable* segment. In other words, any relocation to __TEXT will badly corrupt binaries this way.

In AUDK, we support this with two essential changes. The first is that we always generate a writable dummy segment at the beginning of the address space [1], making the relocs relative to the image base. The second is that in ocmtoc, our fork of the abandoned (and pretty badly-bugged) Apple mtoc, we explicitly require this segment to be present and verify its virtual address is the minimum virtual address [2]. It is then omitted from the conversion process [3]. I suggest you replicate these changes and fully switch to ocmtoc for XCODE5 builds.

Best regards,
Marvin

[1]
https://github.com/acidanthera/audk/blob/c382e9c571c7d5f39ba53b46a0c723c7943f33c5/BaseTools/Conf/tools_def.template#L2976-L2988

[2]
https://github.com/acidanthera/ocmtoc/blob/b0152c51beae264770c3faf0d213f9594ee043be/efitools/mtoc.c#L1097-L1123
https://github.com/acidanthera/ocmtoc/blob/b0152c51beae264770c3faf0d213f9594ee043be/efitools/mtoc.c#L1204-L1214

[3]
https://github.com/acidanthera/ocmtoc/blob/b0152c51beae264770c3faf0d213f9594ee043be/efitools/mtoc.c#L1307-L1311

[-- Attachment #2: Type: text/html, Size: 2165 bytes --]

  reply	other threads:[~2023-03-30 21:54 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 21:20 [RFT PATCH v2 0/6] UefiCpuPkg, OvmfPkf: Simplify CpuExceptionHandlerLib Ard Biesheuvel
2023-03-30 21:20 ` [RFT PATCH v2 1/6] BaseTools/tools_def XCODE: Link X64 with -read_only_relocs suppress Ard Biesheuvel
2023-03-30 21:54   ` Marvin Häuser [this message]
2023-03-31  7:39     ` [edk2-devel] " Ard Biesheuvel
2023-03-31  8:29       ` Marvin Häuser
2023-03-31  8:59         ` Ard Biesheuvel
2023-03-31  9:27           ` Marvin Häuser
2023-03-31  9:36             ` Ard Biesheuvel
2023-03-31 10:35               ` Marvin Häuser
2023-03-31 10:52               ` Gerd Hoffmann
2023-03-31 10:58                 ` Ard Biesheuvel
2023-03-31 11:00                 ` Marvin Häuser
2023-03-31  9:16         ` Gerd Hoffmann
2023-03-31 14:58         ` Rebecca Cran
2023-03-31 15:08           ` Marvin Häuser
2023-03-30 21:20 ` [RFT PATCH v2 2/6] BaseTools/tools_def CLANGDWARF: Permit text relocations Ard Biesheuvel
2023-03-30 21:20 ` [RFT PATCH v2 3/6] UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version Ard Biesheuvel
2023-03-31  4:21   ` Ni, Ray
2023-03-31  7:40     ` [edk2-devel] " Ard Biesheuvel
2023-03-31  8:01       ` Ni, Ray
2023-03-30 21:20 ` [RFT PATCH v2 4/6] UefiCpuPkg/CpuExceptionHandlerLib: Remove needless runtime fixups Ard Biesheuvel
2023-03-30 22:04   ` [edk2-devel] " Marvin Häuser
2023-03-31  5:08     ` Ni, Ray
2023-03-31  8:06       ` Marvin Häuser
2023-03-31  4:22   ` Ni, Ray
2023-03-30 21:21 ` [RFT PATCH v2 5/6] OvmfPkg: Drop special Xcode5 version of exception handler library Ard Biesheuvel
2023-03-31  0:37   ` [edk2-devel] " Yao, Jiewen
2023-03-30 21:21 ` [RFT PATCH v2 6/6] UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version Ard Biesheuvel
2023-03-31  4:23   ` [edk2-devel] " Ni, Ray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13330.1680213242478608984@groups.io \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox