From: Paul G. <pga...@co...> - 2003-09-14 06:38:34
|
*blown away* On 14 Sep 2003 at 11:56, Luke Dunstan wrote: > > > I built this program: > > /////////////////////////////////////////////////////////////////// > > static unsigned long > strhash (const char *str) > { > const unsigned char *s; > unsigned long hash; > unsigned int c; > unsigned int len; > > hash = 0; > len = 0; > s = (const unsigned char *) str; > while ((c = *s++) != '\0') > { > hash += c + (c << 17); > hash ^= hash >> 2; > ++len; > } > hash += len + (len << 17); > hash ^= hash >> 2; > > return hash; > } > > /* Use the output file to create a image base for relocatable DLLs. */ > > static unsigned long > compute_dll_image_base (const char *ofile) > { > unsigned long hash = strhash (ofile); > return 0x60000000 | ((hash << 16) & 0x0FFC0000); > } > > int main(int argc, char *argv[]) > { > if(argc != 2) > return 1; > printf("image base of '%s': 0x%08lX\n", argv[1], > compute_dll_image_base(argv[1])); > return 0; > } > > /////////////////////////////////////////////////////////////////// > > > > And when I executed it: > > $ ./imagbase.exe glwin32.dll > image base of 'glwin32.dll': 0x6B180000 > $ ./imagbase.exe csfont.dll > image base of 'csfont.dll': 0x6B180000 > So the conclusion is that by chance these DLL names just happen to > hash to the same value :-) Who would have thunk it...it just blows me away...I had my suspicions...thank you, Luke. I really appreciate all the time you've put in to this. > > If you would like to give them different base addresses then you must > specify it manually: > > gcc -shared ... -Wl,--image-base,0x5432000 > > dllwrap ... --image-base 0x54320000 Ok. Looks like I am going to have to come up with a way to determine what to do if two different file names hash to an identical value. In the meantime, I will see what I can do to manually define the value via a makefile modificaiton of some sort. Thanks again, Luke, for all your energy on this. Paul G. > ----- Original Message ----- > From: Paul G. > To: min...@li... > Sent: Sunday, September 14, 2003 10:03 AM > Subject: Re: dllwrap -> ld arg passing (Was: Re: [Mingw-users] dllwrap > related bug? (possibly OT)) > > Thanks, Luke, for your quick reply. > > On 12 Sep 2003 at 9:36, Luke Dunstan wrote: > > > > > ----- Original Message ----- > > From: "Paul G." <pga...@co...> > > To: <min...@li...> > > Sent: Friday, September 12, 2003 7:15 AM > > Subject: dllwrap -> ld arg passing (Was: Re: [Mingw-users] dllwrap > > related bug? (possibly OT)) > > > > > > > Thanks Luke for all your earlier feedback, it was and is greatly > > appreciated as it helped me to eliminate a > > > number of erroneous possibilities, thanks again. Finally. After > > > thinking > > about your feedback, Luke, I was left with one > > > single question: > > > > > > Does dllwrap args forwarded/passed to ld override the ld internal > > > hashing > > algorithm(s?) used for establishing .dll -- > > > image-base options? > > > > I think so, but after building a minimal test DLL I found that the > > "--image-base" option passed to dlltool/ld *is* derived from the DLL > > filename exactly like the base address generated by "ld" when you > > use "gcc -shared". What are the names and base addresses of the DLLs > > that you are having problems with? > > I am building the object code with the -g3 switch enabled. I don't > know (or even think) that it could make any difference in the hashing. > Even so, I felt it needed to be mentioned. > > names reported image-base, option assignment > csfont0x6B180000 > glwin320x6B180000 > > Paul G. |