[RFA] pei386 dll: auto-import patch

Charles Wilson cwilson@ece.gatech.edu
Tue Jul 31 12:02:00 GMT 2001


I have taken Paul Sokolovsky's auto-import and export-filtering patch, 
as modified by Robert Collins, and have updated it to current CVS.  I've 
added documentation concerning auto-import to ld.texinfo (under Machine 
Dependent section).  In addition to the extensive testing of the older 
version (as has been discussed on and off this list for the past several 
  weeks, esp. last week), I have rebuilt current CVS binutils with this 
patch, and it works as expected.  It adds desirable behavior to ld on 
x86 under windows-derived OS's, such as mingw and cygwin.  I believe all 
the issues raised by members of those communities have been addressed.

This patch actually commingles two behaviors: additional auto-EXport 
filtering and auto-import of DATA items.  However, the auto-EXport 
improvements are a prerequisite for the auto-import to work properly. 
Also, the auto-EXport filtering merely extends the current behavior 
using established hooks.  Thus, it's not really a "new" feature, and is 
combined with the novel auto-import patch for which it is necessary prereq.

Please apply.

--Charles Wilson

2001-07-31  Paul Sokolovsky  <paul.sokolovsky@technologist.com>

         * ld/pe-dll.c: new variable pe_dll_gory_debug. New static
         variable current_sec (static struct sec *)
         * ld/pe-dll.c (auto_export): change API, pass abfd for
         contextual filtering: don't export any symbols that come
         from libgcc, libstdc++, libmingw32. crt0.o, crt1.o
         or crt2.o.
         Do not export symbols starting with
            "_imp__" (e.g. don't re-export imported symbols)
            "__rtti_" or "__builtin_" (C++ support)
         Do not export the following symbols
            "DllMainCRTStartup@12" "_cygwin_dll_entry@12"
            "_cygwin_crt0_common@8" "_cygwin_noncygwin_dll_entry@12"
            "_fmode" "_impure_ptr" "cygwin_attach_dll" "cygwin_premain0"
            "cygwin_premain1" "cygwin_premain2" "cygwin_premain3"
	   "environ"
         Do not export symbols for specifying internal layout of DLLs
            exclude symbols starting with "_head_"
            exclude symbols ending with "_iname"
         * ld/pe-dll.c (process_def_file): Don't export undefined
	symbols. Do not export symbols starting with  "_imp__" (e.g.
	don't re-export imported symbols).  Call auto_export() with
	new API.
         * ld/pe-dll.c (pe_walk_relocs_of_symbol): New function.
         * ld/pe-dll.c (generate_reloc): add optional gory debugging
         * ld/pe-dll.c (pe_dll_generate_def_file): eliminate extraneous
         initial blank line in output
         * ld/pe-dll.c (make_one): enlarge symtab to make room for
         __nm__ symbols (DATA auto-import support).
         * ld/pe-dll.c (make_singleton_name_thunk): New function.
         * ld/pe-dll.c (make_import_fixup_mark): New function.
         * ld/pe-dll.c (make_import_fixup_entry): New function.
         * ld/pe-dll.c (pe_create_import_fixup): New function.
         * ld/pe-dll.c (add_bfd_to_link): make this function non-static.
	Specify that name argument is a CONST char *.

         * ld/pe-dll.h: declare new variables int pe_dll_auto_import and
         pe_dll_gory_debug; declare new functions
	pe_walk_relocs_of_symbol and pe_create_import_fixup.

         * ld/emultempl/pe.em: add options --disable-auto-import and
         --enable-gory-debug.  New variable data_import_dll.
         * ld/emultempl/pe.em (make_import_fixup): New function.
         * ld/emultempl/pe.em (pe_find_data_imports): New function.
         * ld/emultempl/pe.em (pr_sym): New function.
         * ld/emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Add
	optional gory debugging. Call pe_find_data_imports.  .idata is
	NOT code, it is data; flag it so.

         * ld/ldlang.c (load_symbols): check if
         ldemul_unrecognized_file(entry) prior to calling
         bfd_get_error()

         * bfd/cofflink.c: new variable pe_dll_auto_import
         * bfd/cofflink.c (coff_link_check_ar_symbols): also search for
         __imp__symbol as well as _symbol.

         * bfd/linker.c (_bfd_generic_link_add_archive_symbols): also
         search for __imp__symbol as well as _symbol.

2001-07-31  Charles Wilson  <cwilson@ece.gatech.edu>
	
	* ld/gen-doc.texi: process I80386 arch-specific documentation in
	ld.texinfo

         * ld/ld.texinfo: add additional documentation for
         --export-all-symbols.  Document --out-implib,
         --enable-auto-image-base, --disable-auto-image-base,
         --dll-search-prefix, and --disable-auto-import.  Add ix86
         machine-specific documentation; currently, only documents
         the auto-import changes for DLLs.



More information about the Binutils mailing list