From patchwork Sun Jan 16 23:07:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sergey V. Lobanov" X-Patchwork-Id: 1580568 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JcW0H4d4gz9sXM for ; Mon, 17 Jan 2022 10:07:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 921C383458; Mon, 17 Jan 2022 00:07:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=lobanov.in Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 1D20A834F0; Mon, 17 Jan 2022 00:07:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1948C83025 for ; Mon, 17 Jan 2022 00:07:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=lobanov.in Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sergey@lobanov.in Received: from forward101q.mail.yandex.net (forward101q.mail.yandex.net [IPv6:2a02:6b8:c0e:4b:0:640:4012:bb98]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 2FCE05A0BC5 for ; Mon, 17 Jan 2022 02:07:25 +0300 (MSK) Received: from vla1-348f4ad01998.qloud-c.yandex.net (vla1-348f4ad01998.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:1a00:0:640:348f:4ad0]) by forward101q.mail.yandex.net (Yandex) with ESMTP id 2D81C13E80002 for ; Mon, 17 Jan 2022 02:07:25 +0300 (MSK) Received: from vla5-3832771863b8.qloud-c.yandex.net (vla5-3832771863b8.qloud-c.yandex.net [2a02:6b8:c18:3417:0:640:3832:7718]) by vla1-348f4ad01998.qloud-c.yandex.net (mxback/Yandex) with ESMTP id ZZsI8TE2h8-7OfS21jU; Mon, 17 Jan 2022 02:07:25 +0300 Authentication-Results: vla1-348f4ad01998.qloud-c.yandex.net; dkim=pass Received: by vla5-3832771863b8.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id ED4rzdehSP-7OTuw3Ej; Mon, 17 Jan 2022 02:07:24 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Fwd: 2 From: "Sergey V. Lobanov" To: u-boot@lists.denx.de Cc: "Sergey V. Lobanov" Subject: [PATCH V2] mkimage: fix segfault on MacOS arm64 Date: Mon, 17 Jan 2022 02:07:13 +0300 Message-Id: <20220116230713.20175-1-sergey@lobanov.in> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 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 mkimage segfaults due ASLR mechasim on MacOS arm64 It is required to use _dyld_get_image_vmaddr_slide() to prevent segfault on MacOS arm64 This patch ased on the discussion https://github.com/u-boot/u-boot/commit/3b142045e8a7f0ab17b6099e9226296af45967d0 Thanks to Ronny Kotzschmar and ptpt52 github user Signed-off-by: Sergey V. Lobanov Reviewed-by: Jessica Clarke --- tools/imagetool.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/imagetool.h b/tools/imagetool.h index e229a34ffc..a0985d93d2 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -271,11 +271,13 @@ 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 #define INIT_SECTION(name) do { \ unsigned long name ## _len; \ char *__cat(pstart_, name) = getsectdata("__DATA", \ #name, &__cat(name, _len)); \ + __cat(pstart_, name) += _dyld_get_image_vmaddr_slide(0);\ char *__cat(pstop_, name) = __cat(pstart_, name) + \ __cat(name, _len); \ __cat(__start_, name) = (void *)__cat(pstart_, name); \