On Tuesday 29 December 2009 14:49:36, Danny Backx wrote:
> On Mon, 2009-12-28 at 10:00 +0100, Danny Backx wrote:
> > I just committed a cleaned up version of my current work.
> >
> > This now has .edata and .idata sections hidden in .rdata, and can
> > generate working DLL and EXEs but with the SizeOfImage <= 10000 limit.
> >
> > Danny
>
> I found one more issue, haven't figured out the reason yet though.
>
> I got here by using a minimalistic example (a DLL with almost no code
> but a big buffer). This gave me an error that I considered suspicious :
> code 1114 (ERROR_DLL_INIT_FAILED).
>
> So I tuned in on this, and ended up replacing the default
> DllMainCRTStartup (from src/mingw) by an empty one.
> Cutting the story
> shorter, the error appears to be in _pei386_runtime_relocator().
>
> Replacing the underlying function do_pseudo_reloc() by an empty one also
> got the DLL to load. Adding MessageBoxW() calls to print the arguments
> succeeds, until I try to print the value of the third argument "base".
>
> This is (from src/mingw/pseudo-reloc.c) :
> do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,
> &__RUNTIME_PSEUDO_RELOC_LIST_END__,
> &__U(_image_base__));
>
> I tried several versions :
> wsprintf(msg, L"do_pseudo_reloc(%p,%p)", start, end); // works
> wsprintf(msg, L"do_pseudo_reloc(%p)", base); // error 1114
>
> { DWORD a = start, b = end, c = base;
> wsprintf(msg, L"do_pseudo_reloc(%08x,%08x,%08x)", a, b, c);
> } // error 1114
>
> Strangely the latter works with the assignment (c = base) but fails when
> I try to print the value of c.
Does it fail to load, crashes, prints garbage, what?
> Obviously (feeling adventurous) the next thing is to relink a bunch of
> DLLs with empty do_pseudo_reloc, and try a real application.
>
> This turned out to work :-)
> See http://danny.backx.info/download/cegcc/Capture.PNG
Awesome!
> Two questions :
> - why I cannot work with that third argument (_image_base__)
To be clear, you're not supposed to read the contents of
_image_base__. This is a linker defined symbol. Only it's
address is important. Can you try
printing '&__U(_image_base__)' in the caller instead?
> - which functionality have I now turned off by removing the content
> of do_pseudo_reloc().
runtime pseudo-relocations. See the help for
--enable-auto-import and –enable-runtime-pseudo-reloc in the ld manual
(but ignore that it says it's i386 specific).
--
Pedro Alves
------------------------------------------------------------------------------
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