From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75464C433F5 for ; Tue, 11 Jan 2022 19:57:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F052783041; Tue, 11 Jan 2022 20:57:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jrtc27.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=jrtc27.com header.i=@jrtc27.com header.b="ZXwTk1HI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6ED1880562; Tue, 11 Jan 2022 20:42:37 +0100 (CET) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7FF9880FDA for ; Tue, 11 Jan 2022 20:42:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jrtc27.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jrtc27@jrtc27.com Received: by mail-wr1-x42e.google.com with SMTP id a5so188999wrh.5 for ; Tue, 11 Jan 2022 11:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=EQljp6Q0/TU9SlPl9WxzI1GmpGM2VYBtLGTqIZx8VaQ=; b=ZXwTk1HIMhN1YTsKC/5B4lbpNaiFOx2fbUgmOnECJL4Y6ETIuYOFP9zWRix3SxXiZn fXgWfadinE+6Ff6XiwvopAxK0vnAKmzudAIvTmZiC9QDHnxabBEFroVSMLmTzYE/edDe FRif66HEPAiqbMqX/T1gSiZh0w7bEp2+cHJGWvVxEjiJet561bpzC5rMZXRTqMM5MAmS mRfe4f07hGvB6LGrT13ccjc5wA+WE718FLI4DpfJ96OTYIzRurGqhuakskC1jBxR6SkJ mO9UW96AUBmfRsLiXNE5BL9388Szhp4Ml7I+FO/9HDRn7kp/4uF5c3yDyy++HXCFZPJO M0aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=EQljp6Q0/TU9SlPl9WxzI1GmpGM2VYBtLGTqIZx8VaQ=; b=Gsi3DZh7Q04mWj1bJ20MkEdQG9iH8TmKNINw+WoJBincydS/gMw/fpaG5Wr/DQZsKU JFZG1woR8YVhOY+dUuYZ76/BJdIUaK9szqLzhu60k/HvAHC8YyQkdhBWVDuXwMyEHz5D 6zx3fUQ0vl8MKJlrukKIyHtWIHbXycVoKOWJgfDguprtWpa66YxIAwdWl/F809gmfon2 jSL6PABdoRDYpxZxV+1mLELm+U7xwiwhiE+ZVI5bqkwT2GsskUBHHT+bULkkjEnoYJQV jeggSkMen+k5QNGUdfiXhXEidSYuK6zPgXRJ9x0CkL34tyGkmiAIm7/l+qVOgN//eQPY +UQg== X-Gm-Message-State: AOAM531F7eQMX9tF40mOZFBl+9FQG2raHBPU1ypVsPWkM+nPF3fL4Gys Q8AHeH3hnTW2IU4dZXPBZ6SmNrkk/eEs2lfh X-Google-Smtp-Source: ABdhPJwHCAHuTgSpdBHvFIPMqTmmtskT++IJfjY5a6JFh6NlE6daY28btjZ5WfhzH665i36S/vLFYQ== X-Received: by 2002:a5d:434d:: with SMTP id u13mr5167748wrr.391.1641930153965; Tue, 11 Jan 2022 11:42:33 -0800 (PST) Received: from smtpclient.apple (global-5-142.nat-2.net.cam.ac.uk. [131.111.5.142]) by smtp.gmail.com with ESMTPSA id h4sm10215268wrf.93.2022.01.11.11.42.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jan 2022 11:42:33 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Subject: Re: [PATCH] mkimage: fix segfault on MacOS arm64 From: Jessica Clarke In-Reply-To: <69231A4C-25D5-4D80-9639-2E43F3005DBD@lobanov.in> Date: Tue, 11 Jan 2022 19:42:33 +0000 Cc: u-boot@lists.denx.de Content-Transfer-Encoding: quoted-printable Message-Id: <99D0682A-EF69-4A2C-A902-B914C179146A@jrtc27.com> References: <20211202191631.98009-1-sergey@lobanov.in> <69231A4C-25D5-4D80-9639-2E43F3005DBD@lobanov.in> To: "Sergey V. Lobanov" X-Mailer: Apple Mail (2.3693.40.0.1.81) X-Mailman-Approved-At: Tue, 11 Jan 2022 20:57:17 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 2 Dec 2021, at 22:16, Sergey V. Lobanov wrote: >=20 > mkimage segfaults due ASLR mechasim on MacOS arm64 >=20 > It is required to use _dyld_get_image_vmaddr_slide() > to prevent segfault on MacOS arm64 >=20 > This patch ased on the discussion > = https://github.com/u-boot/u-boot/commit/3b142045e8a7f0ab17b6099e9226296af4= 5967d0 >=20 > Thanks to Ronny Kotzschmar and ptpt52 github user >=20 > Signed-off-by: Sergey V. Lobanov > --- > tools/imagetool.h | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/tools/imagetool.h b/tools/imagetool.h > index e229a34ffc..13775ff9b3 100644 > --- a/tools/imagetool.h > +++ b/tools/imagetool.h > @@ -271,11 +271,16 @@ int rockchip_copy_image(int fd, struct = image_tool_params *mparams); > * b) we need a API call to get the respective section symbols */ > #if defined(__MACH__) > #include > +#include >=20 > -#define INIT_SECTION(name) do { = \ > +#define INIT_SECTION(name) struct image_type_params = \ > + **__cat(__start_, name), **__cat(__stop_, name); = \ This change alters the interface of INIT_SECTION. Previously it was just required that something had called it before you referenced the start/stop symbols. Now there are two things going on: 1. Any references have to be in a scope that can see the INIT_SECTION call. 2. This is no longer a single statement, so if (foo) INIT_SECTION(name); breaks. I don=E2=80=99t see why this change is needed, either. It should still = be idempotent to set the global multiple times even after your change to add the base address, since that is done to the temporary local variable. > + do { = \ > unsigned long name ## _len; = \ > char *__cat(pstart_, name) =3D getsectdata("__DATA", = \ > #name, &__cat(name, _len)); = \ > + __cat(pstart_, name) +=3D = \ > + _dyld_get_image_vmaddr_slide(0); = \ Your formatting here is broken, you have an extra tab on both lines. Jess > char *__cat(pstop_, name) =3D __cat(pstart_, name) + = \ > __cat(name, _len); = \ > __cat(__start_, name) =3D (void *)__cat(pstart_, name); = \ > @@ -283,7 +288,6 @@ int rockchip_copy_image(int fd, struct = image_tool_params *mparams); > } while (0) > #define SECTION(name) __attribute__((section("__DATA, " #name))) >=20 > -struct image_type_params **__start_image_type, **__stop_image_type; > #else > #define INIT_SECTION(name) /* no-op for ELF */ > #define SECTION(name) __attribute__((section(#name))) > --=20 > 2.30.1 (Apple Git-130)