WiiUPluginLoaderBackend/source/plugin/DynamicLinkingHelper.h

67 lines
3.1 KiB
C
Raw Normal View History

#pragma once
2020-05-03 12:30:15 +02:00
2022-02-04 16:25:44 +01:00
#include "RelocationData.h"
#include <memory>
2018-09-22 19:52:52 +02:00
#include <string>
#include <vector>
2022-02-04 16:25:44 +01:00
#include <wums/defines/dynamic_linking_defines.h>
2018-09-22 19:52:52 +02:00
class DynamicLinkingHelper {
public:
/**
Gets the function entry for a given function name. If the function name is not present in the list, it will be added.
\param functionName Name of the function
\return Returns a pointer to the entry which contains the functionName. Null on error or if the list full.
**/
2020-05-03 12:30:15 +02:00
static dyn_linking_function_t *getOrAddFunctionEntryByName(dyn_linking_relocation_data_t *data, const char *functionName);
2018-09-22 19:52:52 +02:00
/**
Gets the function import entry for a given function name. If the import is not present in the list, it will be added.
This will return entries for _function_ imports.
\param importName Name of the function
\return Returns a pointer to the function import entry which contains the importName. Null on error or if the list full.
**/
2020-05-03 12:30:15 +02:00
static dyn_linking_import_t *getOrAddFunctionImportByName(dyn_linking_relocation_data_t *data, const char *importName);
2018-09-22 19:52:52 +02:00
/**
Gets the data import entry for a given data name. If the import is not present in the list, it will be added.
This will return entries for _data_ imports.
\param importName Name of the data
\return Returns a pointer to the data import entry which contains the importName. Null on error or if the list full.
**/
2020-05-03 12:30:15 +02:00
static dyn_linking_import_t *getOrAddDataImportByName(dyn_linking_relocation_data_t *data, const char *importName);
2018-09-22 19:52:52 +02:00
/**
Gets the import entry for a given data name and type. If the import is not present in the list, it will be added.
This will return entries for _data_ and _function_ imports, depending on the isData parameter.
\param importName Name of the data
\param isData Set this to true to return a data import
\return Returns a pointer to the data import entry which contains the importName. Null on error or if the list full.
**/
2020-05-03 12:30:15 +02:00
static dyn_linking_import_t *getOrAddImport(dyn_linking_relocation_data_t *data, const char *importName, bool isData);
2022-01-27 12:47:33 +01:00
static bool addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length,
const std::shared_ptr<RelocationData> &relocationData);
2018-09-22 19:52:52 +02:00
2020-05-03 12:30:15 +02:00
static bool
2021-09-25 14:26:18 +02:00
addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend,
const void *destination, const std::string &name,
2021-12-15 17:09:30 +01:00
const std::shared_ptr<ImportRPLInformation> &rplInfo);
2018-09-22 19:52:52 +02:00
2021-09-25 14:26:18 +02:00
static bool addReloationEntry(dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, const void *destination,
dyn_linking_function_t *functionName,
2020-05-03 12:30:15 +02:00
dyn_linking_import_t *importInfo);
2018-09-22 19:52:52 +02:00
private:
2020-12-26 14:17:50 +01:00
DynamicLinkingHelper() = default;
2018-09-22 19:52:52 +02:00
2020-12-26 14:17:50 +01:00
~DynamicLinkingHelper() = default;
2019-03-01 19:31:45 +01:00
};