about summary refs log tree commit diff stats
path: root/src/include
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-01-01 16:13:39 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-01-01 16:13:39 +0100
commitee5398b3be5d45ec39e21b503d4ee8023a665141 (patch)
treee44a6f4233c65c22b41d9219772e548613fb7acc /src/include
parent3d3ab0fedc2b98f7adb84e898ffb32f24a2a1a6a (diff)
downloadbox64-ee5398b3be5d45ec39e21b503d4ee8023a665141.tar.gz
box64-ee5398b3be5d45ec39e21b503d4ee8023a665141.zip
Refactored (again) lib init/fini mecanism
Diffstat (limited to 'src/include')
-rwxr-xr-xsrc/include/box64context.h8
-rwxr-xr-xsrc/include/elfloader.h2
-rwxr-xr-xsrc/include/librarian.h2
-rwxr-xr-xsrc/include/library.h6
4 files changed, 12 insertions, 6 deletions
diff --git a/src/include/box64context.h b/src/include/box64context.h
index 682cdae8..3d8e0061 100755
--- a/src/include/box64context.h
+++ b/src/include/box64context.h
@@ -49,10 +49,13 @@ void free_tlsdatasize(void* p);
 typedef struct needed_libs_s {
     int         cap;
     int         size;
-    library_t   **libs;
+    char**      names;
+    library_t** libs;
 } needed_libs_t;
 
 void free_neededlib(needed_libs_t* needed);
+needed_libs_t* new_neededlib(int n);
+void add1_neededlib(needed_libs_t* needed);
 
 typedef struct base_segment_s {
     uintptr_t       base;
@@ -95,7 +98,8 @@ typedef struct box64context_s {
     int                 elfsize;        // number of elf loaded
 
 
-    needed_libs_t       neededlibs;     // needed libs for main elf
+    needed_libs_t       *neededlibs;    // needed libs for main elf
+    needed_libs_t       *preload;
 
     uintptr_t           ep;             // entry point
 
diff --git a/src/include/elfloader.h b/src/include/elfloader.h
index 891a62ac..d5116f56 100755
--- a/src/include/elfloader.h
+++ b/src/include/elfloader.h
@@ -31,7 +31,7 @@ void CalcStack(elfheader_t* h, uint64_t* stacksz, size_t* stackalign);
 uintptr_t GetEntryPoint(lib_t* maplib, elfheader_t* h);
 uintptr_t GetLastByte(elfheader_t* h);
 void AddSymbols(lib_t *maplib, kh_mapsymbols_t* mapsymbols, kh_mapsymbols_t* weaksymbols, kh_mapsymbols_t* localsymbols, elfheader_t* h);
-int LoadNeededLibs(elfheader_t* h, lib_t *maplib, needed_libs_t* neededlibs, library_t *deplib, int local, int bindnow, box64context_t *box64, x64emu_t* emu);
+int LoadNeededLibs(elfheader_t* h, lib_t *maplib, int local, int bindnow, box64context_t *box64, x64emu_t* emu);
 uintptr_t GetElfInit(elfheader_t* h);
 uintptr_t GetElfFini(elfheader_t* h);
 void RefreshElfTLS(elfheader_t* h);
diff --git a/src/include/librarian.h b/src/include/librarian.h
index 87a78a34..5c1fe0f2 100755
--- a/src/include/librarian.h
+++ b/src/include/librarian.h
@@ -21,7 +21,7 @@ void FreeDLPrivate(dlprivate_t **lib);
 
 box64context_t* GetLibrarianContext(lib_t* maplib);
 kh_mapsymbols_t* GetGlobalData(lib_t* maplib);
-int AddNeededLib(lib_t* maplib, needed_libs_t* neededlibs, library_t* deplib, int local, int bindnow, const char** paths, int npath, box64context_t* box64, x64emu_t* emu); // 0=success, 1=error
+int AddNeededLib(lib_t* maplib, int local, int bindnow, needed_libs_t* needed, box64context_t* box64, x64emu_t* emu); // 0=success, 1=error
 library_t* GetLibMapLib(lib_t* maplib, const char* name);
 library_t* GetLibInternal(const char* name);
 uintptr_t FindGlobalSymbol(lib_t *maplib, const char* name, int version, const char* vername);
diff --git a/src/include/library.h b/src/include/library.h
index b88aaa04..4fdfa65a 100755
--- a/src/include/library.h
+++ b/src/include/library.h
@@ -19,6 +19,7 @@ library_t *NewLibrary(const char* path, box64context_t* box64);
 int AddSymbolsLibrary(lib_t* maplib, library_t* lib, x64emu_t* emu);
 int FinalizeLibrary(library_t* lib, lib_t* local_maplib, int bindnow, x64emu_t* emu);
 int ReloadLibrary(library_t* lib, x64emu_t* emu);
+int FiniLibrary(library_t* lib, x64emu_t* emu);
 void InactiveLibrary(library_t* lib);
 void Free1Library(library_t **lib, x64emu_t* emu);
 
@@ -31,13 +32,14 @@ void fillGLProcWrapper(box64context_t* context);
 void freeGLProcWrapper(box64context_t* context);
 void fillALProcWrapper(box64context_t* context);
 void freeALProcWrapper(box64context_t* context);
-needed_libs_t* GetNeededLibs(library_t* lib);
-int GetNeededLibN(library_t* lib);
+char** GetNeededLibsNames(library_t* lib);
+int GetNeededLibsN(library_t* lib);
 library_t* GetNeededLib(library_t* lib, int idx);
 lib_t* GetMaplib(library_t* lib);
 
 int GetElfIndex(library_t* lib);    // -1 if no elf (i.e. wrapped)
 elfheader_t* GetElf(library_t* lib);    // NULL if no elf (i.e. wrapped)
 void* GetHandle(library_t* lib);    // NULL if not wrapped
+void IncRefCount(library_t* lib);
 
 #endif //__LIBRARY_H_