binutils-gdb/bfd/elf-s390-common.c

317 lines
9.6 KiB
C
Raw Normal View History

2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
/* IBM S/390-specific support for ELF 32 and 64 bit functions
Copyright (C) 2000-2015 Free Software Foundation, Inc.
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
Contributed by Andreas Krebbel.
This file is part of BFD, the Binary File Descriptor library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
/* Return TRUE if H is an IFUNC symbol. Simply checking for the
symbol type might not be enough since it might get changed to
STT_FUNC for pointer equality reasons. */
static inline bfd_boolean
s390_is_ifunc_symbol_p (struct elf_link_hash_entry *h)
{
struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry*)h;
return h->type == STT_GNU_IFUNC || eh->ifunc_resolver_address != 0;
}
/* Create sections needed by STT_GNU_IFUNC symbol. */
static bfd_boolean
s390_elf_create_ifunc_sections (bfd *abfd, struct bfd_link_info *info)
{
flagword flags;
asection *s;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
struct elf_link_hash_table *htab = elf_hash_table (info);
if (htab->iplt != NULL)
return TRUE;
flags = bed->dynamic_sec_flags;
Add output_type to bfd_link_info The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise.
2015-08-18 14:51:03 +02:00
if (bfd_link_pic (info))
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
{
s = bfd_make_section_with_flags (abfd, ".rela.ifunc",
flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s,
bed->s->log_file_align))
return FALSE;
htab->irelifunc = s;
}
/* Create .iplt, .rel[a].iplt, and .igot.plt. */
s = bfd_make_section_with_flags (abfd, ".iplt",
flags | SEC_CODE | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
return FALSE;
htab->iplt = s;
s = bfd_make_section_with_flags (abfd, ".rela.iplt", flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s,
bed->s->log_file_align))
return FALSE;
htab->irelplt = s;
s = bfd_make_section_with_flags (abfd, ".igot.plt", flags);
if (s == NULL
|| !bfd_set_section_alignment (abfd, s,
bed->s->log_file_align))
return FALSE;
htab->igotplt = s;
return TRUE;
}
/* Allocate space in .plt, .got and associated reloc sections for
dynamic relocs against a STT_GNU_IFUNC symbol definition. */
static bfd_boolean
s390_elf_allocate_ifunc_dyn_relocs (struct bfd_link_info *info,
struct elf_link_hash_entry *h,
struct elf_dyn_relocs **head)
{
struct elf_dyn_relocs *p;
struct elf_link_hash_table *htab;
struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry*)h;
htab = elf_hash_table (info);
eh->ifunc_resolver_address = h->root.u.def.value;
eh->ifunc_resolver_section = h->root.u.def.section;
/* Support garbage collection against STT_GNU_IFUNC symbols. */
if (h->plt.refcount <= 0 && h->got.refcount <= 0)
{
/* When building shared library, we need to handle the case
where it is marked with regular reference, but not non-GOT
reference. It may happen if we didn't see STT_GNU_IFUNC
symbol at the time when checking relocations. */
Add output_type to bfd_link_info The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise.
2015-08-18 14:51:03 +02:00
if (bfd_link_pic (info)
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
&& !h->non_got_ref
&& h->ref_regular)
for (p = *head; p != NULL; p = p->next)
if (p->count)
{
h->non_got_ref = 1;
goto keep;
}
h->got = htab->init_got_offset;
h->plt = htab->init_plt_offset;
*head = NULL;
return TRUE;
}
/* Return and discard space for dynamic relocations against it if
it is never referenced in a non-shared object. */
if (!h->ref_regular)
{
if (h->plt.refcount > 0
|| h->got.refcount > 0)
abort ();
h->got = htab->init_got_offset;
h->plt = htab->init_plt_offset;
*head = NULL;
return TRUE;
}
keep:
/* Without checking h->plt.refcount here we allocate a PLT slot.
When setting plt.refcount in check_relocs it might not have been
known that this will be an IFUNC symol. */
h->plt.offset = htab->iplt->size;
h->needs_plt = 1;
htab->iplt->size += PLT_ENTRY_SIZE;
htab->igotplt->size += GOT_ENTRY_SIZE;
htab->irelplt->size += RELA_ENTRY_SIZE;
htab->irelplt->reloc_count++;
/* In order to make pointer equality work with IFUNC symbols defined
in a non-PIE executable and referenced in a shared lib, we turn
the symbol into a STT_FUNC symbol and make the symbol value to
point to the IPLT slot. That way the referencing shared lib will
always get the PLT slot address when resolving the respective
R_390_GLOB_DAT/R_390_64 relocs on that symbol. */
if (bfd_link_pde (info)
Add output_type to bfd_link_info The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise.
2015-08-18 14:51:03 +02:00
&& h->def_regular
&& h->ref_dynamic)
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
{
h->root.u.def.section = htab->iplt;
h->root.u.def.value = h->plt.offset;
h->size = PLT_ENTRY_SIZE;
h->type = STT_FUNC;
}
/* We need dynamic relocation for STT_GNU_IFUNC symbol only when
there is a non-GOT reference in a shared object. */
Add output_type to bfd_link_info The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise.
2015-08-18 14:51:03 +02:00
if (!bfd_link_pic (info) || !h->non_got_ref)
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
*head = NULL;
/* Finally, allocate space. */
p = *head;
if (p != NULL)
{
bfd_size_type count = 0;
do
{
count += p->count;
p = p->next;
}
while (p != NULL);
htab->irelifunc->size += count * RELA_ENTRY_SIZE;
}
/* Decide whether the got.iplt slot can be used. This has to be
avoided if the values in the GOT slots could differ for pointer
equality reasons. */
if (h->got.refcount <= 0
Add output_type to bfd_link_info The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise.
2015-08-18 14:51:03 +02:00
|| (bfd_link_pic (info)
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
&& (h->dynindx == -1 || h->forced_local))
|| bfd_link_pie (info)
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
|| htab->sgot == NULL)
{
/* Use .got.iplt. */
h->got.offset = (bfd_vma) -1;
}
else
{
h->got.offset = htab->sgot->size;
htab->sgot->size += GOT_ENTRY_SIZE;
Add output_type to bfd_link_info The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise.
2015-08-18 14:51:03 +02:00
if (bfd_link_pic (info))
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
htab->srelgot->size += RELA_ENTRY_SIZE;
}
return TRUE;
}
static bfd_boolean
elf_s390_allocate_local_syminfo (bfd *abfd, Elf_Internal_Shdr *symtab_hdr)
{
bfd_size_type size;
size = symtab_hdr->sh_info;
size *= (sizeof (bfd_signed_vma) /* local got */
+ sizeof (struct plt_entry) /* local plt */
+ sizeof(char)); /* local tls type */
elf_local_got_refcounts (abfd) = ((bfd_signed_vma *)
bfd_zalloc (abfd, size));
if (elf_local_got_refcounts (abfd) == NULL)
return FALSE;
elf_s390_local_plt (abfd)
= (struct plt_entry*)(elf_local_got_refcounts (abfd)
+ symtab_hdr->sh_info);
elf_s390_local_got_tls_type (abfd)
= (char *) (elf_s390_local_plt (abfd) + symtab_hdr->sh_info);
return TRUE;
}
/* Pick ELFOSABI_GNU if IFUNC symbols are used. */
static bfd_boolean
elf_s390_add_symbol_hook (bfd *abfd,
struct bfd_link_info *info,
Elf_Internal_Sym *sym,
const char **namep ATTRIBUTE_UNUSED,
flagword *flagsp ATTRIBUTE_UNUSED,
asection **secp ATTRIBUTE_UNUSED,
bfd_vma *valp ATTRIBUTE_UNUSED)
{
if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
|| ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
&& (abfd->flags & DYNAMIC) == 0
&& bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
Set EI_OSABI to ELFOSABI_GNU for local IFUNC symbols Since the backend elf_add_symbol_hook isn't called on local symbols, the EI_OSABI field isn't to ELFOSABI_GNU where are local IFUNC symbols. This patch changes the x86 backends to set has_gnu_symbols if there are relocations against IFUNC symbols. Other backends with IFUNC support may need a similar change. This patch also changes the type of has_gnu_symbols from bfd_boolean to enum elf_gnu_symbols. bfd/ PR ld/18815 * elf-bfd.h (elf_gnu_symbols): New enum. (elf_obj_tdata): Use elf_gnu_symbols on has_gnu_symbols. * elf-s390-common.c (elf_s390_add_symbol_hook): Set has_gnu_symbols to elf_gnu_symbol_any. * elf32-arm.c (elf32_arm_add_symbol_hook): Likewise. * elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise. * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise. * elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise. * elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise. * elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise. * lfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise. * elf32-i386.c (elf_i386_check_relocs): Update has_gnu_symbols if there are relocations against IFUNC symbols. (elf_i386_add_symbol_hook): Don't check STT_GNU_IFUNC here. * elf64-x86-64. (elf_x86_64_check_relocs): Update has_gnu_symbols if there are relocations against IFUNC symbols. (elf_x86_64_add_symbol_hook): Don't check STT_GNU_IFUNC here. ld/testsuite/ PR ld/18815 * ld-i386/i386.exp: Run pr18815. * ld-x86-64/x86-64.exp: Likewise. * ld-i386/pr18815.d: New file. * ld-i386/pr18815.s: Likewise. * ld-x86-64/pr18815.d: Likewise. * ld-x86-64/pr18815.s: Likewise.
2015-08-12 22:31:29 +02:00
elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any;
2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf64-s390.c: Include elf-s390-common.c. (R_390_IRELATIVE): New reloc. (elf_s390_reloc_type_lookup): Support R_390_IRELATIVE. (RELA_ENTRY_SIZE): New macro. (elf_s390_link_hash_entry): New fields ifunc_resolver_address and *ifunc_resolver_section. (struct plt_entry): New struct. (struct elf_s390_obj_tdata): New field local_plt. (elf_s390_local_plt): New macro. (struct elf_s390_link_hash_table): New field irelifunc. (ELF64): New macro. (link_hash_newfunc): Initialize new fields. (elf_s390_check_relocs): Handle IFUNC symbols. (elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC symbols. (allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for IFUNC symbols. (elf_s390_size_dynamic_sections): Handle IFUNC symbols. (elf_s390_relocate_section): Likewise. (elf_s390_finish_dynamic_symbol): Likewise. (elf_s390_finish_dynamic_sections): Handle local IFUNC symbols. (elf_s390_finish_ifunc_symbol): New function. (elf_s390_gc_sweep_hook): Handle local plt entries. (elf_backend_add_symbol_hook): Define. * elf32-s390.c: See elf64-s390.c changes. * elf-s390-common.c: New file. * bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field. * libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for BFD_RELOC_390_IRELATIVE. * reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * elf/s390.h (START_RELOC_NUMBERS): Define R_390_IRELATIVE reloc. 2012-07-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * emulparams/elf_s390.sh (IREL_IN_PLT): Define. * emulparams/elf64_s390.sh (IREL_IN_PLT): Define.
2012-07-13 17:47:27 +02:00
return TRUE;
}
/* Whether to sort relocs output by ld -r or ld --emit-relocs, by
r_offset. Don't do so for code sections. We want to keep ordering
of GDCALL / PLT32DBL for TLS optimizations as is. On the other
hand, elf-eh-frame.c processing requires .eh_frame relocs to be
sorted. */
static bfd_boolean
elf_s390_elf_sort_relocs_p (asection *sec)
{
return (sec->flags & SEC_CODE) == 0;
}
/* Merge object attributes from IBFD into OBFD. Raise an error if
there are conflicting attributes. */
static bfd_boolean
elf_s390_merge_obj_attributes (bfd *ibfd, bfd *obfd)
{
obj_attribute *in_attr, *in_attrs;
obj_attribute *out_attr, *out_attrs;
if (!elf_known_obj_attributes_proc (obfd)[0].i)
{
/* This is the first object. Copy the attributes. */
_bfd_elf_copy_obj_attributes (ibfd, obfd);
/* Use the Tag_null value to indicate the attributes have been
initialized. */
elf_known_obj_attributes_proc (obfd)[0].i = 1;
return TRUE;
}
in_attrs = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
out_attrs = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
/* Check for conflicting Tag_GNU_S390_ABI_Vector attributes and
merge non-conflicting ones. */
in_attr = &in_attrs[Tag_GNU_S390_ABI_Vector];
out_attr = &out_attrs[Tag_GNU_S390_ABI_Vector];
if (in_attr->i > 2)
_bfd_error_handler
(_("Warning: %B uses unknown vector ABI %d"), ibfd,
in_attr->i);
else if (out_attr->i > 2)
_bfd_error_handler
(_("Warning: %B uses unknown vector ABI %d"), obfd,
out_attr->i);
else if (in_attr->i != out_attr->i)
{
out_attr->type = ATTR_TYPE_FLAG_INT_VAL;
if (in_attr->i && out_attr->i)
{
const char abi_str[3][9] = { "none", "software", "hardware" };
_bfd_error_handler
(_("Warning: %B uses vector %s ABI, %B uses %s ABI"),
ibfd, obfd, abi_str[in_attr->i], abi_str[out_attr->i]);
}
if (in_attr->i > out_attr->i)
out_attr->i = in_attr->i;
}
/* Merge Tag_compatibility attributes and any common GNU ones. */
_bfd_elf_merge_object_attributes (ibfd, obfd);
return TRUE;
}