From be06cb25e905e1a130746668018fdde58e3305f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 11 Sep 2019 20:49:32 +0200 Subject: [PATCH] libroot: make API version available. Change-Id: I370d5c8e9b4f076e7f115ca6c87bc7f943d36c17 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1850 Reviewed-by: Rene Gollent --- headers/private/libroot/libroot_private.h | 1 + headers/private/runtime_loader/runtime_loader.h | 1 + src/system/libroot/libroot_init.c | 2 ++ src/system/runtime_loader/elf_load_image.cpp | 2 +- src/system/runtime_loader/export.cpp | 9 +++++++-- src/system/runtime_loader/runtime_loader_private.h | 2 +- 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/headers/private/libroot/libroot_private.h b/headers/private/libroot/libroot_private.h index 1126704be6..a54e7d2b30 100644 --- a/headers/private/libroot/libroot_private.h +++ b/headers/private/libroot/libroot_private.h @@ -19,6 +19,7 @@ extern "C" { #endif extern int __gABIVersion; +extern int __gAPIVersion; extern char _single_threaded; /* This determines if a process runs single threaded or not */ diff --git a/headers/private/runtime_loader/runtime_loader.h b/headers/private/runtime_loader/runtime_loader.h index 94be94cbf4..96f91dec0a 100644 --- a/headers/private/runtime_loader/runtime_loader.h +++ b/headers/private/runtime_loader/runtime_loader.h @@ -57,6 +57,7 @@ struct rld_export { const struct user_space_program_args *program_args; const void* commpage_address; int abi_version; + int api_version; }; extern struct rld_export *__gRuntimeLoader; diff --git a/src/system/libroot/libroot_init.c b/src/system/libroot/libroot_init.c index 6da22d4bbd..3dfe64ee6a 100644 --- a/src/system/libroot/libroot_init.c +++ b/src/system/libroot/libroot_init.c @@ -30,6 +30,7 @@ int __libc_argc; char **__libc_argv; int __gABIVersion; +int __gAPIVersion; int32 __gCPUCount; char _single_threaded = true; @@ -51,6 +52,7 @@ initialize_before(image_id imageID) char *programPath = __gRuntimeLoader->program_args->args[0]; __gCommPageAddress = __gRuntimeLoader->commpage_address; __gABIVersion = __gRuntimeLoader->abi_version; + __gAPIVersion = __gRuntimeLoader->api_version; if (programPath) { if ((__progname = strrchr(programPath, '/')) == NULL) diff --git a/src/system/runtime_loader/elf_load_image.cpp b/src/system/runtime_loader/elf_load_image.cpp index fc0267ed26..2e90e15ef2 100644 --- a/src/system/runtime_loader/elf_load_image.cpp +++ b/src/system/runtime_loader/elf_load_image.cpp @@ -641,7 +641,7 @@ load_image(char const* name, image_type type, const char* rpath, #endif } - set_abi_version(image->abi); + set_abi_api_version(image->abi, image->api_version); // init gcc version dependent image flags // symbol resolution strategy diff --git a/src/system/runtime_loader/export.cpp b/src/system/runtime_loader/export.cpp index 2922b7d77d..493ef5d5c5 100644 --- a/src/system/runtime_loader/export.cpp +++ b/src/system/runtime_loader/export.cpp @@ -93,13 +93,18 @@ rldexport_init(void) /*! Is called for all images, and sets the minimum ABI version found to the - gRuntimeLoader.abi_version field. + gRuntimeLoader.abi_version field and the minimum API version found to the + gRuntimeLoader.api_version field. */ void -set_abi_version(int abi_version) +set_abi_api_version(int abi_version, int api_version) { if (gRuntimeLoader.abi_version == 0 || gRuntimeLoader.abi_version > abi_version) { gRuntimeLoader.abi_version = abi_version; } + if (gRuntimeLoader.api_version == 0 + || gRuntimeLoader.api_version > api_version) { + gRuntimeLoader.api_version = api_version; + } } diff --git a/src/system/runtime_loader/runtime_loader_private.h b/src/system/runtime_loader/runtime_loader_private.h index e2886285e0..816fc39006 100644 --- a/src/system/runtime_loader/runtime_loader_private.h +++ b/src/system/runtime_loader/runtime_loader_private.h @@ -99,7 +99,7 @@ status_t elf64_verify_header(void *header, size_t length); #endif // _COMPAT_MODE void rldelf_init(void); void rldexport_init(void); -void set_abi_version(int abi_version); +void set_abi_api_version(int abi_version, int api_version); status_t elf_reinit_after_fork(); status_t heap_init();