Permalink
Browse files

Merge pull request #542 from nicklauslittle/x86-dual-so

Fixed text relocation errors on x86 Android M
  • Loading branch information...
fzurita committed Jan 23, 2016
2 parents 4d2ca83 + cd96d7c commit 4be977292845fd9e5ed3cf7b6a9fac8aa101f789
View
@@ -15,7 +15,7 @@
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="22" />
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
@@ -69,6 +69,10 @@ static pFrontMain frontMain = NULL;
static pNativeResume nativeResume = NULL;
static pNativePause nativePause = NULL;
static const int ANDROID_SDK_VERSION_M = 23;
static const char *coreLibraryName = "mupen64plus-core";
void checkLibraryError(const char* message)
{
const char* error = dlerror();
@@ -125,7 +129,7 @@ extern jint JNI_OnLoad(JavaVM* vm, void* reserved)
Functions called by Java code
*******************************************************************************/
extern "C" DECLSPEC void SDLCALL Java_paulscode_android_mupen64plusae_jni_NativeExports_loadLibraries(JNIEnv* env, jclass cls, jstring jlibPath)
extern "C" DECLSPEC void SDLCALL Java_paulscode_android_mupen64plusae_jni_NativeExports_loadLibraries(JNIEnv* env, jclass cls, jstring jlibPath, jint jandroidSDK)
{
LOGI("Loading native libraries");
@@ -138,11 +142,19 @@ extern "C" DECLSPEC void SDLCALL Java_paulscode_android_mupen64plusae_jni_Native
strcpy(path, libPath);
env->ReleaseStringUTFChars(jlibPath, libPath);
#ifdef __i386__ // ARM libraries are already PIC-compliant
// Check if PIC libraries are needed
if (jandroidSDK >= ANDROID_SDK_VERSION_M)
{
coreLibraryName = "mupen64plus-core-pic";
}
#endif
// Open shared libraries
handleAEI = loadLibrary(path, "ae-imports");
handleSDL = loadLibrary(path, "SDL2");
handleFreetype = loadLibrary(path, "freetype");
handleCore = loadLibrary(path, "mupen64plus-core");
handleCore = loadLibrary(path, coreLibraryName);
handleFront = loadLibrary(path, "mupen64plus-ui-console");
// Make sure we don't have any typos
@@ -164,7 +176,7 @@ extern "C" DECLSPEC void SDLCALL Java_paulscode_android_mupen64plusae_jni_Native
sdlInit = (pSdlInit) locateFunction(handleSDL, "SDL2", "SDL_Android_Init");
sdlSetScreen = (pSdlSetScreen) locateFunction(handleSDL, "SDL2", "Android_SetScreenResolution");
sdlMainReady = (pVoidFunc) locateFunction(handleSDL, "SDL2", "SDL_SetMainReady");
coreDoCommand = (pCoreDoCommand) locateFunction(handleCore, "mupen64plus-core", "CoreDoCommand");
coreDoCommand = (pCoreDoCommand) locateFunction(handleCore, coreLibraryName, "CoreDoCommand");
frontMain = (pFrontMain) locateFunction(handleFront, "mupen64plus-ui-console", "SDL_main");
nativeResume = (pNativeResume) locateFunction(handleSDL, "SDL2", "Java_org_libsdl_app_SDLActivity_nativeResume");
nativePause = (pNativePause) locateFunction(handleSDL, "SDL2", "Java_org_libsdl_app_SDLActivity_nativePause");
@@ -201,7 +213,7 @@ extern "C" DECLSPEC void SDLCALL Java_paulscode_android_mupen64plusae_jni_Native
// Close shared libraries
unloadLibrary(handleFront, "mupen64plus-ui-console");
unloadLibrary(handleCore, "mupen64plus-core");
unloadLibrary(handleCore, coreLibraryName);
unloadLibrary(handleFreetype, "freetype");
unloadLibrary(handleSDL, "SDL2");
unloadLibrary(handleAEI, "ae-imports");
@@ -212,6 +224,8 @@ extern "C" DECLSPEC void SDLCALL Java_paulscode_android_mupen64plusae_jni_Native
handleFreetype = NULL;
handleSDL = NULL;
handleAEI = NULL;
coreLibraryName = "mupen64plus-core";
}
extern "C" DECLSPEC jint SDLCALL Java_paulscode_android_mupen64plusae_jni_NativeExports_emuStart(JNIEnv* env, jclass cls, jstring juserDataPath, jstring juserCachePath, jobjectArray jargv)
View
@@ -129,6 +129,46 @@ else ifeq ($(TARGET_ARCH_ABI), x86)
LOCAL_CFLAGS += -DDYNAREC
LOCAL_CFLAGS += -DNEW_DYNAREC=1
include $(BUILD_SHARED_LIBRARY)
# Build PIC-compliant library
SAVED_PATH := $(LOCAL_PATH)
SAVED_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES)
SAVED_STATIC_LIBRARIES := $(LOCAL_STATIC_LIBRARIES)
SAVED_C_INCLUDES := $(LOCAL_C_INCLUDES)
SAVED_SRC_FILES := $(LOCAL_SRC_FILES)
SAVED_CFLAGS := $(LOCAL_CFLAGS)
SAVED_LDFLAGS := $(LOCAL_LDFLAGS)
include $(CLEAR_VARS)
LOCAL_PATH := $(SAVED_PATH)
LOCAL_SHARED_LIBRARIES := $(SAVED_SHARED_LIBRARIES)
LOCAL_STATIC_LIBRARIES := $(SAVED_STATIC_LIBRARIES)
LOCAL_C_INCLUDES := $(SAVED_C_INCLUDES)
LOCAL_MODULE := mupen64plus-core-pic
LOCAL_SRC_FILES := $(filter-out $(SRCDIR)/r4300/empty_dynarec.c \
$(SRCDIR)/r4300/new_dynarec/new_dynarec.c \
$(SRCDIR)/r4300/new_dynarec/x86/linkage_x86.asm \
, $(SAVED_SRC_FILES)) \
$(SRCDIR)/r4300/x86/assemble.c \
$(SRCDIR)/r4300/x86/gbc.c \
$(SRCDIR)/r4300/x86/gcop0.c \
$(SRCDIR)/r4300/x86/gcop1.c \
$(SRCDIR)/r4300/x86/gcop1_d.c \
$(SRCDIR)/r4300/x86/gcop1_l.c \
$(SRCDIR)/r4300/x86/gcop1_s.c \
$(SRCDIR)/r4300/x86/gcop1_w.c \
$(SRCDIR)/r4300/x86/gr4300.c \
$(SRCDIR)/r4300/x86/gregimm.c \
$(SRCDIR)/r4300/x86/gspecial.c \
$(SRCDIR)/r4300/x86/gtlb.c \
$(SRCDIR)/r4300/x86/regcache.c \
$(SRCDIR)/r4300/x86/rjump.c
LOCAL_CFLAGS := $(filter-out -DNEW_DYNAREC=1, $(SAVED_CFLAGS)) \
-ffast-math -mtune=atom -mssse3 -mfpmath=sse -fPIC
LOCAL_LDFLAGS := $(SAVED_LDFLAGS)
else ifeq ($(TARGET_ARCH_ABI), mips)
# Use for MIPS:
#TODO: Possible to port dynarec from Daedalus?
@@ -38,6 +38,7 @@
import paulscode.android.mupen64plusae.util.Utility;
import android.content.DialogInterface;
import android.media.AudioTrack;
import android.os.Build;
import android.os.Vibrator;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
@@ -234,7 +235,7 @@ public static synchronized void startupEmulator(final String saveToLoad)
if( sCoreThread == null )
{
// Load the native libraries
NativeExports.loadLibraries( sAppData.libsDir );
NativeExports.loadLibraries( sAppData.libsDir, Build.VERSION.SDK_INT );
// Start the core thread if not already running
sCoreThread = new Thread( new Runnable()
@@ -37,7 +37,7 @@
// TODO: Add javadoc
public static native void loadLibraries( String libPath );
public static native void loadLibraries( String libPath, int androidSDK );
public static native void unloadLibraries();
@@ -241,7 +241,14 @@ public AppData( Context context )
profilesDir = coreSharedDataDir + "/profiles";
// Files
coreLib = libsDir + "/libmupen64plus-core.so";
String arch = System.getProperty("os.arch");
// Check for x86, ignore 'arch64' or 'x86_64' for now
if( arch.equals( "i686" ) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M )
coreLib = libsDir + "/libmupen64plus-core-pic.so";
else
coreLib = libsDir + "/libmupen64plus-core.so";
rspLib = libsDir + "/libmupen64plus-rsp-hle.so";
inputLib = libsDir + "/libmupen64plus-input-android.so";
gln64_conf = coreSharedDataDir + "/gln64.conf";

0 comments on commit 4be9772

Please sign in to comment.