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.
This commit is contained in:
Kai Tietz 2009-01-08 13:28:48 +00:00
parent dde0281261
commit ce11ba6c9d
9 changed files with 68 additions and 8 deletions

View File

@ -1,3 +1,21 @@
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

View File

@ -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.

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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;