How to fix SizeOfImage when loading a builtin dll ?
laurent.pinchart at skynet.be
Wed May 29 16:22:00 CDT 2002
On Wednesday 29 May 2002 22:40, Eric Pouech wrote:
> > I thought about modifying winebuild to add
> > char _end;
> > nt_headers->OptionalHeader.SizeOfImage = pe_header - _end;
> > in the library initialisation function. This is small, fast and probably
> > more accurate.
> > Does anyone have any comment about that ?
> don't you mean extern char _end instead ?
> there's nothing currently which ensures that pe_header is at the start
> of the code (it relies on the fact it's the first on gcc/ld link option,
> and that ld allocates slots for compilation units in the order they are
> expressed) => this may become a porting issue
> I'm not sure either that _end is completly portable?
I don't know either. We could instead add a linker script which would set a
symbol to the difference between the end and the start of the file. That
should be more portable.
> using this technique (with _start, _etext, _edata, _bss_start, _end) we
> could also compute the "real" size of code, data, and bss which should
> be of some interest (even if data would be a bit more difficult, since
> we need to take care of the rsrc part)
One thing at a time please :-)
I tried the code described above, but it unfortunately doesn't work for all
dlls. It returns a correct value in some cases (for small dlls it seems), and
a huge negative value around 0xc0000000 in other cases (for bigger dlls).
I check the pe_header and _end symbols using nm and they are correct
I then checked the assembly code generated by gcc, and found out that _end -
pe_header is computed by reading 2 valus in the .got section and substracting
Could anyone help me ?
Should I try with a linker script ?
More information about the wine-devel