http://bugs.winehq.org/show_bug.cgi?id=33349
--- Comment #1 from Anastasius Focht focht@gmx.net 2013-04-12 16:50:51 CDT --- Hello André,
as I told in earlier Wine/ARM bugs, Thumb-2 is the default for Win32 ARM PE binaries. Most ARM Linux distros (Debian, Ubuntu, Fedora?) use ARMv7-A + VFPv3-D16 + Thumb-2 profile (Cortex-A). So forcing Wine code to be compiled for ARM mode on these systems is not optimal.
For the compiler flags, yes "-mthumb" would be sufficient, no need for "-mthumb-interwork". My toolchains have Thumb-2 as default profile, so there would be no need for any CFLAGS override.
Building Wine as thumb code causes issues for "naked" functions with explicit ".arm" directive because the linker won't insert ARM-Thumb interworking veneers automatically. Raising "unimplemented API" exception currently fails because of that:
--- snip --- Wine-gdb> bt #0 0x4016970a in RtlRaiseException (rec=0x40c99310) at /home/linaro/wine/wine-git/dlls/ntdll/signal_arm.c:1081 #1 0x401421b2 in stub_entry_point (dll=0x4ea2c4 "KERNEL32.dll", name=0x4eb05a "InitOnceExecuteOnce", ret_addr=0x49c9b7) at /home/linaro/wine/wine-git/dlls/ntdll/loader.c:197 #2 0x0049c9b6 in ?? () #3 0x0049c9b6 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) Wine-gdb> p *rec $1 = {ExceptionCode = 2147483904, ExceptionFlags = 1, ExceptionRecord = 0x0, ExceptionAddress = 0x49c9b7, NumberParameters = 2, ExceptionInformation = {5153476, 5156954, 1082964736, 5209840, 1075310241, 1075567040, 1082964736, 5209840, 1075310241, 4294967295, 1082642532, 1082642576, 0, 1086952288, 1074973151}} --- snip ---
RtlRaiseException as Thumb-2 code:
--- snip --- Wine-gdb> disas Dump of assembler code for function RtlRaiseException: 0x401696fc <+0>: push {r7, lr} 0x401696fe <+2>: sub sp, #88 ; 0x58 0x40169700 <+4>: add r7, sp, #0 0x40169702 <+6>: str r0, [r7, #4] 0x40169704 <+8>: add.w r3, r7, #12 0x40169708 <+12>: mov r0, r3 => 0x4016970a <+14>: bl 0x40168050 <RtlCaptureContext> 0x4016970e <+18>: ldr r3, [r7, #76] ; 0x4c 0x40169710 <+20>: mov r2, r3 0x40169712 <+22>: ldr r3, [r7, #4] 0x40169714 <+24>: str r2, [r3, #12] 0x40169716 <+26>: add.w r3, r7, #12 0x4016971a <+30>: ldr r0, [r7, #4] 0x4016971c <+32>: mov r1, r3 0x4016971e <+34>: mov.w r2, #1 0x40169722 <+38>: bl 0x40168668 <raise_exception> ... --- snip ---
RtlCaptureContext is forced ARM code (naked, explicit ".arm" directive -> no veneer to switch to arm mode):
--- snip --- Wine-gdb> disas Dump of assembler code for function RtlCaptureContext: => 0x40168050 <+0>: push {r1} 0x40168054 <+4>: mov r1, #64 ; 0x40 0x40168058 <+8>: add r1, r1, #3 0x4016805c <+12>: str r1, [r0] 0x40168060 <+16>: pop {r1} 0x40168064 <+20>: str r0, [r0, #4] 0x40168068 <+24>: str r1, [r0, #8] 0x4016806c <+28>: str r2, [r0, #12] 0x40168070 <+32>: str r3, [r0, #16] 0x40168074 <+36>: str r4, [r0, #20] --- snip ---
T-bit set in CPSR (thumb mode):
--- snip --- Wine-gdb> info reg r0 0x40c992ac 1086952108 r1 0x4eb05a 5156954 r2 0x49c9b7 4835767 r3 0x40c992ac 1086952108 r4 0x415e0048 1096679496 r5 0x0 0 r6 0x0 0 r7 0x40c992a0 1086952096 r8 0x1 1 r9 0x0 0 r10 0x40 64 r11 0x40c99370 1086952304 r12 0x401a200c 1075453964 sp 0x40c992a0 0x40c992a0 lr 0x4016970f 1075222287 pc 0x40168050 0x40168050 <RtlCaptureContext> cpsr 0x400f0030 1074724912 --- snip ---
Wine source: http://source.winehq.org/git/wine.git/blob/3c04958b8a47f56a6dfc9ac067ca88f34...
Removing ".arm" directive correctly raises the exception.
Regards