On Wed, 2009-12-30 at 00:44 +0100, Danny Backx wrote:
> On Tue, 2009-12-29 at 18:34 +0000, Pedro Alves wrote:
> > My knee jerk reaction is: you could try a first step at checking if it's
> > a problem with loader applied relocations, or, if it's a runtime,
> > post loader problem. Replace your debug '#if 0' by, say,
> >
> > at global scope:
> > volatile int print_base = 0;
> >
> > {
> > ...
> > if (print_base)
> > wsprintf(msg, L"Ptr %p", &__U(_image_base__));
> > wsprintf(msg, L"Ptrs %p %p", &__RUNTIME_PSEUDO_RELOC_LIST__,
> > &__RUNTIME_PSEUDO_RELOC_LIST_END__);
> > }
> >
> > And see if that loads and runs. Then try with print_base set to 1.
> > Build without optimizations.
>
> In both cases, the output is the same :
>
> LoadLibrary(lib5bb.dll) : cannot load DLL -> error 1114
>
> I must admit I've been suspicious about the relocations, I guess this
> confirms it.
I've looked further, I'm puzzled.
I created yet another small test (and set image-base to a higher value,
see the other discussion, just for fun).
I checked all the relocations : the table vs. the assembler. They all
appear to make sense. They're usually a couple of words between two
functions (in the .text segment) that are pointers to something in
another segment. A string literal for instance.
I've enclosed the assembler output of a _pei386_runtime_relocator with
the offending lines compiled in :
void
_pei386_runtime_relocator ()
{
static int was_init = 0;
if (was_init)
return;
++was_init;
{
wchar_t msg[64] = L"Yow";
MessageBoxW(0, msg, L"_pei386_runtime_relocator", 0);
}
do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,
&__RUNTIME_PSEUDO_RELOC_LIST_END__,
&__U(_image_base__));
}
The MessageBoxW call is very visible in the assembler output, and it
provides examples for what the relocations look like. The
do_pseudo_reloc call with its parameters is also there. I cannot see a
problem with it, but it does cause the application to fail !
Help ?
Danny
0100146c <_pei386_runtime_relocator>:
100146c: e92d4800 push {fp, lr}
1001470: e28db004 add fp, sp, #4
1001474: e24dd080 sub sp, sp, #128 ; 0x80
1001478: e59f307c ldr r3, [pc, #124] ; 10014fc
<_pei386_runtime_relocator+0x90>
100147c: e5933000 ldr r3, [r3]
1001480: e3530000 cmp r3, #0
1001484: 1a000019 bne 10014f0
<_pei386_runtime_relocator+0x84>
1001488: e59f306c ldr r3, [pc, #108] ; 10014fc
<_pei386_runtime_relocator+0x90>
100148c: e5933000 ldr r3, [r3]
1001490: e2832001 add r2, r3, #1
1001494: e59f3060 ldr r3, [pc, #96] ; 10014fc
<_pei386_runtime_relocator+0x90>
1001498: e5832000 str r2, [r3]
100149c: e59f205c ldr r2, [pc, #92] ; 1001500
<_pei386_runtime_relocator+0x94>
10014a0: e24b3084 sub r3, fp, #132 ; 0x84
10014a4: e8920003 ldm r2, {r0, r1}
10014a8: e8830003 stm r3, {r0, r1}
10014ac: e24b207c sub r2, fp, #124 ; 0x7c
10014b0: e3a03078 mov r3, #120 ; 0x78
10014b4: e1a00002 mov r0, r2
10014b8: e3a01000 mov r1, #0
10014bc: e1a02003 mov r2, r3
10014c0: eb0000d9 bl 100182c <memset>
10014c4: e24b3084 sub r3, fp, #132 ; 0x84
10014c8: e3a00000 mov r0, #0
10014cc: e1a01003 mov r1, r3
10014d0: e59f202c ldr r2, [pc, #44] ; 1001504
<_pei386_runtime_relocator+0x98>
10014d4: e3a03000 mov r3, #0
10014d8: eb0000d6 bl 1001838 <MessageBoxW>
10014dc: e59f0024 ldr r0, [pc, #36] ; 1001508
<_pei386_runtime_relocator+0x9c>
10014e0: e59f1024 ldr r1, [pc, #36] ; 100150c
<_pei386_runtime_relocator+0xa0>
10014e4: e59f2024 ldr r2, [pc, #36] ; 1001510
<_pei386_runtime_relocator+0xa4>
10014e8: ebffff22 bl 1001178 <do_pseudo_reloc>
10014ec: ea000000 b 10014f4
<_pei386_runtime_relocator+0x88>
10014f0: e1a00000 nop ; (mov r0, r0)
10014f4: e24bd004 sub sp, fp, #4
10014f8: e8bd8800 pop {fp, pc}
10014fc: 0101200c tsteq r1, ip
1001500: 01013034 tsteq r1, r4, lsr r0
1001504: 01013000 tsteq r1, r0
1001508: 010130b4 strheq r3, [r1, -r4]
100150c: 010130b4 strheq r3, [r1, -r4]
1001510: 01000000 tsteq r0, r0
PE File Base Relocations (interpreted .reloc section contents)
Virtual Address: 00001000 Chunk size 68 (0x44) Number of fixups 30
reloc 0 offset 4fc [14fc] HIGHLOW
reloc 1 offset 500 [1500] HIGHLOW
reloc 2 offset 504 [1504] HIGHLOW
reloc 3 offset 508 [1508] HIGHLOW
reloc 4 offset 50c [150c] HIGHLOW
reloc 5 offset 510 [1510] HIGHLOW
reloc 6 offset 550 [1550] HIGHLOW
reloc 7 offset 594 [1594] HIGHLOW
reloc 8 offset 648 [1648] HIGHLOW
reloc 9 offset 64c [164c] HIGHLOW
reloc 10 offset 670 [1670] HIGHLOW
reloc 11 offset 674 [1674] HIGHLOW
reloc 12 offset 6dc [16dc] HIGHLOW
reloc 13 offset 6e0 [16e0] HIGHLOW
reloc 14 offset 744 [1744] HIGHLOW
reloc 15 offset 748 [1748] HIGHLOW
reloc 16 offset 788 [1788] HIGHLOW
reloc 17 offset 7ec [17ec] HIGHLOW
reloc 18 offset 7f0 [17f0] HIGHLOW
reloc 19 offset 810 [1810] HIGHLOW
reloc 20 offset 81c [181c] HIGHLOW
reloc 21 offset 828 [1828] HIGHLOW
reloc 22 offset 834 [1834] HIGHLOW
reloc 23 offset 840 [1840] HIGHLOW
reloc 24 offset 84c [184c] HIGHLOW
reloc 25 offset 858 [1858] HIGHLOW
reloc 26 offset 864 [1864] HIGHLOW
reloc 27 offset 870 [1870] HIGHLOW
reloc 28 offset 87c [187c] HIGHLOW
reloc 29 offset 888 [1888] HIGHLOW
Virtual Address: 00012000 Chunk size 12 (0xc) Number of fixups 2
reloc 0 offset 8 [12008] HIGHLOW
reloc 1 offset 0 [12000] ABSOLUTE
Note : full objdump at
http://danny.backx.info/download/cegcc/lib6.objdump
--
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Cegcc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cegcc-devel