This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: allow PE executables to have an export table
- From: Charles Wilson <cwilson at ece dot gatech dot edu>
- To: binutils at sources dot redhat dot com
- Date: Wed, 19 Feb 2003 21:40:58 -0500
- Subject: Re: PATCH: allow PE executables to have an export table
- References: <3E157D03.6020401@ece.gatech.edu>
Charles Wilson wrote:
Tested on cygwin, works as advertised. Updated patch attached (to apply
cleanly to current CVS, and hopefully address the formatting issues).
I've RE-updated this patch to apply to current CVS. I know that we're
still waiting on Fabrizio's copyright release -- but I can't remember if
that was pre-flood, post-flood, during the four month period when FSF
had no copyright administrator, etc.
Can one of the maintainers find out if Fabrizio's release has made it in
to FSF or not? Or if it's lying, waterlogged, behind an old filing cabinet?
--Chuck
2002-12-10 Fabrizio Gennari <fabrizio dot ge at tiscalinet dot it>
* ld/pe-dll.c (process_def_file): don't create an export
section if there are no exports and we're building an exe
(pe_dll_build_sections): ditto
(pe_dll_fill_sections): since this now gets called
even when we're building an exe, conditionalize setting
abfd->dll true on info->shared
* ld/emultempl/pe.em (gld_${EMULATION_NAME}_after_open):
if i386pe or armpe, call pe_dll_build_section()
for both exe's and dll's, not just dll's.
(gld_${EMULATION_NAME}_finish): for all targets except
shpe and mipspe, call pe_dll_fill_sections() for both
exe's and dll's, not just dll's.
? ld.log
? ldint.info
Index: pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.54
diff -u -r1.54 pe-dll.c
--- pe-dll.c 28 Jan 2003 11:39:43 -0000 1.54
+++ pe-dll.c 20 Feb 2003 02:34:49 -0000
@@ -564,6 +564,12 @@
}
}
+ /* If we are not building a DLL, when there are no exports
+ * we do not build an export table at all */
+
+ if (!pe_dll_export_everything && pe_def_file->num_exports == 0 && !(info->shared))
+ return;
+
/* Now, maybe export everything else the default way. */
if (pe_dll_export_everything || pe_def_file->num_exports == 0)
{
@@ -2666,6 +2672,9 @@
pe_dll_id_target (bfd_get_target (abfd));
process_def_file (abfd, info);
+ if (pe_def_file->num_exports == 0 && !(info->shared))
+ return;
+
generate_edata (abfd, info);
build_filler_bfd (1);
}
@@ -2707,7 +2716,8 @@
fill_edata (abfd, info);
- pe_data (abfd)->dll = 1;
+ if (info->shared)
+ pe_data (abfd)->dll = 1;
edata_s->contents = edata_d;
reloc_s->contents = reloc_d;
Index: emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.75
diff -u -r1.75 pe.em
--- emultempl/pe.em 23 Jan 2003 09:30:44 -0000 1.75
+++ emultempl/pe.em 20 Feb 2003 02:34:51 -0000
@@ -1023,8 +1023,11 @@
pe_process_import_defs (output_bfd, & link_info);
pe_find_data_imports ();
-
+#ifndef TARGET_IS_i386pe
+#ifndef TARGET_IS_armpe
if (link_info.shared)
+#endif
+#endif
pe_dll_build_sections (output_bfd, &link_info);
#ifndef TARGET_IS_i386pe
@@ -1461,7 +1464,11 @@
#endif /* defined(TARGET_IS_armpe) || defined(TARGET_IS_arm_epoc_pe) */
#ifdef DLL_SUPPORT
- if (link_info.shared)
+ if (link_info.shared
+#if !defined(TARGET_IS_shpe) && !defined(TARGET_IS_mipspe)
+|| pe_def_file->num_exports != 0
+#endif
+)
{
pe_dll_fill_sections (output_bfd, &link_info);
if (pe_implib_filename)