diff -ruN ld/emultempl/pe.em ld-patched/emultempl/pe.em --- ld/emultempl/pe.em 2002-11-30 09:39:46.000000000 +0100 +++ ld-patched/emultempl/pe.em 2002-12-09 01:29:36.000000000 +0100 @@ -1012,7 +1012,11 @@ pe_find_data_imports (); pe_process_import_defs(output_bfd, &link_info); +#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 @@ -1443,7 +1447,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) diff -ruN ld/pe-dll.c ld-patched/pe-dll.c --- ld/pe-dll.c 2002-12-09 01:20:22.000000000 +0100 +++ ld-patched/pe-dll.c 2002-12-09 01:17:28.000000000 +0100 @@ -561,6 +561,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) { @@ -2588,6 +2594,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); } @@ -2629,7 +2638,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;