2024-05-10 22:58:39 +00:00
|
|
|
--- a/linux-user/syscall.c
|
|
|
|
+++ b/linux-user/syscall.c
|
|
|
|
@@ -17,6 +17,7 @@
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#define _ATFILE_SOURCE
|
|
|
|
+#include <dlfcn.h>
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "qemu/cutils.h"
|
|
|
|
#include "qemu/path.h"
|
2024-05-12 01:14:14 +00:00
|
|
|
@@ -9070,6 +9071,17 @@ _syscall5(int, sys_move_mount, int, __from_dfd, const char *, __from_pathname,
|
2024-05-10 22:58:39 +00:00
|
|
|
int, __to_dfd, const char *, __to_pathname, unsigned int, flag)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+// g2h For Trampoline
|
|
|
|
+static CPUState *_trampoline_g2h_cpu = NULL;
|
|
|
|
+static void *_trampoline_g2h(uint32_t guest_addr) {
|
2024-05-12 01:14:14 +00:00
|
|
|
+ if (guest_addr == 0) {
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
2024-05-10 22:58:39 +00:00
|
|
|
+ return g2h(_trampoline_g2h_cpu, guest_addr);
|
|
|
|
+}
|
|
|
|
+// Trampoline Function
|
2024-05-12 01:14:14 +00:00
|
|
|
+typedef void (*_trampoline_t)(typeof(_trampoline_g2h) *g2h, uint32_t id, uint32_t *args);
|
2024-05-10 22:58:39 +00:00
|
|
|
+
|
|
|
|
/* This is an internal helper for do_syscall so that it is easier
|
|
|
|
* to have a single return point, so that actions, such as logging
|
|
|
|
* of syscall results, can be performed.
|
2024-05-12 01:14:14 +00:00
|
|
|
@@ -9095,6 +9107,27 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
|
2024-05-10 22:58:39 +00:00
|
|
|
void *p;
|
|
|
|
|
|
|
|
switch(num) {
|
|
|
|
+ case 0x1337: {
|
|
|
|
+ // Load Trampoline
|
|
|
|
+ static _trampoline_t _trampoline = NULL;
|
|
|
|
+ if (_trampoline == NULL) {
|
|
|
|
+ // Open Library
|
2024-05-12 01:14:14 +00:00
|
|
|
+ void *_trampoline_handle = dlopen("libmedia-layer-trampoline.so", RTLD_NOW);
|
2024-05-10 22:58:39 +00:00
|
|
|
+ // Load Function
|
|
|
|
+ if (_trampoline_handle != NULL) {
|
|
|
|
+ _trampoline = dlsym(_trampoline_handle, "trampoline");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (_trampoline == NULL) {
|
|
|
|
+ // Failed To Load
|
|
|
|
+ qemu_log_mask(LOG_UNIMP, "Unable To Load Media Layer Trampoline: %s\n", dlerror());
|
|
|
|
+ return -TARGET_ENOSYS;
|
|
|
|
+ }
|
|
|
|
+ // Call Trampoline
|
|
|
|
+ _trampoline_g2h_cpu = cpu;
|
2024-05-12 01:14:14 +00:00
|
|
|
+ _trampoline(_trampoline_g2h, arg1, g2h(cpu, arg2));
|
|
|
|
+ return 0;
|
2024-05-10 22:58:39 +00:00
|
|
|
+ }
|
|
|
|
case TARGET_NR_exit:
|
|
|
|
/* In old applications this may be used to implement _exit(2).
|
|
|
|
However in threaded applications it is used for thread termination,
|