From fe05d45cde810e307e6883aa519c8092be5a0376 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Thu, 4 Feb 2021 20:39:45 -0800 Subject: [PATCH] [libc] Cache self handle in libc When libc_init iterates the initv values, cache the process' self handle. --- src/libraries/libc/arch/x86_64/init_libc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libraries/libc/arch/x86_64/init_libc.c b/src/libraries/libc/arch/x86_64/init_libc.c index 466b97a..3e60dff 100644 --- a/src/libraries/libc/arch/x86_64/init_libc.c +++ b/src/libraries/libc/arch/x86_64/init_libc.c @@ -6,6 +6,7 @@ static size_t __initc = 0; static struct j6_init_value *__initv = 0; j6_handle_t __handle_sys = j6_handle_invalid; +j6_handle_t __handle_self = j6_handle_invalid; void _get_init(size_t *initc, struct j6_init_value **initv) @@ -31,7 +32,10 @@ _init_libc(uint64_t *rsp) if (__initv[i].type == j6_init_handle_other && __initv[i].handle.type == j6_object_type_system) { __handle_sys = __initv[i].handle.handle; - break; + } + else if (__initv[i].type == j6_init_handle_self && + __initv[i].handle.type == j6_object_type_process) { + __handle_self = __initv[i].handle.handle; } } }