mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
add back support for loading libraries linked against bionic
This commit is contained in:
parent
d0962b9974
commit
2f785e2a59
1 changed files with 35 additions and 0 deletions
35
src/main.c
35
src/main.c
|
@ -8,6 +8,39 @@
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
// for getting _r_debug out of the dynamic section
|
||||||
|
// this is needed by the shim bionic linker to register stuff with gdb
|
||||||
|
#include <elf.h>
|
||||||
|
#include <link.h>
|
||||||
|
|
||||||
|
// the dynamic section
|
||||||
|
extern Elf64_Dyn _DYNAMIC[];
|
||||||
|
|
||||||
|
extern struct r_debug *_r_debug_ptr;
|
||||||
|
void init__r_debug() {
|
||||||
|
#if defined(_r_debug)
|
||||||
|
// _r_debug is defined by glibc and is declared as extern in link.h
|
||||||
|
_r_debug_ptr = &_r_debug;
|
||||||
|
#else
|
||||||
|
int i = 0;
|
||||||
|
Elf64_Dyn current;
|
||||||
|
|
||||||
|
do {
|
||||||
|
current = _DYNAMIC[i];
|
||||||
|
if(current.d_tag == 0x15) {
|
||||||
|
_r_debug_ptr = (struct r_debug *)current.d_un.d_ptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
} while(current.d_tag != 0);
|
||||||
|
|
||||||
|
if(!_r_debug_ptr) {
|
||||||
|
fprintf(stderr, "error: no DEBUG tag in the dynamic section, treating this as fatal\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
|
|
||||||
// standard Gtk Application stuff, more or less
|
// standard Gtk Application stuff, more or less
|
||||||
|
@ -227,6 +260,8 @@ int main(int argc, char **argv/*, JNIEnv *env*/)
|
||||||
GtkApplication *app;
|
GtkApplication *app;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
init__r_debug();
|
||||||
|
|
||||||
struct jni_callback_data *callback_data = malloc(sizeof(struct jni_callback_data));
|
struct jni_callback_data *callback_data = malloc(sizeof(struct jni_callback_data));
|
||||||
callback_data->apk_main_activity_class = NULL;
|
callback_data->apk_main_activity_class = NULL;
|
||||||
callback_data->window_width = 960;
|
callback_data->window_width = 960;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue