This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
windows ce DLL, another question
- From: Danny Backx <danny dot backx at scarlet dot be>
- To: binutils at sourceware dot org
- Date: Sat, 13 Mar 2010 18:54:12 +0100
- Subject: windows ce DLL, another question
- Reply-to: danny dot backx at scarlet dot be
Hi,
I've asked questions about this earlier. My goal is still to get
binutils to support Windows CE > 6.1, some stuff is lacking for DLLs.
Since my previous questions I believe I have most issues solved. The
problem I'm chasing now is that one DLL doesn't appear to get a pointer
from another. Yes: auto-import is playing here.
The sample in http://danny.backx.info/download/cegcc/dllbug.tar.gz is
very minimal. It should show the same number three times - from one DLL,
from another, and from the main program. That's not happening.
Can you provide me with a pointer to what the problem might be ? The tar
file includes objdump output etc.
The debug session shows that the pointer inserted after the fun()
function is wrong.
Danny
pavilion: {548} arm-mingw32ce-gdb main.exe
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu
--target=arm-mingw32ce"...
(gdb) target remote ipaq:9999
Remote debugging using ipaq:9999
[New Thread 97447894]
Reading symbols from /home/danny/simple/wince/array/t.dll...done.
Loaded symbols for t.dll
Reading symbols from /home/danny/simple/wince/array/l.dll...done.
Loaded symbols for l.dll
WinMainCRTStartup (hInst=0x5d68d26, hPrevInst=0x0, lpCmdLine=0x1c11fed8,
nCmdShow=5)
at /home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/crt3.c:35
35 {
(gdb) l WinMain
6
7 extern int fun(void);
8
9 #ifdef __UNDER_CE__
10 int APIENTRY WinMain(HINSTANCE inst, HINSTANCE pi, LPWSTR cmd,
int show)
11 {
12 int x;
13 wchar_t s[32];
14
15 localquery();
(gdb)
16 x = fun();
17 wsprintf(s, L"fun() -> %d", x);
18 MessageBox(0, s, L"info", 0);
19 return 0;
20 }
21 #else
22 int main(int argc, char *argv[])
23 {
24 int x = fun();
25
(gdb) break 16
Breakpoint 1 at 0x11074: file main.c, line 16.
(gdb) c
Continuing.
Breakpoint 1, WinMain (inst=0x5d68d26, pi=0x0, cmd=0x1c11fed8, show=5)
at main.c:16
16 x = fun();
(gdb) display/i $pc
1: x/i $pc
0x11074 <WinMain+32>: bl 0x11794 <fun>
(gdb) si
0x00011794 in fun ()
1: x/i $pc
0x11794 <fun>: ldr r12, [pc, #0] ; 0x1179c <fun+8>
(gdb)
0x00011798 in fun ()
1: x/i $pc
0x11798 <fun+4>: ldr pc, [r12]
(gdb)
fun () at t.c:6
6 {
1: x/i $pc
0x139108c <fun>: push {r11, lr}
(gdb)
0x01391090 6 {
1: x/i $pc
0x1391090 <fun+4>: add r11, sp, #4 ; 0x4
(gdb)
0x01391094 6 {
1: x/i $pc
0x1391094 <fun+8>: sub sp, sp, #68 ; 0x44
(gdb)
10 r = a[0];
1: x/i $pc
0x1391098 <fun+12>: ldr r3, [pc, #64] ; 0x13910e0 <__fu0_a>
(gdb) info reg
r0 0x1 1
r1 0x2 2
r2 0x10 16
r3 0x0 0
r4 0x5d68d26 97946918
r5 0x2 2
r6 0x11000 69632
r7 0x1ffcc74 33541236
r8 0x1ffc9e0 33540576
r9 0x1c11fed8 470941400
r10 0x5d68d26 97946918
r11 0x1c11fdd0 470941136
r12 0x131f0 78320
sp 0x1c11fd88 0x1c11fd88
lr 0x11078 69752
pc 0x1391098 0x1391098 <fun+12>
fps 0x0 0
cpsr 0x60000010 1610612752
(gdb) si
0x0139109c 10 r = a[0];
1: x/i $pc
0x139109c <fun+16>: ldr r3, [r3]
(gdb) info reg
r0 0x1 1
r1 0x2 2
r2 0x10 16
r3 0x13b0d88 20647304
r4 0x5d68d26 97946918
r5 0x2 2
r6 0x11000 69632
r7 0x1ffcc74 33541236
r8 0x1ffc9e0 33540576
r9 0x1c11fed8 470941400
r10 0x5d68d26 97946918
r11 0x1c11fdd0 470941136
r12 0x131f0 78320
sp 0x1c11fd88 0x1c11fd88
lr 0x11078 69752
pc 0x139109c 0x139109c <fun+16>
fps 0x0 0
cpsr 0x60000010 1610612752
(gdb) si
Data Abort: Thread=86732c0c Proc=8034de90 'main.exe'
AKY=00002001 PC=0139109c(t.dll+0x0000109c) RA=00011078(main.exe
+0x00001078) BVA=1d3b0d88 FSR=00000007
Program received signal SIGSEGV, Segmentation fault.
0x0139109c in fun () at t.c:10
10 r = a[0];
1: x/i $pc
0x139109c <fun+16>: ldr r3, [r3]
(gdb) disass fun
Dump of assembler code for function fun:
0x0139108c <fun+0>: push {r11, lr}
0x01391090 <fun+4>: add r11, sp, #4 ; 0x4
0x01391094 <fun+8>: sub sp, sp, #68 ; 0x44
0x01391098 <fun+12>: ldr r3, [pc, #64] ; 0x13910e0 <__fu0_a>
0x0139109c <fun+16>: ldr r3, [r3]
0x013910a0 <fun+20>: str r3, [r11, #-8]
0x013910a4 <fun+24>: sub r3, r11, #72 ; 0x48
0x013910a8 <fun+28>: mov r0, r3
0x013910ac <fun+32>: ldr r1, [pc, #48] ; 0x13910e4 <__fu0_a+4>
0x013910b0 <fun+36>: ldr r2, [r11, #-8]
0x013910b4 <fun+40>: bl 0x1391710 <wsprintfW>
0x013910b8 <fun+44>: sub r3, r11, #72 ; 0x48
0x013910bc <fun+48>: mov r0, #0 ; 0x0
0x013910c0 <fun+52>: mov r1, r3
0x013910c4 <fun+56>: ldr r2, [pc, #28] ; 0x13910e8 <__fu0_a+8>
0x013910c8 <fun+60>: mov r3, #0 ; 0x0
0x013910cc <fun+64>: bl 0x139171c <MessageBoxW>
0x013910d0 <fun+68>: ldr r3, [r11, #-8]
0x013910d4 <fun+72>: mov r0, r3
0x013910d8 <fun+76>: sub sp, r11, #4 ; 0x4
0x013910dc <fun+80>: pop {r11, pc}
0x013910e0 <__fu0_a+0>: teqeq r11, r8, lsl #27
0x013910e4 <__fu0_a+4>: teqeq r9, r0
0x013910e8 <__fu0_a+8>: teqeq r9, r8, lsr #32
End of assembler dump.
(gdb) x/16xb 0x013910e0
0x13910e0 <__fu0_a>: 0x88 0x0d 0x3b 0x01 0x00 0x30
0x39 0x01
0x13910e8 <__fu0_a+8>: 0x28 0x30 0x39 0x01 0x04 0x30
0x9f 0xe5
(gdb) disass localquery
Dump of assembler code for function localquery:
0x013a10d4 <localquery+0>: push {r11, lr}
0x013a10d8 <localquery+4>: add r11, sp, #4 ; 0x4
0x013a10dc <localquery+8>: sub sp, sp, #64 ; 0x40
0x013a10e0 <localquery+12>: ldr r3, [pc, #52] ; 0x13a111c
<localquery+72>
0x013a10e4 <localquery+16>: ldr r3, [r3]
0x013a10e8 <localquery+20>: sub r2, r11, #68 ; 0x44
0x013a10ec <localquery+24>: mov r0, r2
0x013a10f0 <localquery+28>: ldr r1, [pc, #40] ; 0x13a1120
<localquery+76>
0x013a10f4 <localquery+32>: mov r2, r3
0x013a10f8 <localquery+36>: bl 0x13a174c <wsprintfW>
0x013a10fc <localquery+40>: sub r3, r11, #68 ; 0x44
0x013a1100 <localquery+44>: mov r0, #0 ; 0x0
0x013a1104 <localquery+48>: mov r1, r3
0x013a1108 <localquery+52>: ldr r2, [pc, #20] ; 0x13a1124
<localquery+80>
0x013a110c <localquery+56>: mov r3, #0 ; 0x0
0x013a1110 <localquery+60>: bl 0x13a1758 <MessageBoxW>
0x013a1114 <localquery+64>: sub sp, r11, #4 ; 0x4
0x013a1118 <localquery+68>: pop {r11, pc}
0x013a111c <localquery+72>: teqeq r10, r0
0x013a1120 <localquery+76>: teqeq r10, r0
0x013a1124 <localquery+80>: teqeq r10, r8, lsr #32
End of assembler dump.
(gdb) x/32xb 0x013a111c
0x13a111c <localquery+72>: 0x00 0x20 0x3a 0x01 0x00
0x30 0x3a 0x01
0x13a1124 <localquery+80>: 0x28 0x30 0x3a 0x01 0x04
0x30 0x9f 0xe5
0x13a112c <__atexit_first+4>: 0x00 0x00 0x93 0xe5 0x0e
0xf0 0xa0 0xe1
0x13a1134 <__atexit_first+12>: 0x18 0x20 0x3a 0x01 0x92
0x01 0x00 0xea
(gdb) x/32xb 013a2000
Invalid number "013a2000".
(gdb) x/32xb 0x13a2000
0x13a2000 <a>: 0x03 0x00 0x00 0x00 0x04 0x00 0x00
0x00
0x13a2008 <a+8>: 0x05 0x00 0x00 0x00 0x06 0x00
0x00 0x00
0x13a2010 <a+16>: 0x00 0x00 0x00 0x00 0x18 0x18
0x3a 0x01
0x13a2018 <first_atexit>: 0x60 0x00 0x12 0x00 0x64
0x00 0x12 0x00
--
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info