binutils-gdb/ld/emultempl
Eric Botcazou 317ff0084b Speed up direct linking with DLLs on Windows (1/2).
This patch deals with the auto-import feature.  There are 2 versions
of this feature: the original one, which was piggybacked on the OS
loader with an optional help from the runtime (--enable-auto-import
--enable-runtime-pseudo-reloc-v1) and is still the one mostly
documented in the sources and manual; the enhanced one by Kai Tietz,
which is entirely piggybacked on the runtime (--enable-auto-import
--enable-runtime-pseudo-reloc-v2) and is the default for Mingw and
Cygwin nowadays.

The implementation is inefficient because of pe[p]_find_data_imports:
for every undefined symbol, the function walks the entire set of
relocations for all the input files and does a direct name comparison
for each of them.

This is easily fixable by using a hash-based map for v1 and a simple
hash table for v2.  This patch leaves v1 alone and only changes v2.
It also factors out pe[p]_find_data_imports into a common function,
removes old cruft left and right, and attempts to better separate
the implementations of v1 and v2 in the code.

ld/
	* emultempl/pe.em (U_SIZE): Delete.
	(pe_data_import_dll): Likewise.
	(make_import_fixup): Return void, take 4th parameter and pass it down
	in call to pe_create_import_fixup.
	(pe_find_data_imports): Move to...
	(gld_${EMULATION_NAME}_after_open): Run the stdcall fixup pass after
	the auto-import pass and add a guard before running the latter.
	* emultempl/pep.em (U_SIZE): Delete.
	(pep_data_import_dll): Likewise.
	(make_import_fixup): Return void, take 4th parameter and pass it down
	in call to pe_create_import_fixup.
	(pep_find_data_imports): Move to...
	(gld_${EMULATION_NAME}_after_open): Run the stdcall fixup pass after
	the auto-import pass and add a guard before running the latter.
	* pe-dll.c (runtime_pseudp_reloc_v2_init): Change type to bfd_boolean.
	(pe_walk_relocs_of_symbol): Rename into...
	(pe_walk_relocs): ...this.  Add 2 more parameters,4th parameter to the
	callback prototype and pass 4th parameter in calls to the callback.
	If the import hash table is present, invoke the callback on the reloc
	if the symbol name is in the table.
	(pe_find_data_imports): ...here.  Take 2 parameters.  Build an import
	hash table for the pseudo-relocation support version 2.  When it is
	built, walk the relocations only once at the end; when it is not, do
	not build a fixup when the symbol isn't part of an import table.
	Issue the associated warning only after a first fixup is built.
	(tmp_seq2): Delete.
	(make_singleton_name_imp): Likewise.
	(make_import_fixup_mark): Return const char * and a stable string.
	(make_import_fixup_entry): Do not deal with the pseudo-relocation
	support version 2.
	(make_runtime_pseudo_reloc): Factor out code and fix formatting.
	(pe_create_import_fixup): Add 5th parameter.  Clearly separate the
	pseudo-relocation support version 2 from the rest.  Fix formatting.
	* pe-dll.h (pe_walk_relocs_of_symbol): Delete.
	(pe_find_data_imports): Declare.
	(pe_create_import_fixup): Add 5th parameter.
	* pep-dll.c (pe_data_import_dll): Delete.
	(pe_find_data_imports): Define.
	(pe_walk_relocs_of_symbol): Delete.
	* pep-dll.h (pep_walk_relocs_of_symbol): Delete.
	(pep_find_data_imports): Declare.
	(pep_create_import_fixup): Add 5th parameter.
	* ld.texinfo (--enable-auto-import): Adjust to new implementation.
2018-04-04 12:07:50 +02:00
..
README Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
aarch64elf.em Ensure 8-byte alignment for AArch64 stubs. 2018-03-02 10:49:20 +00:00
aix.em ld error/warning messages 2018-02-26 10:51:12 +10:30
alphaelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
arclinux.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
armcoff.em ld error/warning messages 2018-02-26 10:51:12 +10:30
armelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
astring.sed
avrelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
beos.em ld error/warning messages 2018-02-26 10:51:12 +10:30
bfin.em ld error/warning messages 2018-02-26 10:51:12 +10:30
cr16elf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
crxelf.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
elf-generic.em ld error/warning messages 2018-02-26 10:51:12 +10:30
elf32.em ld: Add --enable-separate-code 2018-02-27 11:34:29 -08:00
epiphanyelf_4x4.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
genelf.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
generic.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
gld960.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
gld960c.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
hppaelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
ia64elf.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
irix.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
linux.em ld error/warning messages 2018-02-26 10:51:12 +10:30
lnk960.em ld error/warning messages 2018-02-26 10:51:12 +10:30
m68hc1xelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
m68kcoff.em ld error/warning messages 2018-02-26 10:51:12 +10:30
m68kelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
metagelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
mipself.em ld error/warning messages 2018-02-26 10:51:12 +10:30
mmix-elfnmmo.em ld error/warning messages 2018-02-26 10:51:12 +10:30
mmixelf.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
mmo.em ld error/warning messages 2018-02-26 10:51:12 +10:30
msp430.em ld error/warning messages 2018-02-26 10:51:12 +10:30
nds32elf.em nds32: Remove the unsupported target feature. 2018-03-15 14:50:51 +08:00
needrelax.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
netbsd.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
nios2elf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
ostring.sed
pe.em Speed up direct linking with DLLs on Windows (1/2). 2018-04-04 12:07:50 +02:00
pep.em Speed up direct linking with DLLs on Windows (1/2). 2018-04-04 12:07:50 +02:00
ppc32elf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
ppc64elf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
pruelf.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
riscvelf.em RISC-V: Don't enable relaxation in relocatable link 2018-03-15 09:54:51 +01:00
rxelf.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
s390.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
scoreelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
sh64elf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
solaris2.em solaris2.em: Fold after_allocation into before_allocation 2018-01-18 16:22:13 -08:00
spu_icache.S bfd/ 2009-03-17 12:46:19 +00:00
spu_icache.o_c Regenerate spu overlay and icache manager files 2014-11-04 22:36:13 +10:30
spu_ovl.S Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
spu_ovl.o_c Regenerate spu_ovl.o_c 2016-10-15 12:53:57 +10:30
spuelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
sunos.em ld error/warning messages 2018-02-26 10:51:12 +10:30
tic6xdsbt.em ld error/warning messages 2018-02-26 10:51:12 +10:30
ticoff.em ld error/warning messages 2018-02-26 10:51:12 +10:30
v850elf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
vanilla.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
vms.em ld error/warning messages 2018-02-26 10:51:12 +10:30
vxworks.em ld error/warning messages 2018-02-26 10:51:12 +10:30
xtensaelf.em ld error/warning messages 2018-02-26 10:51:12 +10:30
z80.em Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30

README

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The files in this directory are sourced by genscripts.sh, after
setting some variables to substitute in, to produce
C source files that contain jump tables for each emulation.

Copyright (C) 2012-2018 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.