From 32044725efdc67dada535fd26bcb2791b47f0245 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 21 Jan 2022 19:12:01 +0100 Subject: [PATCH] WUMS 0.3.1 add hook for calling __ini and __fini --- Makefile | 2 +- include/wums/common.h | 2 +- include/wums/defines/module_defines.h | 4 ++-- include/wums/exports.h | 2 +- include/wums/hooks.h | 19 ++++++++++++++++++- include/wums/meta.h | 18 ++++++++++-------- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index c24a35d..83f9453 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/share/wums_rules export WUMS_MAJOR := 0 export WUMS_MINOR := 3 -export WUMS_PATCH := 0 +export WUMS_PATCH := 1 VERSION := $(WUMS_MAJOR).$(WUMS_MINOR).$(WUMS_PATCH) diff --git a/include/wums/common.h b/include/wums/common.h index 8119f06..8c400ea 100644 --- a/include/wums/common.h +++ b/include/wums/common.h @@ -2,7 +2,7 @@ * by Alex Chadwick * * Copyright (C) 2014, Alex Chadwick - * Modified by Maschell, 2018-2021 + * Modified by Maschell, 2018-2022 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/wums/defines/module_defines.h b/include/wums/defines/module_defines.h index 7331f6a..4ca3f73 100644 --- a/include/wums/defines/module_defines.h +++ b/include/wums/defines/module_defines.h @@ -60,14 +60,14 @@ typedef struct module_information_single_t { uint32_t entrypoint; uint32_t startAddress; uint32_t endAddress; - uint8_t skipEntrypoint; + uint8_t skipInitFini; uint8_t initBeforeRelocationDoneHook; module_function_symbol_data_t * function_symbol_entries; uint32_t number_used_function_symbols; } module_information_single_t; #define MAXIMUM_MODULES 32 -#define MODULE_INFORMATION_VERSION 0x00000006 +#define MODULE_INFORMATION_VERSION 0x00000007 typedef struct module_information_t { uint32_t version; diff --git a/include/wums/exports.h b/include/wums/exports.h index ab33721..3b4a726 100644 --- a/include/wums/exports.h +++ b/include/wums/exports.h @@ -2,7 +2,7 @@ * by Alex Chadwick * * Copyright (C) 2014, Alex Chadwick - * Modified by Maschell, 2018-2021 + * Modified by Maschell, 2018-2022 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/wums/hooks.h b/include/wums/hooks.h index 6c92fc8..92d780c 100644 --- a/include/wums/hooks.h +++ b/include/wums/hooks.h @@ -2,7 +2,7 @@ * by Alex Chadwick * * Copyright (C) 2014, Alex Chadwick - * Modified by Maschell, 2018-2021 + * Modified by Maschell, 2018-2022 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -51,6 +51,9 @@ typedef enum wums_hook_type_t { WUMS_HOOK_INIT_WUT_SOCKETS, WUMS_HOOK_FINI_WUT_SOCKETS, + WUMS_HOOK_INIT_WRAPPER, /* Calls __init */ + WUMS_HOOK_FINI_WRAPPER, /* Calls __fini */ + WUMS_HOOK_INIT, WUMS_HOOK_APPLICATION_STARTS, WUMS_HOOK_APPLICATION_ENDS, @@ -156,6 +159,20 @@ typedef struct wums_relocs_done_args_t { __EXTERN_C_MACRO void __fini_wut_socket(); \ WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_SOCKETS,__fini_wut_socket) +#define WUMS___INIT_WRAPPER() \ + __EXTERN_C_MACRO void __init(); \ + void __init_wrapper(){ \ + __init(); \ + }\ + WUMS_HOOK_EX(WUMS_HOOK_INIT_WRAPPER,__init_wrapper); + +#define WUMS___FINI_WRAPPER() \ + __EXTERN_C_MACRO void __fini(); \ + void __fini_wrapper(){ \ + __fini(); \ + }\ + WUMS_HOOK_EX(WUMS_HOOK_FINI_WRAPPER,__fini_wrapper); + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/wums/meta.h b/include/wums/meta.h index 285eeb4..6982c5c 100644 --- a/include/wums/meta.h +++ b/include/wums/meta.h @@ -2,7 +2,7 @@ * by Alex Chadwick * * Copyright (C) 2014, Alex Chadwick - * Modified by Maschell, 2018-2021 + * Modified by Maschell, 2018-2022 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,20 +32,22 @@ extern "C" { #endif -#define WUMS_MODULE_EXPORT_NAME(x) \ - WUMS_META(export_name, x); \ - WUMS_META(wum, "0.2"); \ - WUMS_USE_WUT_MALLOC(); \ - WUMS_USE_WUT_SOCKETS(); \ +#define WUMS_MODULE_EXPORT_NAME(x) \ + WUMS_META(export_name, x); \ + WUMS_META(wum, "0.3.1"); \ + WUMS_USE_WUT_MALLOC(); \ + WUMS_USE_WUT_SOCKETS(); \ WUMS_USE_WUT_NEWLIB(); \ - WUMS_USE_WUT_STDCPP(); \ + WUMS_USE_WUT_STDCPP(); \ + WUMS___INIT_WRAPPER(); \ + WUMS___FINI_WRAPPER(); \ WUMS_META(buildtimestamp, __DATE__ " " __TIME__) #define WUMS_MODULE_AUTHOR(x) WUMS_META(author, x) #define WUMS_MODULE_VERSION(x) WUMS_META(version, x) #define WUMS_MODULE_LICENSE(x) WUMS_META(license, x) #define WUMS_MODULE_DESCRIPTION(x) WUMS_META(description, x) -#define WUMS_MODULE_SKIP_ENTRYPOINT() WUMS_META(skipEntrypoint, "true") +#define WUMS_MODULE_SKIP_INIT_FINI() WUMS_META(skipInitFini, "true") #define WUMS_MODULE_INIT_BEFORE_RELOCATION_DONE_HOOK() WUMS_META(initBeforeRelocationDoneHook, "true") #ifdef __cplusplus