From beb34205ed5bf78675da1495926c4be248460aeb Mon Sep 17 00:00:00 2001 From: lean Date: Mon, 11 Jul 2022 02:21:47 +0800 Subject: [PATCH] mkimage: fix segfault on MacOS arm64 M1/M2 --- .../patches/090-macos-arm64-builing-fix.patch | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tools/mkimage/patches/090-macos-arm64-builing-fix.patch diff --git a/tools/mkimage/patches/090-macos-arm64-builing-fix.patch b/tools/mkimage/patches/090-macos-arm64-builing-fix.patch new file mode 100644 index 000000000..8bc89784b --- /dev/null +++ b/tools/mkimage/patches/090-macos-arm64-builing-fix.patch @@ -0,0 +1,32 @@ +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 + +-#define INIT_SECTION(name) do { \ ++#define INIT_SECTION(name) struct image_type_params \ ++ **__cat(__start_, name), **__cat(__stop_, 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); \ +@@ -283,7 +288,6 @@ int rockchip_copy_image(int fd, struct image_tool_params *mparams); + } while (0) + #define SECTION(name) __attribute__((section("__DATA, " #name))) + +-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))) +-- +2.30.1 (Apple Git-130)