* [PATCH V2] mkimage: fix segfault on MacOS arm64
@ 2022-01-16 23:07 Sergey V. Lobanov
2022-01-24 22:56 ` Sergey V. Lobanov
2022-01-24 23:00 ` Jessica Clarke
0 siblings, 2 replies; 4+ messages in thread
From: Sergey V. Lobanov @ 2022-01-16 23:07 UTC (permalink / raw)
To: u-boot; +Cc: Sergey V. Lobanov
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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2] mkimage: fix segfault on MacOS arm64
2022-01-16 23:07 [PATCH V2] mkimage: fix segfault on MacOS arm64 Sergey V. Lobanov
@ 2022-01-24 22:56 ` Sergey V. Lobanov
2022-01-24 23:00 ` Jessica Clarke
1 sibling, 0 replies; 4+ messages in thread
From: Sergey V. Lobanov @ 2022-01-24 22:56 UTC (permalink / raw)
To: u-boot; +Cc: jrtc27
CC: Jessica Clarke
> On 17 Jan 2022, at 02:07, Sergey V. Lobanov <sergey@lobanov.in> wrote:
>
> 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)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] mkimage: fix segfault on MacOS arm64
2022-01-16 23:07 [PATCH V2] mkimage: fix segfault on MacOS arm64 Sergey V. Lobanov
2022-01-24 22:56 ` Sergey V. Lobanov
@ 2022-01-24 23:00 ` Jessica Clarke
2022-01-24 23:31 ` Sergey V. Lobanov
1 sibling, 1 reply; 4+ messages in thread
From: Jessica Clarke @ 2022-01-24 23:00 UTC (permalink / raw)
To: Sergey V. Lobanov; +Cc: u-boot
On Mon, Jan 17, 2022 at 02:07:13AM +0300, Sergey V. Lobanov wrote:
> 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); \
This now seems sensible to me, thanks for fixing my mess.
Reviewed-by: Jessica Clarke <jrtc27@jrtc27.com>
(though you may want to clean up your commit message; "ased" is missing
the leading b and you're still missing the verb "is", plus "mechasim"
should be "mechanism" and it should be "due to the", not just "due")
Jess
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] mkimage: fix segfault on MacOS arm64
2022-01-24 23:00 ` Jessica Clarke
@ 2022-01-24 23:31 ` Sergey V. Lobanov
0 siblings, 0 replies; 4+ messages in thread
From: Sergey V. Lobanov @ 2022-01-24 23:31 UTC (permalink / raw)
To: Jessica Clarke; +Cc: u-boot
Thank you, Jessica.
I have rebased on current master, added Reviewed-by tag, fixed grammar/typos and sent v3
> On 25 Jan 2022, at 02:00, Jessica Clarke <jrtc27@jrtc27.com> wrote:
>
> On Mon, Jan 17, 2022 at 02:07:13AM +0300, Sergey V. Lobanov wrote:
>> 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); \
>
> This now seems sensible to me, thanks for fixing my mess.
>
> Reviewed-by: Jessica Clarke <jrtc27@jrtc27.com>
>
> (though you may want to clean up your commit message; "ased" is missing
> the leading b and you're still missing the verb "is", plus "mechasim"
> should be "mechanism" and it should be "due to the", not just "due")
>
> Jess
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-24 23:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-16 23:07 [PATCH V2] mkimage: fix segfault on MacOS arm64 Sergey V. Lobanov
2022-01-24 22:56 ` Sergey V. Lobanov
2022-01-24 23:00 ` Jessica Clarke
2022-01-24 23:31 ` Sergey V. Lobanov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.