2002-01-16 05:52:38 +00:00
|
|
|
# This shell script emits a C file. -*- C -*-
|
2010-02-03 12:03:35 +00:00
|
|
|
# Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
2008-01-15 07:25:49 +00:00
|
|
|
# Free Software Foundation, Inc.
|
2002-01-16 05:52:38 +00:00
|
|
|
#
|
2007-07-06 14:09:45 +00:00
|
|
|
# This file is part of the GNU Binutils.
|
2002-01-16 05:52:38 +00:00
|
|
|
#
|
|
|
|
# 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
|
2007-07-06 14:09:45 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2002-01-16 05:52:38 +00:00
|
|
|
# (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
|
2007-07-06 14:09:45 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA.
|
2002-01-16 05:52:38 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# This file is sourced from elf32.em, and defines extra powerpc64-elf
|
|
|
|
# specific routines.
|
|
|
|
#
|
2007-07-19 19:56:10 +00:00
|
|
|
fragment <<EOF
|
2002-01-16 05:52:38 +00:00
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
#include "ldctor.h"
|
2002-05-02 09:48:15 +00:00
|
|
|
#include "libbfd.h"
|
2004-01-09 05:36:30 +00:00
|
|
|
#include "elf-bfd.h"
|
2002-01-16 05:52:38 +00:00
|
|
|
#include "elf64-ppc.h"
|
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
/* Fake input file for stubs. */
|
|
|
|
static lang_input_statement_type *stub_file;
|
2003-07-10 00:38:19 +00:00
|
|
|
static int stub_added = 0;
|
2002-05-01 02:34:54 +00:00
|
|
|
|
2005-03-29 11:07:38 +00:00
|
|
|
/* Whether we need to call ppc_layout_sections_again. */
|
|
|
|
static int need_laying_out = 0;
|
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
/* Maximum size of a group of input sections that can be handled by
|
|
|
|
one stub section. A value of +/-1 indicates the bfd back-end
|
|
|
|
should use a suitable default size. */
|
|
|
|
static bfd_signed_vma group_size = 1;
|
|
|
|
|
2002-05-22 09:04:48 +00:00
|
|
|
/* Whether to add ".foo" entries for each "foo" in a version script. */
|
|
|
|
static int dotsyms = 1;
|
|
|
|
|
2003-02-09 04:36:44 +00:00
|
|
|
/* Whether to run tls optimization. */
|
2004-11-04 11:55:13 +00:00
|
|
|
static int no_tls_opt = 0;
|
include/elf/
* ppc.h (DT_PPC_TLSOPT): Define.
* ppc64.h (DT_PPC64_TLSOPT): Define.
bfd/
* elf32-ppc.c (TLS_GET_ADDR_GLINK_SIZE): Define.
(ADD_3_12_2, BEQLR, CMPWI_11_0, LWZ_11_3, LWZ_12_3): Define.
(MR_0_3, MR_3_0): Define.
(struct ppc_elf_link_hash_table): Add no_tls_get_addr_opt.
(ppc_elf_select_plt_layout): Save emit_stub_syms param earlier.
(ppc_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt
(allocate_dynrelocs): Increase glink entry size for __tls_get_addr.
(ppc_elf_size_dynamic_sections): Add DT_PPC_TLS_OPT tag.
(write_glink_stub): Add param p.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Emit special glink call stub for
__tls_get_addr.
* elf32-ppc.h (ppc_elf_tls_setup): Update prototype.
* elf64-ppc.c (struct ppc_link_hash_table): Add no_tls_get_addr_opt.
(ppc64_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt.
(ppc64_elf_size_dynamic_sections): Add DT_PPC64_TLS_OPT tag.
(LD_R11_0R3, LD_R12_0R3, MR_R0_R3, CMPDI_R11_0, ADD_R3_R12_R13,
BEQLR, MR_R3_R0, MFLR_R11, STD_R11_0R1, BCTRL, LD_R11_0R1,
LD_R2_0R1, MTLR_R11): Define.
(build_tls_get_addr_stub): New function.
(ppc_build_one_stub): Call it.
(ppc_size_one_stub): Add extra size for __tls_get_addr stub.
(ppc64_elf_relocate_section): Don't change nop to ld 2,40(1) for
__tls_get_addr plt call.
* elf64-ppc.h (ppc64_elf_tls_setup): Update prototype.
binutils/
* readelf.c (get_ppc_dynamic_type): Add TLSOPT.
(get_ppc64_dynamic_type): Likewise.
ld/
* emultempl/ppc32elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define. Redefine other options in
terms of previous option.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
* emultempl/ppc64elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc64_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
ld/testsuite/
* ld-powerpc/tlslib.s: Delete dot-symbol entry syms. Add
__tls_get_addr_opt.
* ld-powerpc/tlslib32.s: Add __tls_get_addr_opt.
* ld-powerpc/oldtlslib.s: New file, old-abi version of tlslib.s.
* ld-powerpc/powerpc.exp: Build old-abi library and use it in
two new link tests.
* ld-powerpc/tlsexe.d: Update for new __tls_get_addr stub.
* ld-powerpc/tlsexe.g, * ld-powerpc/tlsexe.r, *ld-powerpc/tlsexe32.d,
* ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r,
* ld-powerpc/tlsexetoc.d, * ld-powerpc/tlsexetoc.g,
* ld-powerpc/tlsexetoc.r: Likewise.
2009-09-21 11:51:02 +00:00
|
|
|
static int no_tls_get_addr_opt = 0;
|
2004-11-04 11:55:13 +00:00
|
|
|
|
|
|
|
/* Whether to run opd optimization. */
|
|
|
|
static int no_opd_opt = 0;
|
|
|
|
|
|
|
|
/* Whether to run toc optimization. */
|
|
|
|
static int no_toc_opt = 0;
|
2003-02-09 04:36:44 +00:00
|
|
|
|
2005-01-06 09:03:56 +00:00
|
|
|
/* Whether to allow multiple toc sections. */
|
|
|
|
static int no_multi_toc = 0;
|
|
|
|
|
2003-06-08 14:07:34 +00:00
|
|
|
/* Whether to emit symbols for stubs. */
|
2009-10-02 15:00:30 +00:00
|
|
|
static int emit_stub_syms = -1;
|
2003-06-08 14:07:34 +00:00
|
|
|
|
|
|
|
static asection *toc_section = 0;
|
|
|
|
|
2004-08-19 07:47:25 +00:00
|
|
|
/* Whether to canonicalize .opd so that there are no overlapping
|
|
|
|
.opd entries. */
|
|
|
|
static int non_overlapping_opd = 0;
|
2002-05-01 02:34:54 +00:00
|
|
|
|
|
|
|
/* This is called before the input files are opened. We create a new
|
|
|
|
fake input file to hold the stub sections. */
|
|
|
|
|
|
|
|
static void
|
2003-06-20 05:33:26 +00:00
|
|
|
ppc_create_output_section_statements (void)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
2008-02-15 09:03:02 +00:00
|
|
|
if (!(bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
|
* elf-bfd.h (emum elf_object_id): Rename to elf_target_id. Add
entries for other architectures.
(struct elf_link_hash_table): Add hash_table_id field.
(elf_hash_table_id): New accessor macro.
* elflink.c (_bfd_elf_link_hash_table_init): Add target_id
parameter.
* elf-m10300.c (elf32_mn10300_hash_table): Check table id before
returning cast pointer.
(elf32_mn10300_link_hash_table_create): Identify new table as
containing MN10300 extensions.
(mn10300_elf_relax_section): Check pointer returned by
elf32_mn10300_hash_table.
* elf32-arm.c: Likewise, except using ARM extensions.
* elf32-avr.c: Likewise, except using AVR extensions.
* elf32-bfin.c: Likewise, except using BFIN extensions.
* elf32-cris.c: Likewise, except using CRIS extensions.
* elf32-frv.c: Likewise, except using FRV extensions.
* elf32-hppa.c: Likewise, except using HPPA32 extensions.
* elf32-i386.c: Likewise, except using I386 extensions.
* elf32-lm32.c: Likewise, except using LM32 extensions.
* elf32-m32r.c: Likewise, except using M32RM extensions.
* elf32-m68hc11.c: Likewise, except using M68HC11 extensions.
* elf32-m68hc1x.c: Likewise, except using M68HC11 extensions.
* elf32-m68hc1x.h: Likewise, except using M68HC11 extensions.
* elf32-m68k.c: Likewise, except using M68K extensions.
* elf32-microblaze.c: Likewise, except using MICROBLAZE extensions.
* elf32-ppc.c: Likewise, except using PPC32 extensions.
* elf32-s390.c: Likewise, except using S390 extensions.
* elf32-sh.c: Likewise, except using SH extensions.
* elf32-spu.c: Likewise, except using SPU extensions.
* elf32-xtensa.c: Likewise, except using XTENSA extensions.
* elf64-alpha.c: Likewise, except using ALPHA extensions.
* elf64-hppa.c: Likewise, except using HPPA64 extensions.
* elf64-ppc.c: Likewise, except using PPC64 extensions.
* elf64-s390.c: Likewise, except using S390 extensions.
* elf64-x86-64.c: Likewise, except using X86_64 extensions.
* elfxx-ia64.c: Likewise, except using IA64 extensions.
* elfxx-mips.c: Likewise, except using MIPS extensions.
* elfxx-sparc.c: Likewise, except using SPARC extensions.
* elfxx-sparc.h: Likewise, except using SPARC extensions.
* elf32-cr16.c (struct elf32_cr16_link_hash_table): Delete
redundant structure.
(elf32_cr16_hash_table): Delete unused macro.
(elf32_cr16_link_hash_traverse): Delete unused macro.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-vax.c: Likewise.
* elf64-sh64.c: Likewise.
* emultempl/alphaelf.em: Update value expected from elf_object_id.
* emultempl/hppaelf.em: Likewise.
* emultempl/mipself.em: Likewise.
* emultempl/ppc32elf.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
2010-02-04 09:16:43 +00:00
|
|
|
&& elf_object_id (link_info.output_bfd) == PPC64_ELF_DATA))
|
2003-02-17 22:49:24 +00:00
|
|
|
return;
|
|
|
|
|
2004-03-22 22:58:04 +00:00
|
|
|
link_info.wrap_char = '.';
|
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
stub_file = lang_add_input_file ("linker stubs",
|
|
|
|
lang_input_file_is_fake_enum,
|
|
|
|
NULL);
|
2008-02-15 03:35:53 +00:00
|
|
|
stub_file->the_bfd = bfd_create ("linker stubs", link_info.output_bfd);
|
2002-05-01 02:34:54 +00:00
|
|
|
if (stub_file->the_bfd == NULL
|
|
|
|
|| !bfd_set_arch_mach (stub_file->the_bfd,
|
2008-02-15 03:35:53 +00:00
|
|
|
bfd_get_arch (link_info.output_bfd),
|
|
|
|
bfd_get_mach (link_info.output_bfd)))
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
2005-02-16 02:20:13 +00:00
|
|
|
einfo ("%F%P: can not create BFD %E\n");
|
2002-05-01 02:34:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-10 09:15:08 +00:00
|
|
|
stub_file->the_bfd->flags |= BFD_LINKER_CREATED;
|
2002-05-01 02:34:54 +00:00
|
|
|
ldlang_add_file (stub_file);
|
2003-07-10 00:38:19 +00:00
|
|
|
ppc64_elf_init_stub_bfd (stub_file->the_bfd, &link_info);
|
2002-05-01 02:34:54 +00:00
|
|
|
}
|
|
|
|
|
2002-11-12 07:56:38 +00:00
|
|
|
static void
|
2003-06-20 05:33:26 +00:00
|
|
|
ppc_before_allocation (void)
|
2002-11-12 07:56:38 +00:00
|
|
|
{
|
2003-02-17 22:49:24 +00:00
|
|
|
if (stub_file != NULL)
|
2003-02-04 14:51:35 +00:00
|
|
|
{
|
2008-01-15 07:25:49 +00:00
|
|
|
if (!no_opd_opt
|
2008-02-15 03:35:53 +00:00
|
|
|
&& !ppc64_elf_edit_opd (link_info.output_bfd, &link_info,
|
|
|
|
non_overlapping_opd))
|
2005-02-16 02:20:13 +00:00
|
|
|
einfo ("%X%P: can not edit %s %E\n", "opd");
|
2003-02-09 04:36:44 +00:00
|
|
|
|
include/elf/
* ppc.h (DT_PPC_TLSOPT): Define.
* ppc64.h (DT_PPC64_TLSOPT): Define.
bfd/
* elf32-ppc.c (TLS_GET_ADDR_GLINK_SIZE): Define.
(ADD_3_12_2, BEQLR, CMPWI_11_0, LWZ_11_3, LWZ_12_3): Define.
(MR_0_3, MR_3_0): Define.
(struct ppc_elf_link_hash_table): Add no_tls_get_addr_opt.
(ppc_elf_select_plt_layout): Save emit_stub_syms param earlier.
(ppc_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt
(allocate_dynrelocs): Increase glink entry size for __tls_get_addr.
(ppc_elf_size_dynamic_sections): Add DT_PPC_TLS_OPT tag.
(write_glink_stub): Add param p.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Emit special glink call stub for
__tls_get_addr.
* elf32-ppc.h (ppc_elf_tls_setup): Update prototype.
* elf64-ppc.c (struct ppc_link_hash_table): Add no_tls_get_addr_opt.
(ppc64_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt.
(ppc64_elf_size_dynamic_sections): Add DT_PPC64_TLS_OPT tag.
(LD_R11_0R3, LD_R12_0R3, MR_R0_R3, CMPDI_R11_0, ADD_R3_R12_R13,
BEQLR, MR_R3_R0, MFLR_R11, STD_R11_0R1, BCTRL, LD_R11_0R1,
LD_R2_0R1, MTLR_R11): Define.
(build_tls_get_addr_stub): New function.
(ppc_build_one_stub): Call it.
(ppc_size_one_stub): Add extra size for __tls_get_addr stub.
(ppc64_elf_relocate_section): Don't change nop to ld 2,40(1) for
__tls_get_addr plt call.
* elf64-ppc.h (ppc64_elf_tls_setup): Update prototype.
binutils/
* readelf.c (get_ppc_dynamic_type): Add TLSOPT.
(get_ppc64_dynamic_type): Likewise.
ld/
* emultempl/ppc32elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define. Redefine other options in
terms of previous option.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
* emultempl/ppc64elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc64_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
ld/testsuite/
* ld-powerpc/tlslib.s: Delete dot-symbol entry syms. Add
__tls_get_addr_opt.
* ld-powerpc/tlslib32.s: Add __tls_get_addr_opt.
* ld-powerpc/oldtlslib.s: New file, old-abi version of tlslib.s.
* ld-powerpc/powerpc.exp: Build old-abi library and use it in
two new link tests.
* ld-powerpc/tlsexe.d: Update for new __tls_get_addr stub.
* ld-powerpc/tlsexe.g, * ld-powerpc/tlsexe.r, *ld-powerpc/tlsexe32.d,
* ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r,
* ld-powerpc/tlsexetoc.d, * ld-powerpc/tlsexetoc.g,
* ld-powerpc/tlsexetoc.r: Likewise.
2009-09-21 11:51:02 +00:00
|
|
|
if (ppc64_elf_tls_setup (link_info.output_bfd, &link_info,
|
|
|
|
no_tls_get_addr_opt)
|
2008-02-15 03:35:53 +00:00
|
|
|
&& !no_tls_opt)
|
2003-02-17 22:49:24 +00:00
|
|
|
{
|
|
|
|
/* Size the sections. This is premature, but we want to know the
|
|
|
|
TLS segment layout so that certain optimizations can be done. */
|
* ld.h (lang_phase_type): Move to..
* ldexp.h: ..here. Add lang_mark_phase_enum.
(node_type): Remove etree_undef and etree_unspec.
(exp_data_seg): Delete.
(struct ldexp_control, expld): New.
(invalid, exp_mark_used_section): Delete.
(exp_fold_tree, exp_get_vma, exp_get_value_int, exp_get_fill,
exp_get_abs_int): Update prototypes.
* ldexp.c (assigning_to_dot): Delete.
(expld): Define.
(make_abs): Operate directly on expld.result. Update all callers.
(new_abs): Likewise. Return void.
(new_rel_from_abs): Rename from new_rel_from_section.
(new_rel, new_rel_from_abs): Operate on expld.result and return void.
Update all callers.
(fold_unary): Operate on expld.result and return void. Remove
"current_section", "allocation_done", "dot", "dotp" and "mark_used"
params. Update all callers.
(fold_binary, fold_trinary, fold_name, exp_fold_tree_1): Likewise.
(fold_unary <ALIGN_K>): Ensure alignment is absolute.
(fold_unary <ABSOLUTE>): Use make_abs.
(fold_unary <DATA_SEGMENT_END>): Evaluate mark_phase as for
allocating_phase.
(fold_binary <DATA_SEGMENT_ALIGN, DATA_SEGMENT_RELRO_END, >): Ditto.
(fold_binary <'%','/'>): Don't error if marking.
(fold_name <SIZEOF_HEADERS>): Don't call bfd_sizeof_headers when
marking.
(fold_name <NAME>): Remove FIXME; -R is handled correctly. Don't
error when marking.
(fold_name <ADDR, LOADADDR, SIZEOF>): Don't set SEC_KEEP.
(exp_fold_tree_1): Don't error when marking.
(exp_fold_tree_1 <etree_rel>): Evaluate in all phases except first.
(exp_fold_tree_1 <etree_assign to dot>): Don't check for NULL
current section, instead check for NULL dotp.
(exp_fold_tree_1 <etree_provide>): Don't evaluate the assignment
source unless the symbol is referenced and undefined.
(exp_fold_tree): Remove "allocation_done" and "dot" params. Save
params to expld.
(exp_fold_tree_no_dot): Remove "current_section", "allocation_done
and "mark_used" params. Save params to expld. Update all callers.
(exp_assop): Do without temp var.
(exp_print_tree <etree_undef>): Delete code.
(exp_get_vma): Remove "allocation_done" param. Correct error return.
(exp_get_fill, exp_get_abs_int): Likewise.
(exp_get_value_int): Remove "allocation_done" param.
(exp_mark_used_section): Delete.
* ldgram.y (fill_exp): Update exp_get_fill call.
(origin_spec, length_spec): Update exp_get_vma call.
* ldlang.c (lang_init): Don't bother clearing lang_statement_iteration.
(lang_mark_used_section_1, lang_mark_used_section): Delete.
(strip_excluded_output_sections): Call one_lang_size_sections_pass in
marking mode. Merge old lang_mark_used_section code. Correct handling
of output sections with excluded input sections and data statements.
Don't drop non-zero sized sections. Don't zap os->bfd_section.
Do set SEC_EXCLUDE when appropriate.
(print_output_section_statement): Update for changed ldexp.c
interface.
(print_assignment, lang_size_sections_1): Likewise.
(lang_do_assignments_1, lang_enter_output_section_statement): Likewise.
(lang_new_phdr, lang_record_phdrs): Likewise.
(lang_size_sections): Likewise.
(insert_pad): Use following statement if it is a pad, rather than
creating a new one.
(lang_size_sections_1 <lang_output_section_statement_enum>): Do
process ignored output section to set vma and lma, but don't
update dot for these sections. Don't error if marking.
(lang_size_sections_1 <lang_assignment_statement_enum>): Don't
update dot for ignored sections.
(lang_size_sections_1 <lang_data_statement_enum>): Don't mark absolute
section with SEC_ALLOC.
(one_lang_size_sections_pass): New function.
(lang_size_sections): Remove first five params. Set expld.phase on
entry and exit. Use one_lang_size_sections_pass.
(lang_do_assignments): Remove all params. Update all callers.
(lang_reset_memory_regions): Clear os->processed for all output
section statements.
* ldlang.h (lang_do_assignments): Update prototype.
(lang_size_sections): Likewise.
(one_lang_size_sections_pass): Declare.
* pe-dll.c (pe_dll_fill_sections, pe_exe_fill_sections): Update
lang_size_sections and lang_do_assignments calls.
* emultempl/elf32.em (layout_sections_again): Likewise.
* emultempl/ppc64elf.em (ppc_before_allocation): Use
one_lang_size_sections_pass.
2005-06-09 02:05:47 +00:00
|
|
|
expld.phase = lang_mark_phase_enum;
|
|
|
|
expld.dataseg.phase = exp_dataseg_none;
|
|
|
|
one_lang_size_sections_pass (NULL, TRUE);
|
2003-02-17 22:49:24 +00:00
|
|
|
|
2008-02-15 03:35:53 +00:00
|
|
|
if (!ppc64_elf_tls_optimize (link_info.output_bfd, &link_info))
|
2005-02-16 02:20:13 +00:00
|
|
|
einfo ("%X%P: TLS problem %E\n");
|
2003-02-17 22:49:24 +00:00
|
|
|
|
2004-01-09 05:36:30 +00:00
|
|
|
/* We must not cache anything from the preliminary sizing. */
|
2003-02-17 22:49:24 +00:00
|
|
|
lang_reset_memory_regions ();
|
|
|
|
}
|
2004-11-04 11:55:13 +00:00
|
|
|
|
|
|
|
if (!no_toc_opt
|
|
|
|
&& !link_info.relocatable
|
2008-02-15 03:35:53 +00:00
|
|
|
&& !ppc64_elf_edit_toc (link_info.output_bfd, &link_info))
|
2005-02-16 02:20:13 +00:00
|
|
|
einfo ("%X%P: can not edit %s %E\n", "toc");
|
2003-02-04 14:51:35 +00:00
|
|
|
}
|
|
|
|
|
2002-11-12 07:56:38 +00:00
|
|
|
gld${EMULATION_NAME}_before_allocation ();
|
|
|
|
}
|
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
struct hook_stub_info
|
|
|
|
{
|
|
|
|
lang_statement_list_type add;
|
|
|
|
asection *input_section;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Traverse the linker tree to find the spot where the stub goes. */
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
static bfd_boolean
|
2003-06-20 05:33:26 +00:00
|
|
|
hook_in_stub (struct hook_stub_info *info, lang_statement_union_type **lp)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
|
|
|
lang_statement_union_type *l;
|
2002-11-30 08:39:46 +00:00
|
|
|
bfd_boolean ret;
|
2002-05-01 02:34:54 +00:00
|
|
|
|
|
|
|
for (; (l = *lp) != NULL; lp = &l->header.next)
|
|
|
|
{
|
|
|
|
switch (l->header.type)
|
|
|
|
{
|
|
|
|
case lang_constructors_statement_enum:
|
|
|
|
ret = hook_in_stub (info, &constructor_list.head);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case lang_output_section_statement_enum:
|
|
|
|
ret = hook_in_stub (info,
|
|
|
|
&l->output_section_statement.children.head);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case lang_wild_statement_enum:
|
|
|
|
ret = hook_in_stub (info, &l->wild_statement.children.head);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case lang_group_statement_enum:
|
|
|
|
ret = hook_in_stub (info, &l->group_statement.children.head);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case lang_input_section_enum:
|
|
|
|
if (l->input_section.section == info->input_section)
|
|
|
|
{
|
|
|
|
/* We've found our section. Insert the stub immediately
|
|
|
|
before its associated input section. */
|
|
|
|
*lp = info->add.head;
|
|
|
|
*(info->add.tail) = l;
|
2002-11-30 08:39:46 +00:00
|
|
|
return TRUE;
|
2002-05-01 02:34:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case lang_data_statement_enum:
|
|
|
|
case lang_reloc_statement_enum:
|
|
|
|
case lang_object_symbols_statement_enum:
|
|
|
|
case lang_output_statement_enum:
|
|
|
|
case lang_target_statement_enum:
|
|
|
|
case lang_input_statement_enum:
|
|
|
|
case lang_assignment_statement_enum:
|
|
|
|
case lang_padding_statement_enum:
|
|
|
|
case lang_address_statement_enum:
|
|
|
|
case lang_fill_statement_enum:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FAIL ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-11-30 08:39:46 +00:00
|
|
|
return FALSE;
|
2002-05-01 02:34:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Call-back for ppc64_elf_size_stubs. */
|
|
|
|
|
|
|
|
/* Create a new stub section, and arrange for it to be linked
|
|
|
|
immediately before INPUT_SECTION. */
|
|
|
|
|
|
|
|
static asection *
|
2003-06-20 05:33:26 +00:00
|
|
|
ppc_add_stub_section (const char *stub_sec_name, asection *input_section)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
|
|
|
asection *stub_sec;
|
|
|
|
flagword flags;
|
|
|
|
asection *output_section;
|
|
|
|
const char *secname;
|
|
|
|
lang_output_section_statement_type *os;
|
|
|
|
struct hook_stub_info info;
|
|
|
|
|
|
|
|
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
|
2007-02-13 01:53:03 +00:00
|
|
|
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_KEEP);
|
2008-07-07 00:46:51 +00:00
|
|
|
stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd,
|
|
|
|
stub_sec_name, flags);
|
|
|
|
if (stub_sec == NULL)
|
2002-05-01 02:34:54 +00:00
|
|
|
goto err_ret;
|
|
|
|
|
|
|
|
output_section = input_section->output_section;
|
|
|
|
secname = bfd_get_section_name (output_section->owner, output_section);
|
|
|
|
os = lang_output_section_find (secname);
|
|
|
|
|
|
|
|
info.input_section = input_section;
|
|
|
|
lang_list_init (&info.add);
|
2005-11-17 00:10:05 +00:00
|
|
|
lang_add_section (&info.add, stub_sec, os);
|
2002-05-01 02:34:54 +00:00
|
|
|
|
|
|
|
if (info.add.head == NULL)
|
|
|
|
goto err_ret;
|
|
|
|
|
2003-07-10 00:38:19 +00:00
|
|
|
stub_added = 1;
|
2002-05-01 02:34:54 +00:00
|
|
|
if (hook_in_stub (&info, &os->children.head))
|
|
|
|
return stub_sec;
|
|
|
|
|
|
|
|
err_ret:
|
|
|
|
einfo ("%X%P: can not make stub section: %E\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Another call-back for ppc64_elf_size_stubs. */
|
|
|
|
|
|
|
|
static void
|
2003-06-20 05:33:26 +00:00
|
|
|
ppc_layout_sections_again (void)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
|
|
|
/* If we have changed sizes of the stub sections, then we need
|
|
|
|
to recalculate all the section offsets. This may mean we need to
|
|
|
|
add even more stubs. */
|
2006-06-20 02:22:16 +00:00
|
|
|
gld${EMULATION_NAME}_map_segments (TRUE);
|
2002-01-16 05:52:38 +00:00
|
|
|
|
2003-06-25 06:40:27 +00:00
|
|
|
if (!link_info.relocatable)
|
2008-02-15 03:35:53 +00:00
|
|
|
_bfd_set_gp_value (link_info.output_bfd,
|
|
|
|
ppc64_elf_toc (link_info.output_bfd));
|
2009-08-10 07:50:56 +00:00
|
|
|
|
|
|
|
need_laying_out = -1;
|
2002-01-16 05:52:38 +00:00
|
|
|
}
|
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
|
2003-06-08 14:07:34 +00:00
|
|
|
static void
|
2003-06-20 05:33:26 +00:00
|
|
|
build_toc_list (lang_statement_union_type *statement)
|
2003-06-08 14:07:34 +00:00
|
|
|
{
|
2005-11-17 00:10:05 +00:00
|
|
|
if (statement->header.type == lang_input_section_enum)
|
|
|
|
{
|
|
|
|
asection *i = statement->input_section.section;
|
|
|
|
|
|
|
|
if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
|
|
|
|
&& (i->flags & SEC_EXCLUDE) == 0
|
|
|
|
&& i->output_section == toc_section)
|
2010-02-03 12:03:35 +00:00
|
|
|
{
|
|
|
|
if (!ppc64_elf_next_toc_section (&link_info, i))
|
|
|
|
einfo ("%X%P: linker script separates .got and .toc\n");
|
|
|
|
}
|
2005-11-17 00:10:05 +00:00
|
|
|
}
|
2003-06-08 14:07:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
static void
|
2003-06-20 05:33:26 +00:00
|
|
|
build_section_lists (lang_statement_union_type *statement)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
2005-11-17 00:10:05 +00:00
|
|
|
if (statement->header.type == lang_input_section_enum)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
2005-11-17 00:10:05 +00:00
|
|
|
asection *i = statement->input_section.section;
|
|
|
|
|
|
|
|
if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
|
|
|
|
&& (i->flags & SEC_EXCLUDE) == 0
|
|
|
|
&& i->output_section != NULL
|
2008-02-15 03:35:53 +00:00
|
|
|
&& i->output_section->owner == link_info.output_bfd)
|
2005-11-17 00:10:05 +00:00
|
|
|
{
|
|
|
|
if (!ppc64_elf_next_input_section (&link_info, i))
|
|
|
|
einfo ("%X%P: can not size stub section: %E\n");
|
|
|
|
}
|
2002-05-01 02:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-22 09:04:48 +00:00
|
|
|
|
2009-08-10 07:50:56 +00:00
|
|
|
/* Call the back-end function to set TOC base after we have placed all
|
|
|
|
the sections. */
|
2002-01-16 05:52:38 +00:00
|
|
|
static void
|
2009-08-10 07:50:56 +00:00
|
|
|
gld${EMULATION_NAME}_after_allocation (void)
|
2002-01-16 05:52:38 +00:00
|
|
|
{
|
2009-08-10 07:50:56 +00:00
|
|
|
/* bfd_elf_discard_info just plays with data and debugging sections,
|
|
|
|
ie. doesn't affect code size, so we can delay resizing the
|
2005-03-29 11:07:38 +00:00
|
|
|
sections. It's likely we'll resize everything in the process of
|
|
|
|
adding stubs. */
|
2008-02-15 03:35:53 +00:00
|
|
|
if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
|
2005-03-29 11:07:38 +00:00
|
|
|
need_laying_out = 1;
|
|
|
|
|
2002-11-12 07:56:38 +00:00
|
|
|
/* If generating a relocatable output file, then we don't have any
|
|
|
|
stubs. */
|
2003-06-25 06:40:27 +00:00
|
|
|
if (stub_file != NULL && !link_info.relocatable)
|
2002-01-16 05:52:38 +00:00
|
|
|
{
|
2010-02-03 12:03:35 +00:00
|
|
|
int ret = ppc64_elf_setup_section_lists (&link_info,
|
|
|
|
&ppc_add_stub_section,
|
|
|
|
&ppc_layout_sections_again);
|
2005-02-16 02:20:13 +00:00
|
|
|
if (ret < 0)
|
|
|
|
einfo ("%X%P: can not size stub section: %E\n");
|
|
|
|
else if (ret > 0)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
2010-02-03 12:03:35 +00:00
|
|
|
ppc64_elf_start_multitoc_partition (&link_info);
|
|
|
|
|
|
|
|
if (!no_multi_toc)
|
|
|
|
{
|
|
|
|
toc_section = bfd_get_section_by_name (link_info.output_bfd,
|
|
|
|
".got");
|
|
|
|
if (toc_section != NULL)
|
|
|
|
lang_for_each_statement (build_toc_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ppc64_elf_layout_multitoc (&link_info)
|
|
|
|
&& !no_multi_toc
|
|
|
|
&& toc_section != NULL)
|
2003-06-08 14:07:34 +00:00
|
|
|
lang_for_each_statement (build_toc_list);
|
|
|
|
|
2010-02-03 12:03:35 +00:00
|
|
|
ppc64_elf_finish_multitoc_partition (&link_info);
|
2003-06-08 14:07:34 +00:00
|
|
|
|
2002-11-12 07:56:38 +00:00
|
|
|
lang_for_each_statement (build_section_lists);
|
2002-05-01 02:34:54 +00:00
|
|
|
|
2002-11-12 07:56:38 +00:00
|
|
|
/* Call into the BFD backend to do the real work. */
|
2010-02-03 12:03:35 +00:00
|
|
|
if (!ppc64_elf_size_stubs (&link_info, group_size))
|
2005-02-16 02:20:13 +00:00
|
|
|
einfo ("%X%P: can not size stub section: %E\n");
|
2002-01-16 05:52:38 +00:00
|
|
|
}
|
2002-05-01 02:34:54 +00:00
|
|
|
}
|
2002-01-16 05:52:38 +00:00
|
|
|
|
2006-06-20 02:22:16 +00:00
|
|
|
if (need_laying_out != -1)
|
2009-08-10 07:50:56 +00:00
|
|
|
{
|
|
|
|
gld${EMULATION_NAME}_map_segments (need_laying_out);
|
|
|
|
|
|
|
|
if (!link_info.relocatable)
|
|
|
|
_bfd_set_gp_value (link_info.output_bfd,
|
|
|
|
ppc64_elf_toc (link_info.output_bfd));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Final emulation specific call. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gld${EMULATION_NAME}_finish (void)
|
|
|
|
{
|
|
|
|
/* e_entry on PowerPC64 points to the function descriptor for
|
|
|
|
_start. If _start is missing, default to the first function
|
|
|
|
descriptor in the .opd section. */
|
|
|
|
entry_section = ".opd";
|
2005-03-29 11:07:38 +00:00
|
|
|
|
2004-08-09 06:48:37 +00:00
|
|
|
if (link_info.relocatable)
|
|
|
|
{
|
2008-02-15 03:35:53 +00:00
|
|
|
asection *toc = bfd_get_section_by_name (link_info.output_bfd, ".toc");
|
2004-08-09 06:48:37 +00:00
|
|
|
if (toc != NULL
|
2008-02-15 03:35:53 +00:00
|
|
|
&& bfd_section_size (link_info.output_bfd, toc) > 0x10000)
|
2004-08-09 06:48:37 +00:00
|
|
|
einfo ("%X%P: TOC section size exceeds 64k\n");
|
|
|
|
}
|
|
|
|
|
2003-07-10 00:38:19 +00:00
|
|
|
if (stub_added)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
2003-06-19 13:51:05 +00:00
|
|
|
char *msg = NULL;
|
|
|
|
char *line, *endline;
|
|
|
|
|
2009-10-02 15:00:30 +00:00
|
|
|
if (emit_stub_syms < 0)
|
|
|
|
emit_stub_syms = 1;
|
2003-06-19 13:51:05 +00:00
|
|
|
if (!ppc64_elf_build_stubs (emit_stub_syms, &link_info,
|
|
|
|
config.stats ? &msg : NULL))
|
2002-05-01 02:34:54 +00:00
|
|
|
einfo ("%X%P: can not build stubs: %E\n");
|
2003-06-19 13:51:05 +00:00
|
|
|
|
|
|
|
for (line = msg; line != NULL; line = endline)
|
|
|
|
{
|
|
|
|
endline = strchr (line, '\n');
|
|
|
|
if (endline != NULL)
|
|
|
|
*endline++ = '\0';
|
|
|
|
fprintf (stderr, "%s: %s\n", program_name, line);
|
|
|
|
}
|
|
|
|
if (msg != NULL)
|
|
|
|
free (msg);
|
2002-05-01 02:34:54 +00:00
|
|
|
}
|
2004-08-10 11:23:03 +00:00
|
|
|
|
|
|
|
ppc64_elf_restore_symbols (&link_info);
|
2005-08-04 01:19:10 +00:00
|
|
|
finish_default ();
|
2002-05-01 02:34:54 +00:00
|
|
|
}
|
2002-01-16 05:52:38 +00:00
|
|
|
|
2002-02-05 07:07:21 +00:00
|
|
|
|
2002-05-22 09:04:48 +00:00
|
|
|
/* Add a pattern matching ".foo" for every "foo" in a version script.
|
|
|
|
|
|
|
|
The reason for doing this is that many shared library version
|
|
|
|
scripts export a selected set of functions or data symbols, forcing
|
|
|
|
others local. eg.
|
|
|
|
|
|
|
|
. VERS_1 {
|
|
|
|
. global:
|
|
|
|
. this; that; some; thing;
|
|
|
|
. local:
|
|
|
|
. *;
|
|
|
|
. };
|
|
|
|
|
|
|
|
To make the above work for PowerPC64, we need to export ".this",
|
|
|
|
".that" and so on, otherwise only the function descriptor syms are
|
|
|
|
exported. Lack of an exported function code sym may cause a
|
|
|
|
definition to be pulled in from a static library. */
|
|
|
|
|
2003-06-20 05:33:26 +00:00
|
|
|
static struct bfd_elf_version_expr *
|
|
|
|
gld${EMULATION_NAME}_new_vers_pattern (struct bfd_elf_version_expr *entry)
|
2002-05-22 09:04:48 +00:00
|
|
|
{
|
|
|
|
struct bfd_elf_version_expr *dot_entry;
|
|
|
|
unsigned int len;
|
|
|
|
char *dot_pat;
|
|
|
|
|
2007-05-14 08:53:23 +00:00
|
|
|
if (!dotsyms
|
2008-11-26 01:04:17 +00:00
|
|
|
|| entry->pattern[0] == '.'
|
|
|
|
|| (!entry->literal && entry->pattern[0] == '*'))
|
2002-05-22 09:04:48 +00:00
|
|
|
return entry;
|
|
|
|
|
2003-06-20 05:33:26 +00:00
|
|
|
dot_entry = xmalloc (sizeof *dot_entry);
|
2003-10-22 06:58:17 +00:00
|
|
|
*dot_entry = *entry;
|
2002-05-22 09:04:48 +00:00
|
|
|
dot_entry->next = entry;
|
2008-11-26 01:04:17 +00:00
|
|
|
len = strlen (entry->pattern) + 2;
|
|
|
|
dot_pat = xmalloc (len);
|
|
|
|
dot_pat[0] = '.';
|
|
|
|
memcpy (dot_pat + 1, entry->pattern, len - 1);
|
|
|
|
dot_entry->pattern = dot_pat;
|
2002-05-22 09:04:48 +00:00
|
|
|
return dot_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
/* Avoid processing the fake stub_file in vercheck, stat_needed and
|
|
|
|
check_needed routines. */
|
2002-01-16 05:52:38 +00:00
|
|
|
|
2003-06-20 05:33:26 +00:00
|
|
|
static void (*real_func) (lang_input_statement_type *);
|
2002-01-16 05:52:38 +00:00
|
|
|
|
2003-06-20 05:33:26 +00:00
|
|
|
static void ppc_for_each_input_file_wrapper (lang_input_statement_type *l)
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
|
|
|
if (l != stub_file)
|
|
|
|
(*real_func) (l);
|
2002-01-16 05:52:38 +00:00
|
|
|
}
|
2002-05-01 02:34:54 +00:00
|
|
|
|
|
|
|
static void
|
2003-06-20 05:33:26 +00:00
|
|
|
ppc_lang_for_each_input_file (void (*func) (lang_input_statement_type *))
|
2002-05-01 02:34:54 +00:00
|
|
|
{
|
|
|
|
real_func = func;
|
|
|
|
lang_for_each_input_file (&ppc_for_each_input_file_wrapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define lang_for_each_input_file ppc_lang_for_each_input_file
|
|
|
|
|
2002-01-16 05:52:38 +00:00
|
|
|
EOF
|
|
|
|
|
2007-03-26 11:10:44 +00:00
|
|
|
if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
|
2007-07-19 19:56:10 +00:00
|
|
|
fragment <<EOF
|
2007-03-26 11:10:44 +00:00
|
|
|
/* Special handling for embedded SPU executables. */
|
|
|
|
extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
|
|
|
|
static bfd_boolean gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *);
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
ppc64_recognized_file (lang_input_statement_type *entry)
|
|
|
|
{
|
|
|
|
if (embedded_spu_file (entry, "-m64"))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return gld${EMULATION_NAME}_load_symbols (entry);
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
LDEMUL_RECOGNIZED_FILE=ppc64_recognized_file
|
|
|
|
fi
|
|
|
|
|
2002-05-01 02:34:54 +00:00
|
|
|
# Define some shell vars to insert bits of code into the standard elf
|
|
|
|
# parse_args and list_options functions.
|
|
|
|
#
|
|
|
|
PARSE_AND_LIST_PROLOGUE='
|
|
|
|
#define OPTION_STUBGROUP_SIZE 301
|
2003-06-08 14:07:34 +00:00
|
|
|
#define OPTION_STUBSYMS (OPTION_STUBGROUP_SIZE + 1)
|
2009-10-02 15:00:30 +00:00
|
|
|
#define OPTION_NO_STUBSYMS (OPTION_STUBSYMS + 1)
|
|
|
|
#define OPTION_DOTSYMS (OPTION_NO_STUBSYMS + 1)
|
2002-05-22 09:04:48 +00:00
|
|
|
#define OPTION_NO_DOTSYMS (OPTION_DOTSYMS + 1)
|
2003-02-09 04:36:44 +00:00
|
|
|
#define OPTION_NO_TLS_OPT (OPTION_NO_DOTSYMS + 1)
|
include/elf/
* ppc.h (DT_PPC_TLSOPT): Define.
* ppc64.h (DT_PPC64_TLSOPT): Define.
bfd/
* elf32-ppc.c (TLS_GET_ADDR_GLINK_SIZE): Define.
(ADD_3_12_2, BEQLR, CMPWI_11_0, LWZ_11_3, LWZ_12_3): Define.
(MR_0_3, MR_3_0): Define.
(struct ppc_elf_link_hash_table): Add no_tls_get_addr_opt.
(ppc_elf_select_plt_layout): Save emit_stub_syms param earlier.
(ppc_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt
(allocate_dynrelocs): Increase glink entry size for __tls_get_addr.
(ppc_elf_size_dynamic_sections): Add DT_PPC_TLS_OPT tag.
(write_glink_stub): Add param p.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Emit special glink call stub for
__tls_get_addr.
* elf32-ppc.h (ppc_elf_tls_setup): Update prototype.
* elf64-ppc.c (struct ppc_link_hash_table): Add no_tls_get_addr_opt.
(ppc64_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt.
(ppc64_elf_size_dynamic_sections): Add DT_PPC64_TLS_OPT tag.
(LD_R11_0R3, LD_R12_0R3, MR_R0_R3, CMPDI_R11_0, ADD_R3_R12_R13,
BEQLR, MR_R3_R0, MFLR_R11, STD_R11_0R1, BCTRL, LD_R11_0R1,
LD_R2_0R1, MTLR_R11): Define.
(build_tls_get_addr_stub): New function.
(ppc_build_one_stub): Call it.
(ppc_size_one_stub): Add extra size for __tls_get_addr stub.
(ppc64_elf_relocate_section): Don't change nop to ld 2,40(1) for
__tls_get_addr plt call.
* elf64-ppc.h (ppc64_elf_tls_setup): Update prototype.
binutils/
* readelf.c (get_ppc_dynamic_type): Add TLSOPT.
(get_ppc64_dynamic_type): Likewise.
ld/
* emultempl/ppc32elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define. Redefine other options in
terms of previous option.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
* emultempl/ppc64elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc64_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
ld/testsuite/
* ld-powerpc/tlslib.s: Delete dot-symbol entry syms. Add
__tls_get_addr_opt.
* ld-powerpc/tlslib32.s: Add __tls_get_addr_opt.
* ld-powerpc/oldtlslib.s: New file, old-abi version of tlslib.s.
* ld-powerpc/powerpc.exp: Build old-abi library and use it in
two new link tests.
* ld-powerpc/tlsexe.d: Update for new __tls_get_addr stub.
* ld-powerpc/tlsexe.g, * ld-powerpc/tlsexe.r, *ld-powerpc/tlsexe32.d,
* ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r,
* ld-powerpc/tlsexetoc.d, * ld-powerpc/tlsexetoc.g,
* ld-powerpc/tlsexetoc.r: Likewise.
2009-09-21 11:51:02 +00:00
|
|
|
#define OPTION_NO_TLS_GET_ADDR_OPT (OPTION_NO_TLS_OPT + 1)
|
|
|
|
#define OPTION_NO_OPD_OPT (OPTION_NO_TLS_GET_ADDR_OPT + 1)
|
2004-11-04 11:55:13 +00:00
|
|
|
#define OPTION_NO_TOC_OPT (OPTION_NO_OPD_OPT + 1)
|
2005-01-06 09:03:56 +00:00
|
|
|
#define OPTION_NO_MULTI_TOC (OPTION_NO_TOC_OPT + 1)
|
|
|
|
#define OPTION_NON_OVERLAPPING_OPD (OPTION_NO_MULTI_TOC + 1)
|
2002-05-01 02:34:54 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
PARSE_AND_LIST_LONGOPTS='
|
|
|
|
{ "stub-group-size", required_argument, NULL, OPTION_STUBGROUP_SIZE },
|
2003-06-08 14:07:34 +00:00
|
|
|
{ "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
|
2009-10-02 15:00:30 +00:00
|
|
|
{ "no-emit-stub-syms", no_argument, NULL, OPTION_NO_STUBSYMS },
|
2002-05-22 09:04:48 +00:00
|
|
|
{ "dotsyms", no_argument, NULL, OPTION_DOTSYMS },
|
|
|
|
{ "no-dotsyms", no_argument, NULL, OPTION_NO_DOTSYMS },
|
2003-02-09 04:36:44 +00:00
|
|
|
{ "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
|
include/elf/
* ppc.h (DT_PPC_TLSOPT): Define.
* ppc64.h (DT_PPC64_TLSOPT): Define.
bfd/
* elf32-ppc.c (TLS_GET_ADDR_GLINK_SIZE): Define.
(ADD_3_12_2, BEQLR, CMPWI_11_0, LWZ_11_3, LWZ_12_3): Define.
(MR_0_3, MR_3_0): Define.
(struct ppc_elf_link_hash_table): Add no_tls_get_addr_opt.
(ppc_elf_select_plt_layout): Save emit_stub_syms param earlier.
(ppc_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt
(allocate_dynrelocs): Increase glink entry size for __tls_get_addr.
(ppc_elf_size_dynamic_sections): Add DT_PPC_TLS_OPT tag.
(write_glink_stub): Add param p.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Emit special glink call stub for
__tls_get_addr.
* elf32-ppc.h (ppc_elf_tls_setup): Update prototype.
* elf64-ppc.c (struct ppc_link_hash_table): Add no_tls_get_addr_opt.
(ppc64_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt.
(ppc64_elf_size_dynamic_sections): Add DT_PPC64_TLS_OPT tag.
(LD_R11_0R3, LD_R12_0R3, MR_R0_R3, CMPDI_R11_0, ADD_R3_R12_R13,
BEQLR, MR_R3_R0, MFLR_R11, STD_R11_0R1, BCTRL, LD_R11_0R1,
LD_R2_0R1, MTLR_R11): Define.
(build_tls_get_addr_stub): New function.
(ppc_build_one_stub): Call it.
(ppc_size_one_stub): Add extra size for __tls_get_addr stub.
(ppc64_elf_relocate_section): Don't change nop to ld 2,40(1) for
__tls_get_addr plt call.
* elf64-ppc.h (ppc64_elf_tls_setup): Update prototype.
binutils/
* readelf.c (get_ppc_dynamic_type): Add TLSOPT.
(get_ppc64_dynamic_type): Likewise.
ld/
* emultempl/ppc32elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define. Redefine other options in
terms of previous option.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
* emultempl/ppc64elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc64_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
ld/testsuite/
* ld-powerpc/tlslib.s: Delete dot-symbol entry syms. Add
__tls_get_addr_opt.
* ld-powerpc/tlslib32.s: Add __tls_get_addr_opt.
* ld-powerpc/oldtlslib.s: New file, old-abi version of tlslib.s.
* ld-powerpc/powerpc.exp: Build old-abi library and use it in
two new link tests.
* ld-powerpc/tlsexe.d: Update for new __tls_get_addr stub.
* ld-powerpc/tlsexe.g, * ld-powerpc/tlsexe.r, *ld-powerpc/tlsexe32.d,
* ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r,
* ld-powerpc/tlsexetoc.d, * ld-powerpc/tlsexetoc.g,
* ld-powerpc/tlsexetoc.r: Likewise.
2009-09-21 11:51:02 +00:00
|
|
|
{ "no-tls-get-addr-optimize", no_argument, NULL, OPTION_NO_TLS_GET_ADDR_OPT },
|
2004-11-04 11:55:13 +00:00
|
|
|
{ "no-opd-optimize", no_argument, NULL, OPTION_NO_OPD_OPT },
|
|
|
|
{ "no-toc-optimize", no_argument, NULL, OPTION_NO_TOC_OPT },
|
2005-01-06 09:03:56 +00:00
|
|
|
{ "no-multi-toc", no_argument, NULL, OPTION_NO_MULTI_TOC },
|
2004-08-19 07:47:25 +00:00
|
|
|
{ "non-overlapping-opd", no_argument, NULL, OPTION_NON_OVERLAPPING_OPD },
|
2002-05-01 02:34:54 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
PARSE_AND_LIST_OPTIONS='
|
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--stub-group-size=N Maximum size of a group of input sections that\n\
|
|
|
|
can be handled by one stub section. A negative\n\
|
|
|
|
value locates all stubs before their branches\n\
|
|
|
|
(with a group size of -N), while a positive\n\
|
|
|
|
value allows two groups of input sections, one\n\
|
|
|
|
before, and one after each stub section.\n\
|
|
|
|
Values of +/-1 indicate the linker should\n\
|
|
|
|
choose suitable defaults.\n"
|
2002-05-01 02:34:54 +00:00
|
|
|
));
|
2002-05-22 09:04:48 +00:00
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--emit-stub-syms Label linker stubs with a symbol.\n"
|
2003-06-08 14:07:34 +00:00
|
|
|
));
|
|
|
|
fprintf (file, _("\
|
2009-10-02 15:00:30 +00:00
|
|
|
--no-emit-stub-syms Don'\''t label linker stubs with a symbol.\n"
|
|
|
|
));
|
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--dotsyms For every version pattern \"foo\" in a version\n\
|
|
|
|
script, add \".foo\" so that function code\n\
|
|
|
|
symbols are treated the same as function\n\
|
|
|
|
descriptor symbols. Defaults to on.\n"
|
2002-05-22 09:04:48 +00:00
|
|
|
));
|
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--no-dotsyms Don'\''t do anything special in version scripts.\n"
|
2002-05-22 09:04:48 +00:00
|
|
|
));
|
2003-02-09 04:36:44 +00:00
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--no-tls-optimize Don'\''t try to optimize TLS accesses.\n"
|
2003-02-09 04:36:44 +00:00
|
|
|
));
|
2004-08-19 07:47:25 +00:00
|
|
|
fprintf (file, _("\
|
include/elf/
* ppc.h (DT_PPC_TLSOPT): Define.
* ppc64.h (DT_PPC64_TLSOPT): Define.
bfd/
* elf32-ppc.c (TLS_GET_ADDR_GLINK_SIZE): Define.
(ADD_3_12_2, BEQLR, CMPWI_11_0, LWZ_11_3, LWZ_12_3): Define.
(MR_0_3, MR_3_0): Define.
(struct ppc_elf_link_hash_table): Add no_tls_get_addr_opt.
(ppc_elf_select_plt_layout): Save emit_stub_syms param earlier.
(ppc_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt
(allocate_dynrelocs): Increase glink entry size for __tls_get_addr.
(ppc_elf_size_dynamic_sections): Add DT_PPC_TLS_OPT tag.
(write_glink_stub): Add param p.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Emit special glink call stub for
__tls_get_addr.
* elf32-ppc.h (ppc_elf_tls_setup): Update prototype.
* elf64-ppc.c (struct ppc_link_hash_table): Add no_tls_get_addr_opt.
(ppc64_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt.
(ppc64_elf_size_dynamic_sections): Add DT_PPC64_TLS_OPT tag.
(LD_R11_0R3, LD_R12_0R3, MR_R0_R3, CMPDI_R11_0, ADD_R3_R12_R13,
BEQLR, MR_R3_R0, MFLR_R11, STD_R11_0R1, BCTRL, LD_R11_0R1,
LD_R2_0R1, MTLR_R11): Define.
(build_tls_get_addr_stub): New function.
(ppc_build_one_stub): Call it.
(ppc_size_one_stub): Add extra size for __tls_get_addr stub.
(ppc64_elf_relocate_section): Don't change nop to ld 2,40(1) for
__tls_get_addr plt call.
* elf64-ppc.h (ppc64_elf_tls_setup): Update prototype.
binutils/
* readelf.c (get_ppc_dynamic_type): Add TLSOPT.
(get_ppc64_dynamic_type): Likewise.
ld/
* emultempl/ppc32elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define. Redefine other options in
terms of previous option.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
* emultempl/ppc64elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc64_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
ld/testsuite/
* ld-powerpc/tlslib.s: Delete dot-symbol entry syms. Add
__tls_get_addr_opt.
* ld-powerpc/tlslib32.s: Add __tls_get_addr_opt.
* ld-powerpc/oldtlslib.s: New file, old-abi version of tlslib.s.
* ld-powerpc/powerpc.exp: Build old-abi library and use it in
two new link tests.
* ld-powerpc/tlsexe.d: Update for new __tls_get_addr stub.
* ld-powerpc/tlsexe.g, * ld-powerpc/tlsexe.r, *ld-powerpc/tlsexe32.d,
* ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r,
* ld-powerpc/tlsexetoc.d, * ld-powerpc/tlsexetoc.g,
* ld-powerpc/tlsexetoc.r: Likewise.
2009-09-21 11:51:02 +00:00
|
|
|
--no-tls-get-addr-optimize Don'\''t use a special __tls_get_addr call.\n"
|
|
|
|
));
|
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--no-opd-optimize Don'\''t optimize the OPD section.\n"
|
2004-11-04 11:55:13 +00:00
|
|
|
));
|
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--no-toc-optimize Don'\''t optimize the TOC section.\n"
|
2004-11-04 11:55:13 +00:00
|
|
|
));
|
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--no-multi-toc Disallow automatic multiple toc sections.\n"
|
2005-01-06 09:03:56 +00:00
|
|
|
));
|
|
|
|
fprintf (file, _("\
|
2007-08-17 13:50:48 +00:00
|
|
|
--non-overlapping-opd Canonicalize .opd, so that there are no\n\
|
|
|
|
overlapping .opd entries.\n"
|
2004-08-19 07:47:25 +00:00
|
|
|
));
|
2002-05-01 02:34:54 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
PARSE_AND_LIST_ARGS_CASES='
|
|
|
|
case OPTION_STUBGROUP_SIZE:
|
|
|
|
{
|
|
|
|
const char *end;
|
|
|
|
group_size = bfd_scan_vma (optarg, &end, 0);
|
|
|
|
if (*end)
|
|
|
|
einfo (_("%P%F: invalid number `%s'\''\n"), optarg);
|
|
|
|
}
|
|
|
|
break;
|
2002-05-22 09:04:48 +00:00
|
|
|
|
2003-06-08 14:07:34 +00:00
|
|
|
case OPTION_STUBSYMS:
|
|
|
|
emit_stub_syms = 1;
|
|
|
|
break;
|
|
|
|
|
2009-10-02 15:00:30 +00:00
|
|
|
case OPTION_NO_STUBSYMS:
|
|
|
|
emit_stub_syms = 0;
|
|
|
|
break;
|
|
|
|
|
2002-05-22 09:04:48 +00:00
|
|
|
case OPTION_DOTSYMS:
|
2003-02-09 04:36:44 +00:00
|
|
|
dotsyms = 1;
|
2002-05-22 09:04:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_NO_DOTSYMS:
|
2003-02-09 04:36:44 +00:00
|
|
|
dotsyms = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_NO_TLS_OPT:
|
2004-11-04 11:55:13 +00:00
|
|
|
no_tls_opt = 1;
|
|
|
|
break;
|
|
|
|
|
include/elf/
* ppc.h (DT_PPC_TLSOPT): Define.
* ppc64.h (DT_PPC64_TLSOPT): Define.
bfd/
* elf32-ppc.c (TLS_GET_ADDR_GLINK_SIZE): Define.
(ADD_3_12_2, BEQLR, CMPWI_11_0, LWZ_11_3, LWZ_12_3): Define.
(MR_0_3, MR_3_0): Define.
(struct ppc_elf_link_hash_table): Add no_tls_get_addr_opt.
(ppc_elf_select_plt_layout): Save emit_stub_syms param earlier.
(ppc_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt
(allocate_dynrelocs): Increase glink entry size for __tls_get_addr.
(ppc_elf_size_dynamic_sections): Add DT_PPC_TLS_OPT tag.
(write_glink_stub): Add param p.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Emit special glink call stub for
__tls_get_addr.
* elf32-ppc.h (ppc_elf_tls_setup): Update prototype.
* elf64-ppc.c (struct ppc_link_hash_table): Add no_tls_get_addr_opt.
(ppc64_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt.
(ppc64_elf_size_dynamic_sections): Add DT_PPC64_TLS_OPT tag.
(LD_R11_0R3, LD_R12_0R3, MR_R0_R3, CMPDI_R11_0, ADD_R3_R12_R13,
BEQLR, MR_R3_R0, MFLR_R11, STD_R11_0R1, BCTRL, LD_R11_0R1,
LD_R2_0R1, MTLR_R11): Define.
(build_tls_get_addr_stub): New function.
(ppc_build_one_stub): Call it.
(ppc_size_one_stub): Add extra size for __tls_get_addr stub.
(ppc64_elf_relocate_section): Don't change nop to ld 2,40(1) for
__tls_get_addr plt call.
* elf64-ppc.h (ppc64_elf_tls_setup): Update prototype.
binutils/
* readelf.c (get_ppc_dynamic_type): Add TLSOPT.
(get_ppc64_dynamic_type): Likewise.
ld/
* emultempl/ppc32elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define. Redefine other options in
terms of previous option.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
* emultempl/ppc64elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc64_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
ld/testsuite/
* ld-powerpc/tlslib.s: Delete dot-symbol entry syms. Add
__tls_get_addr_opt.
* ld-powerpc/tlslib32.s: Add __tls_get_addr_opt.
* ld-powerpc/oldtlslib.s: New file, old-abi version of tlslib.s.
* ld-powerpc/powerpc.exp: Build old-abi library and use it in
two new link tests.
* ld-powerpc/tlsexe.d: Update for new __tls_get_addr stub.
* ld-powerpc/tlsexe.g, * ld-powerpc/tlsexe.r, *ld-powerpc/tlsexe32.d,
* ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r,
* ld-powerpc/tlsexetoc.d, * ld-powerpc/tlsexetoc.g,
* ld-powerpc/tlsexetoc.r: Likewise.
2009-09-21 11:51:02 +00:00
|
|
|
case OPTION_NO_TLS_GET_ADDR_OPT:
|
|
|
|
no_tls_get_addr_opt = 1;
|
|
|
|
break;
|
|
|
|
|
2004-11-04 11:55:13 +00:00
|
|
|
case OPTION_NO_OPD_OPT:
|
|
|
|
no_opd_opt = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_NO_TOC_OPT:
|
|
|
|
no_toc_opt = 1;
|
2002-05-22 09:04:48 +00:00
|
|
|
break;
|
2004-08-19 07:47:25 +00:00
|
|
|
|
2005-01-06 09:03:56 +00:00
|
|
|
case OPTION_NO_MULTI_TOC:
|
|
|
|
no_multi_toc = 1;
|
|
|
|
break;
|
|
|
|
|
2004-08-19 07:47:25 +00:00
|
|
|
case OPTION_NON_OVERLAPPING_OPD:
|
|
|
|
non_overlapping_opd = 1;
|
|
|
|
break;
|
2002-05-01 02:34:54 +00:00
|
|
|
'
|
|
|
|
|
2002-01-16 05:52:38 +00:00
|
|
|
# Put these extra ppc64elf routines in ld_${EMULATION_NAME}_emulation
|
|
|
|
#
|
2002-11-12 07:56:38 +00:00
|
|
|
LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
|
2002-01-16 05:52:38 +00:00
|
|
|
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
|
2006-06-20 02:22:16 +00:00
|
|
|
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
|
2002-05-01 02:34:54 +00:00
|
|
|
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
|
2002-05-22 09:04:48 +00:00
|
|
|
LDEMUL_NEW_VERS_PATTERN=gld${EMULATION_NAME}_new_vers_pattern
|