* 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-08 Kai Tietz <kai.tietz@onevision.com>
+
+ * 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 <kai.tietz@onevision.com>
* emultempl/pe.em: Prefix dollar characters to be outputed in
-*- 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.
(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
{"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 */
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);
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
{"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. */
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);
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
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. */
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);
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;
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);
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;
#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
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;