Hi Radek,

On Jul 24 10:30, Radek Barton via Cygwin-patches wrote:
> Hello.
> 
> Sending another version of the patch with the comments added.

Thanks for this.  A small nit:

> 
> Radek
> 
> ---
> >From b9d04d2359a258f4a08f7f50fe5a11c03859f2b5 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Radek=20Barto=C5=88?= <radek.bar...@microsoft.com>
> Date: Sat, 19 Jul 2025 19:17:12 +0200
> Subject: [PATCH v2] Cygwin: mkimport: implement AArch64 +/-4GB relocations
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> Based on https://sourceware.org/pipermail/cygwin-patches/2025q3/014154.html
> suggestion, this patch implements +/-4GB relocations for AArch64 in the 
> mkimport
> script by using adrp and ldr instructions. This change required update
> in winsup\cygwin\mm\malloc_wrapper.cc where those instructions are
> decoded to get target import address.
> 
> Signed-off-by: Radek BartoĊˆ <radek.bar...@microsoft.com>
> ---
>  winsup/cygwin/mm/malloc_wrapper.cc | 26 +++++++++++++++++---------
>  winsup/cygwin/scripts/mkimport     |  7 +++++--
>  2 files changed, 22 insertions(+), 11 deletions(-)
> 
> diff --git a/winsup/cygwin/mm/malloc_wrapper.cc 
> b/winsup/cygwin/mm/malloc_wrapper.cc
> index 863d3089c..991bd57be 100644
> --- a/winsup/cygwin/mm/malloc_wrapper.cc
> +++ b/winsup/cygwin/mm/malloc_wrapper.cc
> @@ -51,16 +51,24 @@ import_address (void *imp)
>    __try
>      {
>  #if defined(__aarch64__)
> -      // If opcode is an adr instruction.
> -      uint32_t opcode = *(uint32_t *) imp;
> -      if ((opcode & 0x9f000000) == 0x10000000)

For multiline comments, please use /* ... */ as in the surrounding code.

> +      // If opcode1 is an adrp and opcode2 is ldr instruction:
> +      //   - https://www.scs.stanford.edu/~zyedidia/arm64/adrp.html
> +      //   - https://www.scs.stanford.edu/~zyedidia/arm64/ldr_imm_gen.html
> +      // NOTE: This implementation assumes that the relocation table is made 
> of
> +      // those specific AArch64 instructions as generated by the
> +      // winsup\cygwin\scripts\mkimport script. Please, keep it in sync.

And for paths, please use forward slashes. We're POSIXy here ;)

Apart from that this LGTM, but I would like to wait for a GTG from
Jeremy as well.


Thanks,
Corinna

Reply via email to