about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-11-30 21:37:55 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-11-30 21:37:55 +0100
commit8cd27fca4d6c3724d4028096a6a654431db79692 (patch)
tree9aa617e4e9399411840850f3572a8065e8c42f1e /src
parent3676ca15c892558dea0d4b1bda7c939486116a38 (diff)
downloadbox64-8cd27fca4d6c3724d4028096a6a654431db79692.tar.gz
box64-8cd27fca4d6c3724d4028096a6a654431db79692.zip
Added support for wrapped libbsd (needed for latest libstdc++ lib)
Diffstat (limited to 'src')
-rw-r--r--src/library_list.h1
-rw-r--r--src/wrapped/generated/functions_list.txt1
-rw-r--r--src/wrapped/generated/wrappedlibbsddefs.h8
-rw-r--r--src/wrapped/generated/wrappedlibbsdtypes.h17
-rw-r--r--src/wrapped/generated/wrappedlibbsdundefs.h8
-rw-r--r--src/wrapped/wrappedlibbsd.c31
-rw-r--r--src/wrapped/wrappedlibbsd_private.h112
-rw-r--r--src/wrapped/wrappedlibc.c15
-rw-r--r--src/wrapped/wrappedlibc_private.h4
9 files changed, 187 insertions, 10 deletions
diff --git a/src/library_list.h b/src/library_list.h
index 26a1c80e..c5456170 100644
--- a/src/library_list.h
+++ b/src/library_list.h
@@ -5,6 +5,7 @@
 GO("libc.musl-x86_64.so.1", libcmusl)
 GO("libpthread.so.0", libpthread)
 GO("librt.so.1", librt)
+GO("libbsd.so.0", libbsd)
 GO("libEGL.so.1", libegl)
 GO("libGL.so.1", libgl)
 GO("libGL.so", libgl)
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index e6d3044b..3d56e9ae 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -3911,6 +3911,7 @@ wrappedlibasound:
   - snd_async_add_pcm_handler
 - pFpipL:
   - snd_dlopen
+wrappedlibbsd:
 wrappedlibc:
 - vFv:
   - _Jv_RegisterClasses
diff --git a/src/wrapped/generated/wrappedlibbsddefs.h b/src/wrapped/generated/wrappedlibbsddefs.h
new file mode 100644
index 00000000..6196b6c3
--- /dev/null
+++ b/src/wrapped/generated/wrappedlibbsddefs.h
@@ -0,0 +1,8 @@
+/*******************************************************************
+ * File automatically generated by rebuild_wrappers.py (v2.2.0.18) *
+ *******************************************************************/
+#ifndef __wrappedlibbsdDEFS_H_
+#define __wrappedlibbsdDEFS_H_
+
+
+#endif // __wrappedlibbsdDEFS_H_
diff --git a/src/wrapped/generated/wrappedlibbsdtypes.h b/src/wrapped/generated/wrappedlibbsdtypes.h
new file mode 100644
index 00000000..4bf0567a
--- /dev/null
+++ b/src/wrapped/generated/wrappedlibbsdtypes.h
@@ -0,0 +1,17 @@
+/*******************************************************************
+ * File automatically generated by rebuild_wrappers.py (v2.2.0.18) *
+ *******************************************************************/
+#ifndef __wrappedlibbsdTYPES_H_
+#define __wrappedlibbsdTYPES_H_
+
+#ifndef LIBNAME
+#error You should only #include this file inside a wrapped*.c file
+#endif
+#ifndef ADDED_FUNCTIONS
+#define ADDED_FUNCTIONS() 
+#endif
+
+
+#define SUPER() ADDED_FUNCTIONS()
+
+#endif // __wrappedlibbsdTYPES_H_
diff --git a/src/wrapped/generated/wrappedlibbsdundefs.h b/src/wrapped/generated/wrappedlibbsdundefs.h
new file mode 100644
index 00000000..82311e18
--- /dev/null
+++ b/src/wrapped/generated/wrappedlibbsdundefs.h
@@ -0,0 +1,8 @@
+/*******************************************************************
+ * File automatically generated by rebuild_wrappers.py (v2.2.0.18) *
+ *******************************************************************/
+#ifndef __wrappedlibbsdUNDEFS_H_
+#define __wrappedlibbsdUNDEFS_H_
+
+
+#endif // __wrappedlibbsdUNDEFS_H_
diff --git a/src/wrapped/wrappedlibbsd.c b/src/wrapped/wrappedlibbsd.c
new file mode 100644
index 00000000..11428d46
--- /dev/null
+++ b/src/wrapped/wrappedlibbsd.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define _GNU_SOURCE         /* See feature_test_macros(7) */
+#include <dlfcn.h>
+
+#include "wrappedlibs.h"
+
+#include "debug.h"
+#include "wrapper.h"
+#include "bridge.h"
+#include "librarian/library_private.h"
+#include "x64emu.h"
+#include "emu/x64emu_private.h"
+#include "elfloader.h"
+#include "box64context.h"
+#include "x64tls.h"
+
+
+// don't try to load the actual ld-linux (because name is variable), just use box64 itself, as it's linked to ld-linux
+const char* libbsdName = "libbsd.so.0";
+#define LIBNAME libbsd
+
+#define PRE_INIT\
+    if(1)                                                           \
+        lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);    \
+    else
+
+// define all standard library functions
+#include "wrappedlib_init.h"
+
diff --git a/src/wrapped/wrappedlibbsd_private.h b/src/wrapped/wrappedlibbsd_private.h
new file mode 100644
index 00000000..bded8d13
--- /dev/null
+++ b/src/wrapped/wrappedlibbsd_private.h
@@ -0,0 +1,112 @@
+#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA))
+#error meh!
+#endif
+
+GO(arc4random, uFv)
+GO(arc4random_addrandom, vFpi)
+GO(arc4random_buf, vFpL)
+GO(arc4random_stir, vFv)
+GO(arc4random_uniform, uFu)
+//GO(bsd_getopt, 
+//GO(closefrom, 
+//GO(dehumanize_number, 
+//GO(errc, 
+//GO(expand_number, 
+//GO(explicit_bzero, 
+//GO(__fdnlist, 
+//GO(fgetln, 
+//GO(fgetwln, 
+//GO(flopen, 
+//GO(flopenat, 
+//GO(fmtcheck, 
+//GO(fparseln, 
+//GO(fpurge, 
+//GO(freezero, 
+//GO(funopen, 
+//GO(getbsize, 
+//GO(getmode, 
+//GO(getpeereid, 
+GO(getprogname, pFv)
+//GO(gid_from_group, 
+//GO(group_from_gid, 
+//GO(heapsort, 
+//GO(humanize_number, 
+//GO(inet_net_pton@@LIBBSD_0.0, 
+//GO(_int_to_time, 
+//GO(_long_to_time, 
+//GO(MD5Data, 
+//GO(MD5End, 
+//GO(MD5File, 
+//GO(MD5FileChunk, 
+//GO(MD5Final, 
+//GO(MD5Init, 
+//GO(MD5Pad, 
+//GO(MD5Transform, 
+//GO(MD5Update, 
+//GO(mergesort, 
+//GO(nlist, 
+//GO(nvis, 
+//DATAB(optreset, 
+//GO(pidfile_close, 
+//GO(pidfile_fileno, 
+//GO(pidfile_open, 
+//GO(pidfile_remove, 
+//GO(pidfile_write, 
+//GO(radixsort, 
+//GO(readpassphrase, 
+//GO(reallocarray, 
+//GO(reallocf, 
+//GO(recallocarray, 
+//GO(setmode, 
+//GO(setproctitle@LIBBSD_0.2, 
+//GO(setproctitle, 
+//GO(setproctitle_init, 
+GO(setprogname, vFp)
+//GO(sl_add, 
+//GO(sl_find, 
+//GO(sl_free, 
+//GO(sl_init, 
+//GO(snvis, 
+//GO(sradixsort, 
+//GO(stravis, 
+//GO(strenvisx, 
+//GO(strlcat, 
+//GO(strlcpy, 
+//GO(strmode, 
+//GO(strnstr, 
+//GO(strnunvis, 
+//GO(strnunvis@LIBBSD_0.9.1, 
+//GO(strnunvis_netbsd.1, 
+//GO(strnunvisx, 
+//GO(strnvis@LIBBSD_0.9.1, 
+//GO(strnvis, 
+//GO(strnvis_netbsd, 
+//GO(strnvisx, 
+//GO(strsenvisx, 
+//GO(strsnvis, 
+//GO(strsnvisx, 
+//GO(strsvis, 
+//GO(strsvisx, 
+//GO(strtoi, 
+//GO(strtonum, 
+//GO(strtou, 
+//GO(strunvis, 
+//GO(strunvisx, 
+//GO(strvis, 
+//GO(strvisx, 
+//GO(svis, 
+//GO(_time32_to_time, 
+//GO(_time64_to_time, 
+//GO(_time_to_int, 
+//GO(_time_to_long, 
+//GO(_time_to_time32, 
+//GO(_time_to_time64, 
+//GO(uid_from_user, 
+//GO(unvis, 
+//GO(user_from_uid, 
+//GO(verrc, 
+//GO(vis, 
+//GO(vwarnc, 
+//GO(warnc, 
+//GO(wcslcat, 
+//GO(wcslcpy, 
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 24f1cc5a..60aac36a 100644
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -3361,24 +3361,27 @@ EXPORT char my___libc_single_threaded = 0;
 
 #ifdef ANDROID
 #define NEEDED_LIBS   0
-#define NEEDED_LIBS_234 3,  \
+#define NEEDED_LIBS_234 4,  \
     "libpthread.so.0",      \
     "libdl.so.2" ,          \
-    "libm.so"
+    "libm.so",              \
+    "libbsd.so"
 #else
-#define NEEDED_LIBS   5,    \
+#define NEEDED_LIBS   6,    \
     "ld-linux-x86-64.so.2", \
     "libpthread.so.0",      \
     "libdl.so.2",           \
     "libutil.so.1",         \
-    "librt.so.1"
-#define NEEDED_LIBS_234 6,  \
+    "librt.so.1",           \
+    "libbsd.so.0"
+#define NEEDED_LIBS_234 7,  \
     "ld-linux-x86-64.so.2", \
     "libpthread.so.0",      \
     "libdl.so.2",           \
     "libutil.so.1",         \
     "libresolv.so.2",       \
-    "librt.so.1"
+    "librt.so.1",           \
+    "libbsd.so.0"
 #endif
 
 #define CUSTOM_INIT         \
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index 380f7782..cd65c416 100644
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -2429,12 +2429,8 @@ GO(dummy__ZnwmSt11align_val_tRKSt9nothrow_t, pFLLp) // for mallochook.c
 #ifdef ANDROID
 GOM(__libc_init, vFEpppp)
 GO(__errno, pFv)
-GO(setprogname, vFp)
-GO(getprogname, pFv)
 #else
 // Those symbols don't exist in non-Android builds
 //GOM(__libc_init,
 //GO(__errno,
-//GO(setprogname,
-//GO(getprogname,
 #endif