binutils-gdb/ld/emulparams
H.J. Lu dd7e64d45b Optimize out i386/x86-64 JUMP_SLOT relocation
When there are both PLT and GOT references to the same function symbol,
linker will create a GOTPLT slot for PLT entry and a GOT slot for GOT
reference.  A run-time JUMP_SLOT relocation is created to update the
GOTPLT slot and a run-time GLOB_DAT relocation is created to update the
GOT slot.  Both JUMP_SLOT and GLOB_DAT relocations will apply the same
symbol value to GOTPLT and GOT slots, respectively, at run-time.

This optimization combines GOTPLT and GOT slots into a single GOT slot
and removes the run-time JUMP_SLOT relocation.  It replaces the regular
PLT entry:

	indirect jump	[GOTPLT slot]
	push		relocation index
	jump		PLT0

with an GOT PLT entry with an indirect jump via the GOT slot:

	indirect jump	[GOT slot]
	nop

and resolves PLT reference to the GOT PLT entry.

We must avoid this optimization if pointer equality is needed since
we don't clear symbol value in this case and the dynamic linker won't
update the GOT slot.  Otherwise, the resulting binary will get into an
infinite loop at run-time.

bfd/

	* elf32-i386.c (elf_i386_got_plt_entry): New.
	(elf_i386_pic_got_plt_entry): Likewise.
	(elf_i386_link_hash_entry): Add plt_got.
	(elf_i386_link_hash_table): Likewise.
	(elf_i386_link_hash_newfunc): Initialize plt_got.offset to -1.
	(elf_i386_get_local_sym_hash): Likewise.
	(elf_i386_check_relocs): Create the GOT PLT if there are both
	PLT and GOT references when the regular PLT is used.
	(elf_i386_allocate_dynrelocs): Use the GOT PLT if there are
	both PLT and GOT references unless pointer equality is needed.
	(elf_i386_relocate_section): Also check the GOT PLT when
	resolving R_386_PLT32.
	(elf_i386_finish_dynamic_symbol): Use the GOT PLT if it is
	available.

	* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add plt_got.
	(elf_x86_64_link_hash_table): Likewise.
	(elf_x86_64_link_hash_newfunc): Initialize plt_got.offset to -1.
	(elf_x86_64_get_local_sym_hash): Likewise.
	(elf_x86_64_check_relocs): Create the GOT PLT if there are both
	PLT and GOT references when the regular PLT is used.
	(elf_x86_64_allocate_dynrelocs): Use the GOT PLT if there are
	both PLT and GOT references unless pointer equality is needed.
	(elf_x86_64_relocate_section): Also check the GOT PLT when
	resolving R_X86_64_PLT32.
	(elf_x86_64_finish_dynamic_symbol): Use the GOT PLT if it is
	available.

ld/

	* emulparams/elf_i386.sh (TINY_READONLY_SECTION): New.
	* emulparams/elf_x86_64.sh (TINY_READONLY_SECTION): Add .plt.got.

ld/testsuite/

	* ld-i386/i386.exp: Add run-time relocation tests for plt-main.
	* ld-i386/plt-main.rd: New file.
	* ld-x86-64/plt-main-bnd.dd: Likewise.
	* ld-x86-64/plt-main.rd: Likewise.
	* ld-x86-64/x86-64.exp: Add run-time relocation tests for
	plt-main.
2014-11-25 05:05:39 -08:00
..
README Update copyright years 2014-03-05 22:16:15 +10:30
aarch64elf.sh aarch64: Add support for GNU indirect functions. 2013-10-03 14:46:09 +00:00
aarch64elf32.sh ld/ChangeLog: 2013-11-21 11:17:50 -08:00
aarch64elf32b.sh [AArch64, ILP32] 6/6 Add big-endian targets 2013-06-26 10:56:05 +00:00
aarch64elfb.sh Add support for 64-bit ARM architecture: AArch64 2012-08-13 14:52:54 +00:00
aarch64linux.sh [AArch64] Define LP64 LE loader name. 2014-01-20 18:18:52 +00:00
aarch64linux32.sh 2014-02-11 Andrew Pinski <apinski@cavium.com> 2014-02-11 11:16:30 -08:00
aarch64linux32b.sh 2014-02-11 Andrew Pinski <apinski@cavium.com> 2014-02-11 11:16:30 -08:00
aarch64linuxb.sh [AArch64] Define LP64 BE linker name. 2014-01-20 18:20:04 +00:00
aix5ppc.sh
aix5rs6.sh
aixppc.sh
aixrs6.sh
alpha.sh
alphavms.sh 2010-04-14 Tristan Gingold <gingold@adacore.com> 2010-04-14 09:27:27 +00:00
arcelf.sh
arm_epoc_pe.sh
arm_wince_pe.sh
armaoutb.sh
armaoutl.sh
armcoff.sh
armelf.sh ld/ 2009-11-20 15:04:51 +00:00
armelf_fbsd.sh * emulparams/armelf_fbsd.sh (TEXT_START_ADDR): Increase alignment to 64kB boundary like in armelf_linux.sh 2014-08-22 06:33:45 +02:00
armelf_linux.sh ld/ARM: Increase maximum page size to 64kB 2014-07-08 15:00:12 +01:00
armelf_linux_eabi.sh ld/ 2009-11-20 15:04:51 +00:00
armelf_nacl.sh * elf32-arm.c (elf32_arm_nacl_plt0_entry, elf32_arm_nacl_plt_entry): 2012-04-12 13:01:15 +00:00
armelf_nbsd.sh
armelf_vxworks.sh
armelfb.sh
armelfb_fbsd.sh ld/ARM: Add target arm*b-*-freebsd*, update target arm*-*-freebsd*. 2014-06-18 21:58:19 +02:00
armelfb_linux.sh
armelfb_linux_eabi.sh
armelfb_nacl.sh * elf32-arm.c (elf32_arm_nacl_plt0_entry, elf32_arm_nacl_plt_entry): 2012-04-12 13:01:15 +00:00
armelfb_nbsd.sh
armnbsd.sh
armnto.sh
armpe.sh
armsymbian.sh ld/ 2009-11-20 15:04:51 +00:00
avr1.sh
avr2.sh
avr3.sh
avr4.sh
avr5.sh
avr6.sh
avr25.sh
avr31.sh
avr35.sh
avr51.sh
avrtiny.sh Add support for the AVR Tiny series of microcontrollers. 2014-07-01 10:20:17 +01:00
avrxmega1.sh /bfd: 2011-03-22 18:10:48 +00:00
avrxmega2.sh /bfd: 2011-03-22 18:10:48 +00:00
avrxmega3.sh /bfd: 2011-03-22 18:10:48 +00:00
avrxmega4.sh /bfd: 2011-03-22 18:10:48 +00:00
avrxmega5.sh /bfd: 2011-03-22 18:10:48 +00:00
avrxmega6.sh /bfd: 2011-03-22 18:10:48 +00:00
avrxmega7.sh /bfd: 2011-03-22 18:10:48 +00:00
coff_i860.sh
coff_sparc.sh
crisaout.sh
criself.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
crislinux.sh * emulparams/crislinux.sh (COMMONPAGESIZE): Define. 2014-01-10 01:25:26 +01:00
d10velf.sh
d30v_e.sh
d30v_o.sh
d30velf.sh
delta68.sh
elf32_dlx.sh
elf32_i860.sh
elf32_i960.sh
elf32_sparc.sh * emulparams/elf32_sparc.sh: Set NOP to 0x01000000 2010-09-20 18:41:15 +00:00
elf32_sparc_sol2.sh ld: 2010-10-22 12:08:32 +00:00
elf32_sparc_vxworks.sh
elf32_spu.sh
elf32_tic6x_be.sh bfd: 2010-03-25 21:12:36 +00:00
elf32_tic6x_elf_be.sh ld/ 2011-05-13 18:15:33 +00:00
elf32_tic6x_elf_le.sh ld/ 2011-05-13 18:15:33 +00:00
elf32_tic6x_le.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
elf32_tic6x_linux_be.sh ld/ 2011-05-13 18:15:33 +00:00
elf32_tic6x_linux_le.sh ld/ 2011-05-13 18:15:33 +00:00
elf32_x86_64.sh Skip directories with LIBPATH_SUFFIX_SKIP suffix 2014-01-15 20:09:09 -08:00
elf32_x86_64_nacl.sh bfd/ 2013-08-26 22:18:07 +00:00
elf32am33lin.sh
elf32b4300.sh
elf32bfin.sh fix 2014-05-28 ld Makefile.am changes 2014-06-02 14:52:52 +09:30
elf32bfinfd.sh fix 2014-05-28 ld Makefile.am changes 2014-06-02 14:52:52 +09:30
elf32bmip.sh [MIPS] Implement O32 FPXX, FP64 and FP64A ABI extensions 2014-07-29 11:27:59 +01:00
elf32bmipn32-defs.sh [MIPS] Implement O32 FPXX, FP64 and FP64A ABI extensions 2014-07-29 11:27:59 +01:00
elf32bmipn32.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
elf32bsmip.sh
elf32btsmip.sh bfd/ 2013-06-24 23:55:46 +00:00
elf32btsmip_fbsd.sh bfd/ 2010-12-31 11:01:00 +00:00
elf32btsmipn32.sh
elf32btsmipn32_fbsd.sh bfd/ 2010-12-31 11:01:00 +00:00
elf32cr16.sh
elf32cr16c.sh
elf32crx.sh
elf32ebmip.sh
elf32ebmipvxworks.sh
elf32elmip.sh
elf32elmipvxworks.sh
elf32epiphany.sh bfd: 2011-10-25 11:18:16 +00:00
elf32epiphany_4x4.sh * scripttempl/epiphany_4x4.sc, emulparams/elf32epiphany_4x4.sh: Add. 2012-11-30 18:28:38 +00:00
elf32fr30.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
elf32frv.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
elf32frvfd.sh
elf32i370.sh
elf32ip2k.sh
elf32iq10.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
elf32iq2000.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
elf32l4300.sh
elf32lm32.sh
elf32lm32fd.sh
elf32lmip.sh
elf32lppc.sh bfd/ 2013-04-25 13:22:52 +00:00
elf32lppclinux.sh bfd/ 2013-04-25 13:22:52 +00:00
elf32lppcnto.sh
elf32lppcsim.sh
elf32lr5900.sh * archures.c: Add support for MIPS r5900 2013-01-04 17:22:53 +00:00
elf32lr5900n32.sh * archures.c: Add support for MIPS r5900 2013-01-04 17:22:53 +00:00
elf32lsmip.sh
elf32ltsmip.sh
elf32ltsmip_fbsd.sh bfd/ 2010-12-31 11:01:00 +00:00
elf32ltsmipn32.sh
elf32ltsmipn32_fbsd.sh bfd/ 2010-12-31 11:01:00 +00:00
elf32m32c.sh
elf32mb_linux.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
elf32mbel_linux.sh Files missing from previous commit. 2012-11-09 22:43:28 +00:00
elf32mcore.sh * ldmain.c (main): Flush stdout before and stderr after printing 2011-01-14 12:37:17 +00:00
elf32mep.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
elf32metag.sh * common.h: Fix case of "Meta". 2013-01-10 09:49:22 +00:00
elf32microblaze.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
elf32microblazeel.sh Files missing from previous commit. 2012-11-09 22:43:28 +00:00
elf32mipswindiss.sh ld/ 2012-08-06 22:40:36 +00:00
elf32moxie.sh Bi-endian patches for moxie 2012-09-13 22:24:51 +00:00
elf32mt.sh
elf32or1k.sh Remove support for the (deprecated) openrisc and or32 configurations and replace 2014-04-22 15:57:47 +01:00
elf32or1k_linux.sh or1k: increase linux TEXT_START_ADDR to 0x2000 2014-07-17 00:26:45 +03:00
elf32ppc.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
elf32ppc_fbsd.sh * Makefile.am (ALL_64_EMULATION_SOURCES): Add powerpc64-*-freebsd 2011-11-21 13:22:46 +00:00
elf32ppccommon.sh Rewrite ppc32 backend .sdata and .sdata2 handling 2014-05-20 13:13:23 +09:30
elf32ppclinux.sh
elf32ppcnto.sh
elf32ppcsim.sh
elf32ppcvxworks.sh Fix ELF ppc32 targets that don't use ppc32elf.em 2014-02-27 23:39:01 +10:30
elf32ppcwindiss.sh
elf32rl78.sh [.] 2011-11-02 03:09:11 +00:00
elf32rx.sh * emulparams/elf32rx.sh (OTHER_READONLY_SECTIONS): Add W_* sections. 2012-09-12 21:28:04 +00:00
elf32tilegx.sh Don't hardcode .got.plt into DATA_SEGMENT_RELRO_END evaluation 2012-06-11 13:23:51 +00:00
elf32tilegx_be.sh Add big-endian support for tilegx. 2012-02-25 19:51:34 +00:00
elf32tilepro.sh Don't hardcode .got.plt into DATA_SEGMENT_RELRO_END evaluation 2012-06-11 13:23:51 +00:00
elf32vax.sh
elf32xc16x.sh
elf32xc16xl.sh
elf32xc16xs.sh
elf32xstormy16.sh
elf32xtensa.sh
elf64_aix.sh
elf64_ia64.sh
elf64_ia64_fbsd.sh
elf64_ia64_vms.sh * configure.ac (ia64*-*-*vms*): Add support for ld. 2012-04-12 07:35:07 +00:00
elf64_s390.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
elf64_sparc.sh
elf64_sparc_fbsd.sh
elf64_sparc_sol2.sh ld: 2010-10-22 12:08:32 +00:00
elf64alpha.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
elf64alpha_fbsd.sh
elf64alpha_nbsd.sh
elf64bmip-defs.sh [MIPS] Implement O32 FPXX, FP64 and FP64A ABI extensions 2014-07-29 11:27:59 +01:00
elf64bmip.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
elf64btsmip.sh
elf64btsmip_fbsd.sh bfd/ 2010-12-31 11:01:00 +00:00
elf64hppa.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
elf64lppc.sh
elf64ltsmip.sh
elf64ltsmip_fbsd.sh bfd/ 2010-12-31 11:01:00 +00:00
elf64mmix.sh
elf64ppc.sh * emulparams/elf32ppccommon.sh (LIBPATH_SUFFIX): Provide 32-bit 2013-09-24 06:29:39 +00:00
elf64ppc_fbsd.sh * Makefile.am (ALL_64_EMULATION_SOURCES): Add powerpc64-*-freebsd 2011-11-21 13:22:46 +00:00
elf64rdos.sh * Makefile.am (ALL_64_EMULATION_SOURCES): Add eelf64rdos.c. 2013-01-23 10:31:13 +00:00
elf64tilegx.sh Don't hardcode .got.plt into DATA_SEGMENT_RELRO_END evaluation 2012-06-11 13:23:51 +00:00
elf64tilegx_be.sh Add big-endian support for tilegx. 2012-02-25 19:51:34 +00:00
elf_fbsd.sh
elf_i386.sh Optimize out i386/x86-64 JUMP_SLOT relocation 2014-11-25 05:05:39 -08:00
elf_i386_be.sh Support arch-dependent fill 2012-01-31 17:54:39 +00:00
elf_i386_chaos.sh * emultempl/elf32.em (gld${EMULATION_NAME}_add_options, 2011-07-14 02:38:43 +00:00
elf_i386_fbsd.sh
elf_i386_ldso.sh Support arch-dependent fill 2012-01-31 17:54:39 +00:00
elf_i386_nacl.sh bfd/ 2013-08-26 22:18:07 +00:00
elf_i386_sol2.sh * emultempl/solaris2.em (elf_solaris2_before_allocation): Renamed 2010-10-12 18:39:36 +00:00
elf_i386_vxworks.sh Support arch-dependent fill 2012-01-31 17:54:39 +00:00
elf_k1om.sh Define IREL_IN_PLT for elf_k1om.sh and elf_l1om.sh 2013-12-20 08:27:02 -08:00
elf_k1om_fbsd.sh Add initial Intel K1OM support. 2011-07-22 20:22:38 +00:00
elf_l1om.sh Define IREL_IN_PLT for elf_k1om.sh and elf_l1om.sh 2013-12-20 08:27:02 -08:00
elf_l1om_fbsd.sh
elf_nacl.sh ld/ 2013-08-23 22:38:42 +00:00
elf_s390.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
elf_x86_64.sh Optimize out i386/x86-64 JUMP_SLOT relocation 2014-11-25 05:05:39 -08:00
elf_x86_64_fbsd.sh
elf_x86_64_nacl.sh bfd/ 2013-08-26 22:18:07 +00:00
elf_x86_64_sol2.sh * emultempl/solaris2.em (elf_solaris2_before_allocation): Renamed 2010-10-12 18:39:36 +00:00
gld960.sh
gld960coff.sh
h8300.sh
h8300elf.sh
h8300h.sh
h8300helf.sh
h8300hn.sh
h8300hnelf.sh
h8300s.sh
h8300self.sh
h8300sn.sh
h8300snelf.sh
h8300sx.sh
h8300sxelf.sh
h8300sxn.sh
h8300sxnelf.sh
h8500.sh
h8500b.sh
h8500c.sh
h8500m.sh
h8500s.sh
hp3hpux.sh
hp300bsd.sh
hppa64linux.sh
hppaelf.sh
hppalinux.sh PR ld/12376 2011-02-18 18:20:29 +00:00
hppanbsd.sh
hppaobsd.sh
i386aout.sh
i386beos.sh strip off +x bits on non-executable/script files 2013-12-07 02:03:03 -05:00
i386bsd.sh
i386coff.sh
i386go32.sh
i386linux.sh
i386lynx.sh
i386mach.sh
i386moss.sh
i386msdos.sh
i386nbsd.sh
i386nto.sh
i386nw.sh
i386pe.sh Remove remaining default manifest support. 2014-04-09 17:12:30 +01:00
i386pe_posix.sh
i386pep.sh Remove remaining default manifest support. 2014-04-09 17:12:30 +01:00
lnk960.sh
m32relf.sh
m32relf_linux.sh
m32rlelf.sh
m32rlelf_linux.sh
m68hc11elf.sh
m68hc11elfb.sh
m68hc12elf.sh
m68hc12elfb.sh
m68k4knbsd.sh
m68kaout.sh
m68kaux.sh
m68kcoff.sh
m68kelf.sh
m68kelfnbsd.sh
m68klinux.sh
m68knbsd.sh
m68kpsos.sh
m88kbcs.sh
mcorepe.sh
mmo.sh
mn10200.sh
mn10300.sh
moxiebox.sh Add moxiebox target 2014-07-27 08:51:20 -04:00
msp430.sh fix 2014-05-28 ld Makefile.am changes 2014-06-02 14:52:52 +09:30
msp430X.sh fix 2014-05-28 ld Makefile.am changes 2014-06-02 14:52:52 +09:30
nds32belf.sh Add support for Andes NDS32: 2013-12-13 11:52:32 +00:00
nds32belf16m.sh Add support for Andes NDS32: 2013-12-13 11:52:32 +00:00
nds32belf_linux.sh Add support for Andes NDS32: 2013-12-13 11:52:32 +00:00
nds32elf.sh Allow ld target customiser script to force on disk scripts. 2014-01-17 10:41:49 +10:30
nds32elf16m.sh Allow ld target customiser script to force on disk scripts. 2014-01-17 10:41:49 +10:30
nds32elf_linux.sh Allow ld target customiser script to force on disk scripts. 2014-01-17 10:41:49 +10:30
news.sh
nios2elf.sh Nios II CALL26 linker relaxation 2014-01-30 17:47:07 -08:00
nios2linux.sh 2014-05-11 Chung-Lin Tang <cltang@codesourcery.com> 2014-05-11 10:04:45 -07:00
ns32knbsd.sh
pc532macha.sh
pdp11.sh
pjelf.sh
pjlelf.sh
plt_unwind.sh * emultempl/elf32.em (gld${EMULATION_NAME}_add_options, 2011-07-14 02:38:43 +00:00
ppclynx.sh
ppcmacos.sh
ppcnw.sh
ppcpe.sh
riscix.sh
score3_elf.sh fix 2014-05-28 ld Makefile.am changes 2014-06-02 14:52:52 +09:30
score7_elf.sh fix 2014-05-28 ld Makefile.am changes 2014-06-02 14:52:52 +09:30
sh.sh
shelf.sh
shelf32.sh
shelf32_linux.sh
shelf32_nbsd.sh
shelf64.sh
shelf64_nbsd.sh
shelf_fd.sh 2010-05-21 Daniel Jacobowitz <dan@codesourcery.com> 2010-05-25 14:12:43 +00:00
shelf_linux.sh
shelf_nbsd.sh
shelf_nto.sh
shelf_uclinux.sh
shelf_vxworks.sh
shl.sh
shlelf.sh
shlelf32.sh
shlelf32_linux.sh
shlelf32_nbsd.sh
shlelf64.sh
shlelf64_nbsd.sh
shlelf_fd.sh 2010-05-21 Daniel Jacobowitz <dan@codesourcery.com> 2010-05-25 14:12:43 +00:00
shlelf_linux.sh 2010-05-21 Daniel Jacobowitz <dan@codesourcery.com> 2010-05-25 14:12:43 +00:00
shlelf_nbsd.sh
shlelf_nto.sh
shlelf_vxworks.sh
shlsymbian.sh
shpe.sh
solaris2.sh * emultempl/solaris2.em (elf_solaris2_before_allocation): Renamed 2010-10-12 18:39:36 +00:00
sparcaout.sh
sparclinux.sh
sparcnbsd.sh
st2000.sh
sun3.sh
sun4.sh
tic3xcoff.sh
tic3xcoff_onchip.sh
tic4xcoff.sh
tic30aout.sh
tic30coff.sh
tic54xcoff.sh
tic80coff.sh Remove trailing white spaces in ld 2013-01-10 20:08:03 +00:00
v850.sh
v850_rh850.sh 2012-11-09 Nick Clifton <nickc@redhat.com> 2012-11-09 17:36:19 +00:00
vanilla.sh
vax.sh
vaxnbsd.sh
vsta.sh
vxworks.sh
w65.sh
xgateelf.sh Add support for Motorola XGATE embedded CPU 2012-05-03 13:12:08 +00:00
z80.sh
z8001.sh
z8002.sh

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 read by genscripts.sh as shell commands.
They set parameters for the emulations.

Copyright (C) 2012-2014 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.