[PATCH]: autoload.cc: Remove unnecessary data entries from .dllname_info sections

Pavel Tsekov ptsekov@gmx.net
Thu Mar 10 10:45:00 GMT 2005


Hello,

I've been looking at the contents of the cygwin1.dll image in the last
few days and I've noticed that the sections named .dllname_info contain
a lot of duplicate entries - one for each autoloaded function from a given
dll. Although it doesn't hurt to have it, this information is not really
neccassary for the autoload functionality - autoload only needs one entry
per dll in .dllname_info. Another point to consider here is that for dlls
that use an auxillary initialization routine (ws2_32 and wsock32)
currently you have one entry (the one that is used) with the address
of the right auxillary initialization routine  and many entries with the
default auxillary initialization routine . This is due to the following
usage:

LoadDLLprime (wsock32, _wsock_init)

[...]

LoadDLLfunc (WSAAsyncSelect, 16, wsock32)

Of course this could be corrected by extending the LoadDLLfunc* macros to
support passing of an auxillary routine or it could be simply ignored
since it doesn't harm :)

Since the current scheme works ok I don't have much arguments for my
patch. IMHO, first it does the right thing  and  second it saves some
memory. I cannot know the thoughts of the original implementor of
autoload.cc but maybe it intended to fix this duplication with the
.linkonce directive of gas or maybe he was willing to pay the prize of
the duplicate entries. However from what I understand .linkonce works only
for sections defined in different object files.

I am including the output of `objdump -h new-cygwin1.dll' with original
and patched autoload.cc.

Original autoload.cc:

new-cygwin1.dll:     file format pei-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
[...]
  2 .ws2_32_info  00000144  610d1000  610d1000  000cf600  2**2

  3 .wsock32_info 00000378  610d2000  610d2000  000cf800  2**2

  4 .advapi32_info 000006c0  610d3000  610d3000  000cfc00  2**2

  6 .netapi32_info 000000b0  610d5000  610d5000  000d1000  2**2

  8 .ntdll_info   00000160  610d7000  610d7000  000d1400  2**2

 10 .psapi_info   00000070  610d9000  610d9000  000d1a00  2**2

 12 .secur32_info 00000078  610db000  610db000  000d1e00  2**2

 14 .user32_info  00000310  610dd000  610dd000  000d2200  2**2

 18 .iphlpapi_info 00000064  610e1000  610e1000  000d3400  2**2

 20 .ole32_info   00000018  610e3000  610e3000  000d3800  2**2

 22 .kernel32_info 000001f4  610e5000  610e5000  000d3c00  2**2

 24 .shell32_info 00000018  610e7000  610e7000  000d4200  2**2

 26 .winmm_info   000001d0  610e9000  610e9000  000d4600  2**2

 28 .rpcrt4_info  00000030  610eb000  610eb000  000d4c00  2**2


Patched autoload.cc:

new-cygwin1.dll:     file format pei-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  2 .ws2_32_info  00000018  610d1000  610d1000  000cf600  2**2

  3 .wsock32_info 00000018  610d2000  610d2000  000cf800  2**2

  4 .advapi32_info 0000001c  610d3000  610d3000  000cfa00  2**2

  5 .netapi32_info 0000001c  610d4000  610d4000  000cfc00  2**2

  6 .ntdll_info   00000018  610d5000  610d5000  000cfe00  2**2

  7 .psapi_info   00000018  610d6000  610d6000  000d0000  2**2

  8 .secur32_info 00000018  610d7000  610d7000  000d0200  2**2

  9 .user32_info  00000018  610d8000  610d8000  000d0400  2**2

 10 .iphlpapi_info 0000001c  610d9000  610d9000  000d0600  2**2

 11 .ole32_info   00000018  610da000  610da000  000d0800  2**2

 12 .kernel32_info 0000001c  610db000  610db000  000d0a00  2**2

 13 .shell32_info 00000018  610dc000  610dc000  000d0c00  2**2

 14 .winmm_info   00000018  610dd000  610dd000  000d0e00  2**2

 15 .rpcrt4_info  00000018  610de000  610de000  000d1000  2**2
-------------- next part --------------
Index: autoload.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/autoload.cc,v
retrieving revision 1.95
diff -u -p -r1.95 autoload.cc
--- autoload.cc	3 Mar 2005 15:12:50 -0000	1.95
+++ autoload.cc	10 Mar 2005 10:12:41 -0000
@@ -76,7 +76,6 @@ details. */
 
 /* Main DLL setup stuff. */
 #define LoadDLLfuncEx2(name, n, dllname, notimp, err) \
-  LoadDLLprime (dllname, dll_func_load)			\
   __asm__ ("						\n\
   .section	." #dllname "_text,\"wx\"		\n\
   .global	_" mangle (name, n) "			\n\
@@ -299,6 +298,18 @@ wsock_init ()
 
 LoadDLLprime (wsock32, _wsock_init)
 LoadDLLprime (ws2_32, _wsock_init)
+LoadDLLprime (advapi32, dll_func_load)
+LoadDLLprime (netapi32, dll_func_load)
+LoadDLLprime (ntdll, dll_func_load)
+LoadDLLprime (psapi, dll_func_load)
+LoadDLLprime (secur32, dll_func_load)
+LoadDLLprime (user32, dll_func_load)
+LoadDLLprime (iphlpapi, dll_func_load)
+LoadDLLprime (ole32, dll_func_load)
+LoadDLLprime (kernel32, dll_func_load)
+LoadDLLprime (shell32, dll_func_load)
+LoadDLLprime (winmm, dll_func_load)
+LoadDLLprime (rpcrt4, dll_func_load)
 
 LoadDLLfunc (AccessCheck, 32, advapi32)
 LoadDLLfunc (AddAccessAllowedAce, 16, advapi32)


More information about the Cygwin-patches mailing list