about summary refs log tree commit diff stats
path: root/src/elfs/elfloader.c
diff options
context:
space:
mode:
authorrajdakin <rajdakin@gmail.com>2021-04-09 17:52:59 +0200
committerrajdakin <rajdakin@gmail.com>2021-04-09 17:52:59 +0200
commit70018a774bf7411ef7550aa4fb3eb153d17dcfd6 (patch)
treebd8a6c823b307e1a431a01ea3e27b8d0ac282bfe /src/elfs/elfloader.c
parent009bb94f17803dff459b812d7314e300a1b31e1e (diff)
downloadbox64-70018a774bf7411ef7550aa4fb3eb153d17dcfd6.tar.gz
box64-70018a774bf7411ef7550aa4fb3eb153d17dcfd6.zip
Fixed the libraries free ordering
Diffstat (limited to 'src/elfs/elfloader.c')
-rwxr-xr-xsrc/elfs/elfloader.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c
index dd37a3fb..f31dc71f 100755
--- a/src/elfs/elfloader.c
+++ b/src/elfs/elfloader.c
@@ -920,7 +920,7 @@ $PLATFORM – Expands to the processor type of the current machine (see the
 uname(1) man page description of the -i option). For more details of this token
 expansion, see “System Specific Shared Objects”
 */
-int LoadNeededLibs(elfheader_t* h, lib_t *maplib, needed_libs_t* neededlibs, int local, box64context_t *box64, x64emu_t* emu)
+int LoadNeededLibs(elfheader_t* h, lib_t *maplib, needed_libs_t* neededlibs, library_t *deplib, int local, box64context_t *box64, x64emu_t* emu)
 {
     DumpDynamicRPath(h);
     // update RPATH first
@@ -973,8 +973,8 @@ int LoadNeededLibs(elfheader_t* h, lib_t *maplib, needed_libs_t* neededlibs, int
     for (int i=0; i<h->numDynamic; ++i)
         if(h->Dynamic[i].d_tag==DT_NEEDED) {
             char *needed = h->DynStrTab+h->delta+h->Dynamic[i].d_un.d_val;
-            // TODO: Add LD_LIBRARY_PATH and RPATH Handling
-            if(AddNeededLib(maplib, neededlibs, local, needed, box64, emu)) {
+            // TODO: Add LD_LIBRARY_PATH and RPATH handling
+            if(AddNeededLib(maplib, neededlibs, deplib, local, needed, box64, emu)) {
                 printf_log(LOG_INFO, "Error loading needed lib: \"%s\"\n", needed);
                 if(!allow_missing_libs)
                     return 1;   //error...
@@ -1056,7 +1056,7 @@ void RunElfFini(elfheader_t* h, x64emu_t *emu)
     h->fini_done = 1;
     // first check fini array
     Elf64_Addr *addr = (Elf64_Addr*)(h->finiarray + h->delta);
-    for (int i=0; i<h->finiarray_sz; ++i) {
+    for (int i=h->finiarray_sz-1; i>=0; --i) {
         printf_log(LOG_DEBUG, "Calling Fini[%d] for %s @%p\n", i, ElfName(h), (void*)addr[i]);
         RunFunctionWithEmu(emu, 0, (uintptr_t)addr[i], 0);
     }