From: Kai Tietz Date: Thu, 8 Jan 2009 13:28:48 +0000 (+0000) Subject: 2009-01-08 Kai Tietz X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce11ba6c9d65f4606431e5d73986ad87e3ee9583;p=binutils-gdb.git 2009-01-08 Kai Tietz * pe.em (OPTION_USE_NUL_PREFIXED_IMPORT_TABLES): New. (gld..._add_options): Add new option --use-nul-prefixed-import-tables. (gld..._handle_option): Likewise. * pep.em: Same as for pe.em. * ld.texinfo: Add new option documentation for --use-nul-prefixed-import-tables. * pe-dll.c (pe_use_nul_prefixed_import_tables): New. (make_head): Make prefix leading zero prefix element for idata$4 and idata$5 dependent to new flag. (make_import_fixup_entry): Remove idata4/5 prefix. * pe-dll.h (pe_use_nul_prefixed_import_tables): New. * pep-dll.c (pe_use_nul_prefixed_import_tables): New. * pep-dll.h (pep_use_nul_prefixed_import_tables): New. * NEWS: Add new option. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index a87bbad723c..747633c846c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,21 @@ +2009-01-08 Kai Tietz + + * pe.em (OPTION_USE_NUL_PREFIXED_IMPORT_TABLES): New. + (gld..._add_options): Add new option + --use-nul-prefixed-import-tables. + (gld..._handle_option): Likewise. + * pep.em: Same as for pe.em. + * ld.texinfo: Add new option documentation for + --use-nul-prefixed-import-tables. + * pe-dll.c (pe_use_nul_prefixed_import_tables): New. + (make_head): Make prefix leading zero prefix element for + idata$4 and idata$5 dependent to new flag. + (make_import_fixup_entry): Remove idata4/5 prefix. + * pe-dll.h (pe_use_nul_prefixed_import_tables): New. + * pep-dll.c (pe_use_nul_prefixed_import_tables): New. + * pep-dll.h (pep_use_nul_prefixed_import_tables): New. + * NEWS: Add new option. + 2009-01-05 Kai Tietz * emultempl/pe.em: Prefix dollar characters to be outputed in diff --git a/ld/NEWS b/ld/NEWS index 9bf378064ac..9e56775923f 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -1,4 +1,8 @@ -*- text -*- + +* Add new option --use-nul-prefixed-import-tables to ld for PE targets to + allow fallback to old import table generation with null element prefix. + * Windows PE systems now support a new --exclude-modules-for-implib option, allowing users to partition object files and archive members between a DLL and its associated import library as they are generated during linking. diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 26a70a743aa..d2d34adb955 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -209,6 +209,8 @@ gld_${EMULATION_NAME}_before_parse (void) (OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V1 + 1) #define OPTION_EXCLUDE_MODULES_FOR_IMPLIB \ (OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V2 + 1) +#define OPTION_USE_NUL_PREFIXED_IMPORT_TABLES \ + (OPTION_EXCLUDE_MODULES_FOR_IMPLIB + 1) static void gld${EMULATION_NAME}_add_options @@ -234,6 +236,8 @@ gld${EMULATION_NAME}_add_options {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM}, {"support-old-code", no_argument, NULL, OPTION_SUPPORT_OLD_CODE}, {"thumb-entry", required_argument, NULL, OPTION_THUMB_ENTRY}, + {"use-nul-prefixed-import-tables", no_argument, NULL, + OPTION_USE_NUL_PREFIXED_IMPORT_TABLES}, #ifdef DLL_SUPPORT /* getopt allows abbreviations, so we do this to stop it from treating -o as an abbreviation for this option */ @@ -596,6 +600,9 @@ gld${EMULATION_NAME}_handle_option (int optc) case OPTION_THUMB_ENTRY: thumb_entry_symbol = optarg; break; + case OPTION_USE_NUL_PREFIXED_IMPORT_TABLES: + pe_use_nul_prefixed_import_tables = TRUE; + break; #ifdef DLL_SUPPORT case OPTION_OUT_DEF: pe_out_def_filename = xstrdup (optarg); diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index f921c1ec632..f6f802e12e2 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -176,7 +176,8 @@ enum options OPTION_DLL_DISABLE_RUNTIME_PSEUDO_RELOC, OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V1, OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V2, - OPTION_EXCLUDE_MODULES_FOR_IMPLIB + OPTION_EXCLUDE_MODULES_FOR_IMPLIB, + OPTION_USE_NUL_PREFIXED_IMPORT_TABLES }; static void @@ -206,6 +207,8 @@ gld${EMULATION_NAME}_add_options {"stack", required_argument, NULL, OPTION_STACK}, {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM}, {"support-old-code", no_argument, NULL, OPTION_SUPPORT_OLD_CODE}, + {"use-nul-prefixed-import-tables", no_argument, NULL, + OPTION_USE_NUL_PREFIXED_IMPORT_TABLES}, #ifdef DLL_SUPPORT /* getopt allows abbreviations, so we do this to stop it from treating -o as an abbreviation for this option. */ @@ -556,6 +559,9 @@ gld${EMULATION_NAME}_handle_option (int optc) case OPTION_SUPPORT_OLD_CODE: support_old_code = 1; break; + case OPTION_USE_NUL_PREFIXED_IMPORT_TABLES: + pep_use_nul_prefixed_import_tables = TRUE; + break; #ifdef DLL_SUPPORT case OPTION_OUT_DEF: pep_out_def_filename = xstrdup (optarg); diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 11bde2936fd..3f1654614de 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -5619,6 +5619,13 @@ But it also sets the bottom bit of the address, so that it can be branched to using a BX instruction, and the program will start executing in Thumb mode straight away. +@cindex PE import table prefixing +@kindex --use-nul-prefixed-import-tables +The @samp{--use-nul-prefixed-import-tables} switch is specifying, that +the import tables idata4 and idata5 have to be generated with a zero +elememt prefix for import libraries. This is the old style to generate +import tables. By default this option is turned off. + @cindex BE8 @kindex --be8 The @samp{--be8} switch instructs @command{ld} to generate BE8 format diff --git a/ld/pe-dll.c b/ld/pe-dll.c index d76d0cfc349..89e15414847 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -155,6 +155,7 @@ int pe_dll_stdcall_aliases = 0; int pe_dll_warn_dup_exports = 0; int pe_dll_compat_implib = 0; int pe_dll_extra_pe_debug = 0; +int pe_use_nul_prefixed_import_tables = 0; /* Static variables and types. */ @@ -1796,18 +1797,24 @@ make_head (bfd *parent) d2 = xmalloc (20); id2->contents = d2; memset (d2, 0, 20); - d2[0] = d2[16] = PE_IDATA5_SIZE; /* Reloc addend. */ + if (pe_use_nul_prefixed_import_tables) + d2[0] = d2[16] = PE_IDATA5_SIZE; /* Reloc addend. */ quick_reloc (abfd, 0, BFD_RELOC_RVA, 2); quick_reloc (abfd, 12, BFD_RELOC_RVA, 4); quick_reloc (abfd, 16, BFD_RELOC_RVA, 1); save_relocs (id2); - bfd_set_section_size (abfd, id5, PE_IDATA5_SIZE); + if (pe_use_nul_prefixed_import_tables) + bfd_set_section_size (abfd, id5, PE_IDATA5_SIZE); + else + bfd_set_section_size (abfd, id5, 0); d5 = xmalloc (PE_IDATA5_SIZE); id5->contents = d5; memset (d5, 0, PE_IDATA5_SIZE); - - bfd_set_section_size (abfd, id4, PE_IDATA4_SIZE); + if (pe_use_nul_prefixed_import_tables) + bfd_set_section_size (abfd, id4, PE_IDATA4_SIZE); + else + bfd_set_section_size (abfd, id4, 0); d4 = xmalloc (PE_IDATA4_SIZE); id4->contents = d4; memset (d4, 0, PE_IDATA4_SIZE); @@ -1815,8 +1822,16 @@ make_head (bfd *parent) bfd_set_symtab (abfd, symtab, symptr); bfd_set_section_contents (abfd, id2, d2, 0, 20); - bfd_set_section_contents (abfd, id5, d5, 0, PE_IDATA5_SIZE); - bfd_set_section_contents (abfd, id4, d4, 0, PE_IDATA4_SIZE); + if (pe_use_nul_prefixed_import_tables) + { + bfd_set_section_contents (abfd, id5, d5, 0, PE_IDATA5_SIZE); + bfd_set_section_contents (abfd, id4, d4, 0, PE_IDATA4_SIZE); + } + else + { + bfd_set_section_contents (abfd, id5, d5, 0, 0); + bfd_set_section_contents (abfd, id4, d4, 0, 0); + } bfd_make_readable (abfd); return abfd; @@ -2279,7 +2294,6 @@ make_import_fixup_entry (const char *name, d2 = xmalloc (20); id2->contents = d2; memset (d2, 0, 20); - d2[0] = d2[16] = PE_IDATA5_SIZE; /* Reloc addend. */ quick_reloc (abfd, 0, BFD_RELOC_RVA, 1); quick_reloc (abfd, 12, BFD_RELOC_RVA, 2); diff --git a/ld/pe-dll.h b/ld/pe-dll.h index 83e7422fe6f..22630dc9ebb 100644 --- a/ld/pe-dll.h +++ b/ld/pe-dll.h @@ -35,6 +35,7 @@ extern int pe_dll_stdcall_aliases; extern int pe_dll_warn_dup_exports; extern int pe_dll_compat_implib; extern int pe_dll_extra_pe_debug; +extern int pe_use_nul_prefixed_import_tables; typedef enum { EXCLUDESYMS, EXCLUDELIBS, EXCLUDEFORIMPLIB } exclude_type; diff --git a/ld/pep-dll.c b/ld/pep-dll.c index 89d237c9c8f..a7c31a70a58 100644 --- a/ld/pep-dll.c +++ b/ld/pep-dll.c @@ -33,6 +33,8 @@ #define pe_dll_kill_ats pep_dll_kill_ats #define pe_dll_stdcall_aliases pep_dll_stdcall_aliases #define pe_dll_warn_dup_exports pep_dll_warn_dup_exports +#define pe_use_nul_prefixed_import_tables \ + pep_use_nul_prefixed_import_tables /* External globals. */ #define pe_data_import_dll pep_data_import_dll diff --git a/ld/pep-dll.h b/ld/pep-dll.h index 5d09658894f..76ad61af8db 100644 --- a/ld/pep-dll.h +++ b/ld/pep-dll.h @@ -35,6 +35,7 @@ extern int pep_dll_stdcall_aliases; extern int pep_dll_warn_dup_exports; extern int pep_dll_compat_implib; extern int pep_dll_extra_pe_debug; +extern int pep_use_nul_prefixed_import_tables; typedef enum { EXCLUDESYMS, EXCLUDELIBS, EXCLUDEFORIMPLIB } exclude_type;