Android.mk
author Sam Lantinga <slouken@libsdl.org>
Thu, 16 May 2013 00:43:22 -0700
changeset 7180 3733e68edbc3
parent 6448 64a6297a8b93
child 7311 56e66417dcee
permissions -rwxr-xr-x
Fixed bug 1846 - _allmul implementation in SDL_stdlib.c doesn't clean up the stack

Colin Barrett

I see this manifest itself (VS2012 x86) as:

"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."

in the first call to SDL_GetTicks in my application. The disassembly at the problem line is:

hires_now.QuadPart *= 1000;
00AD0792 push 0
00AD0794 push 3E8h
00AD0799 mov eax,dword ptr [ebp-10h]
00AD079C push eax
00AD079D mov ecx,dword ptr [hires_now]
00AD07A0 push ecx
00AD07A1 call _allmul (0AE7D40h)
00AD07A6 mov dword ptr [hires_now],eax
00AD07A9 mov dword ptr [ebp-10h],edx

Apparently _allmul should be popping the stack but isn't (other similar functions in SDL_stdlib.c - _alldiv and whatnot - DO pop the stack).

A 'ret 10h' at the end of _allmul appears to do the trick
slouken@4964
     1
LOCAL_PATH := $(call my-dir)
slouken@4964
     2
slouken@4964
     3
###########################
slouken@4964
     4
#
slouken@4964
     5
# SDL shared library
slouken@4964
     6
#
slouken@4964
     7
###########################
slouken@4964
     8
slouken@4964
     9
include $(CLEAR_VARS)
slouken@4964
    10
slouken@6270
    11
LOCAL_MODULE := SDL2
slouken@4964
    12
slouken@4964
    13
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
slouken@4964
    14
slouken@5090
    15
LOCAL_SRC_FILES := \
slouken@4964
    16
	$(subst $(LOCAL_PATH)/,, \
slouken@4964
    17
	$(wildcard $(LOCAL_PATH)/src/*.c) \
slouken@4964
    18
	$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
slouken@5090
    19
	$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
slouken@5090
    20
	$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
slouken@5003
    21
	$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
slouken@5003
    22
	$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
slouken@5090
    23
	$(wildcard $(LOCAL_PATH)/src/core/android/*.cpp) \
slouken@4964
    24
	$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
slouken@4964
    25
	$(wildcard $(LOCAL_PATH)/src/events/*.c) \
slouken@4964
    26
	$(wildcard $(LOCAL_PATH)/src/file/*.c) \
slouken@5090
    27
	$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
slouken@5090
    28
	$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
slouken@4964
    29
	$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
slouken@5090
    30
	$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
slouken@5092
    31
	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
slouken@5090
    32
	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
slouken@6448
    33
	$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
slouken@5161
    34
	$(wildcard $(LOCAL_PATH)/src/render/*.c) \
slouken@5204
    35
	$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
slouken@4964
    36
	$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
slouken@4964
    37
	$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
slouken@5090
    38
	$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
slouken@4964
    39
	$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
slouken@5090
    40
	$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
slouken@4964
    41
	$(wildcard $(LOCAL_PATH)/src/video/*.c) \
slouken@5092
    42
	$(wildcard $(LOCAL_PATH)/src/video/android/*.c))
slouken@4964
    43
slouken@6208
    44
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
slouken@5204
    45
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog
slouken@4964
    46
slouken@4964
    47
include $(BUILD_SHARED_LIBRARY)