From: cgf AT bbc DOT com (Christopher Faylor) Subject: Re: "SHARED" attribute on section in .DLL? 23 Feb 1998 22:00:07 -0800 Message-ID: References: Reply-To: cgf AT bbc DOT com To: cygwin32-developers AT cygnus DOT com In article <199802231757 DOT MAA09496 AT subrogation DOT cygnus DOT com>, Ian Lance Taylor wrote: > From: cgf AT bbc DOT com (Christopher Faylor) > Date: Mon, 23 Feb 1998 03:52:13 GMT > > It mentions that data can be shared between dlls if a dll puts data > that is intended to be shared in a section which has a "shared" attribute. > The book claims that sections can have the following attributes: > READ, WRITE, EXECUTE, SHARED. > > Does anyone know if that is possible to do with ld? If it is, we > could probably get rid of some of the shared memory initialization and > store the process table here. > > I looked through the sources but didn't see anything that was immediately > obvious. > >No, the linker doesn't support this at present. > >It looks through the .drectve section in process_embedded_commands in >bfd/cofflink.c. You can see it set had_shared, but it never does >anything with it. > >I expect that the right thing to do is to eventually set the >IMAGE_SCN_MEM_SHARED flag on the output section. That flags, and >others like it, are set in the coff_swap_scnhdr_out function in >bfd/peicode.h. However, I haven't tried to test this. > >I don't know whether using a SHARED section is any more efficient than >calling OpenFileMapping and MapViewOfFileEx, but it might be. After a lot of diddling, I managed to put the shared information into the .rsrc section and change the attributes of this section to read/write/shared with editbin (obviously this is not something I'm advocating for the long term). Then, I commented out open_shared_file_map in shared.cc and just used a static in the .rsrc section to hold the data. Everything worked fine but there was only a very minor performance improvement. The size of the cygwinb19.dll grew by about 200K, too. I think this is because ld considers .rsrc to be an initialized section so it actually created a copy of the static shared_info structure. Possibly if it was possible to put this into a section that was not considered to hold initialized data, the .dll would be smaller and initial loading would be faster(?). -- http://www.bbc.com/ cgf AT bbc DOT com "Strange how unreal VMS=>UNIX Solutions Boston Business Computing the real can be."