On Thu, 31 Dec 2009 18:06:36 +0000, Pedro Alves <alves....@gmail.com> wrote: > On Thursday 31 December 2009 17:32:02, Danny Backx wrote: >> On Thu, 2009-12-31 at 16:11 +0000, Pedro Alves wrote: >> > And, I'm using ld's --defsym switch to define it. >> >> > It looks like Windows Mobile 6.1's loader is darn strict WRT >> > to base relocations, and we'll have to figure out a different >> > way to get at the runtime image base. >> >> A variation of what both you and I have tried should do the trick, >> shouldn't it ? >> >> Based on the values in your example : >> - we can't pass __image_base__ = 0x010000 >> - but we can pass 0x011000 == &DllMainCRTStartup >> then all the additional info we need is 0x01000 (BaseOfCode). > > Yes, but this patch instead should be quite upstreamable: > > Index: binutils/ld/scripttempl/pe.sc > =================================================================== > --- binutils.orig/ld/scripttempl/pe.sc 2009-12-31 17:50:54.000000000 +0000 > +++ binutils/ld/scripttempl/pe.sc 2009-12-31 17:52:29.000000000 +0000 > @@ -70,6 +70,7 @@ SECTIONS > ${RELOCATING+. = ALIGN(__section_alignment__);} > .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < > ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} : > { > + ${RELOCATING+__text_start__ = . ;} > ${RELOCATING+ *(.init)} > *(.text) > ${R_TEXT} > @@ -85,6 +86,7 @@ SECTIONS > ${RELOCATING+ *(.gcc_exc)} > ${RELOCATING+PROVIDE (etext = .);} > ${RELOCATING+ *(.gcc_except_table)} > + ${RELOCATING+__text_end__ = . ;} > } > > /* The Cygwin32 library uses a section to avoid copying certain data > > There are already __data_start__, __data_end__ and > __bss_start__, __bss_end__ symbols, only text range is missing. > > For the 0x01000, we could just hardcode it. In practice, this is > the usual size of the PE headers. Can an image have a bigger header > than that, in practice? Or are the variable size bits all in > idata, edata, etc., which end up in allocated section? I know that > gdb hardcodes the 0x1000 (src/gdb/windows-nat.c). > > I don't think it is possible on Windows CE to read the > IMAGE_OPTIONAL_HEADER and friends from DllMainCRTStartup, starting from > the passed in handle? We could get at the image base that way, but > I think that's only possible on non-CE Windows. Am I wrong?
Even if I told you how to do it, I don't think it will be useful if I have obtained this information using non public info. doesn't it ? ------------------------------------------------------------------------------ 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 Cegcc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cegcc-devel