216a8abd35d01561b121b2c69ed97fd76ef40f93
[openwrt/staging/wigyori.git] / tools / mkimage / patches / 090-macos-arm64-builing-fix.patch
1 This patch fixes compilation issues on MacOS arm64.
2 Based on discussion
3 https://github.com/u-boot/u-boot/commit/3b142045e8a7f0ab17b6099e9226296af45967d0
4
5 diff --git a/Makefile b/Makefile
6 index b4f1cbc..551041f 100644
7 --- a/Makefile
8 +++ b/Makefile
9 @@ -324,11 +324,6 @@ HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")
10 KBUILD_HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp")
11 KBUILD_HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
12
13 -# since Lion (10.7) ASLR is on by default, but we use linker generated lists
14 -# in some host tools which is a problem then ... so disable ASLR for these
15 -# tools
16 -KBUILD_HOSTLDFLAGS += $(call os_x_before, 10, 7, "", "-Xlinker -no_pie")
17 -
18 # macOS Mojave (10.14.X)
19 # Undefined symbols for architecture x86_64: "_PyArg_ParseTuple"
20 KBUILD_HOSTLDFLAGS += $(call os_x_after, 10, 14, "-lpython -dynamclib", "")
21 diff --git a/tools/imagetool.h b/tools/imagetool.h
22 index 8726792..d1b72ef 100644
23 --- a/tools/imagetool.h
24 +++ b/tools/imagetool.h
25 @@ -270,17 +270,20 @@ int rockchip_copy_image(int fd, struct image_tool_params *mparams);
26 * b) we need a API call to get the respective section symbols */
27 #if defined(__MACH__)
28 #include <mach-o/getsect.h>
29 +#include <mach-o/dyld.h>
30
31 #define INIT_SECTION(name) do { \
32 unsigned long name ## _len; \
33 - char *__cat(pstart_, name) = getsectdata("__TEXT", \
34 + char *__cat(pstart_, name) = getsectdata("__DATA", \
35 #name, &__cat(name, _len)); \
36 + __cat(pstart_, name) += \
37 + _dyld_get_image_vmaddr_slide(0); \
38 char *__cat(pstop_, name) = __cat(pstart_, name) + \
39 __cat(name, _len); \
40 __cat(__start_, name) = (void *)__cat(pstart_, name); \
41 __cat(__stop_, name) = (void *)__cat(pstop_, name); \
42 } while (0)
43 -#define SECTION(name) __attribute__((section("__TEXT, " #name)))
44 +#define SECTION(name) __attribute__((section("__DATA, " #name)))
45
46 struct image_type_params **__start_image_type, **__stop_image_type;
47 #else