public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Sergey V. Lobanov" <sergey@lobanov.in>
To: u-boot@lists.denx.de
Cc: "Sergey V. Lobanov" <sergey@lobanov.in>
Subject: [PATCH V2] mkimage: fix segfault on MacOS arm64
Date: Mon, 17 Jan 2022 02:07:13 +0300	[thread overview]
Message-ID: <20220116230713.20175-1-sergey@lobanov.in> (raw)

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 <sergey@lobanov.in>
---
 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 <mach-o/getsect.h>
+#include <mach-o/dyld.h>
 
 #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);	\
-- 
2.32.0 (Apple Git-132)


             reply	other threads:[~2022-01-16 23:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-16 23:07 Sergey V. Lobanov [this message]
2022-01-24 22:56 ` [PATCH V2] mkimage: fix segfault on MacOS arm64 Sergey V. Lobanov
2022-01-24 23:00 ` Jessica Clarke
2022-01-24 23:31   ` Sergey V. Lobanov

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-all 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=20220116230713.20175-1-sergey@lobanov.in \
    --to=sergey@lobanov.in \
    --cc=u-boot@lists.denx.de \
    /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